[comp.sys.apple2] USR

ART100@psuvm.psu.edu (Andy Tefft) (11/07/90)

From the Applesoft Programmer's ref manual (not verbatim):

When USR is called, the value supplied in the argument is
placed in the floating-point accumulator ($9d to $a3) and
control is passed to location $0a-$0d which must contain
a JMP to your routine. Your routine should store the result
in the FAC and end with an RTS. The value in the FAC is passed
back to your applesoft program as the value yielded by USR.

EG:

*0a:4c 0 3
*300:18 a5 9d 69 3 85 9d 60

]print usr(3)
(prints out 24)

This simply multiplies the argument by 8.

Helpful hint: to obtain a 2-byte integer from the number in the FAC,
jsr to $e01c. The integer is returned in $a0 and $a1 (high and low
order bytes, respectively, so the manual says).

To put an integer number in the FAC, put the high order byte in
the A reg, the low order byte in the Y reg, and jsr to $e2f2.