Prev: 25F5 Up: Map Next: 2627
25F8: THE 'SCANNING RND' ROUTINE
The address of this routine is derived from an offset found in the scanning function table.
Input
Output
S_RND 25F8 CALL SYNTAX_Z Unless syntax is being checked, jump to calculate a random number.
25FB JR Z,S_RND_END
25FD LD BC,(\$5C76) Fetch the current value of SEED.
2601 CALL STACK_BC Put it on the calculator stack.
2604 RST \$28 Now use the calculator.
2605 DEFB \$A1 stk_one
2606 DEFB \$0F addition: The 'last value' is now SEED+1.
2607 DEFB \$34 stk_data: Put the number 75 on the calculator stack.
2608 DEFB \$37,\$16
260A DEFB \$04 multiply: 'last value' (SEED+1)*75.
260B DEFB \$34 stk_data: Put the number 65537 on the calculator stack.
260C DEFB \$80,\$41,\$00,\$00,\$80
2611 DEFB \$32 n_mod_m: Divide (SEED+1)*75 by 65537 to give a 'remainder' and an 'answer'.
2612 DEFB \$02 delete: Discard the 'answer'.
2613 DEFB \$A1 stk_one
2614 DEFB \$03 subtract: The 'last value' is now 'remainder' - 1.
2615 DEFB \$31 duplicate: Make a copy of the 'last value'.
2616 DEFB \$38 end_calc: The calculation is finished.
2617 CALL FP_TO_BC Use the 'last value' to give the new value for SEED.
261A LD (\$5C76),BC
261E LD A,(HL) Fetch the exponent of 'last value'.
261F AND A Jump forward if the exponent is zero.
2620 JR Z,S_RND_END
2622 SUB \$10 Reduce the exponent, i.e. divide 'last value' by 65536 to give the required 'last value'.
2624 LD (HL),A
S_RND_END 2625 JR S_PI_END Jump past the S_PI routine.
 Prev: 25F5 Up: Map Next: 2627