| Routines

34B3: THE 'USR' FUNCTION (offset +2D)

The address of this routine is found in the table of addresses. It is called indirectly via fp_calc_2. This subroutine ('USR number' as distinct from 'USR string') handles the function USR X, where X is a number. The value of X is obtained in BC, a return address is stacked and the machine code is executed from location X.
usr_no | 34B3 | CALL FIND_INT2 | Evaluate the 'last value', rounded to the nearest integer; test that it is in range and return it in BC.
| 34B6 | LD HL,$2D2B | Make the return address be that of the subroutine STACK_BC.
| 34B9 | PUSH HL
| 34BA | PUSH BC | Make an indirect jump to the required location.
| 34BB | RET
Note: it is interesting that the IY register pair is re-initialised when the return to STACK_BC has been made, but the important HL' that holds the next literal pointer is not restored should it have been disturbed. For a successful return to BASIC, HL' must on exit from the machine code contain the address of the 'end-calc' instruction at +2758.