User`s manual

8-9
For example, if the entry point is at 32700:
32700 decimal = 7FBC hexadecimal
LSB = BC hexadecimal = 188 decimal
MSB = 7F hexadecimal = 127 decimal
So use the statements:
POKE 16526, 188
POKE 16527, 127
to tell BASIC that the USR routine entry is at 32700.
Making the USR call
At the point in your BASIC program where you want to call the subroutine,
insert a statement like
X = USR(N)
where N can be an expression and must have a value between -32768 and
+32767 inclusive. This argument, N, can be used to pass a value to your
routine (see below) or you can simply consider it a dummy argument and not
use it at all.
When BASIC encounters your X=USR(N) statement, it will branch to the
address stored at 16526-16527. At the point in your USR routine where you
want to return to the BASIC program, insert a simple RET instruction –
unless you want to return a value to BASIC, in which case, see below.
Passing an argument to the USR routine
If you want to pass the USR(N) argument to your routine, then include the
following CALL instruction at the beginning of your USR routine:
CALL 0A7FH
This loads the argument N into the HL register pair as a two-byte signed
integer.
Returning an argument from the USR routine
To return an integer value to the USR(N) function, load the value (a two-byte
signed integer) into HL and place the following jump instruction at the end of
your routine:
JP 0A9AH