The USR function is also still there as a token (213).
All it does is jump to ZP $0A.
As in AppleSoft BASIC, the JMP vector defaults to the ILLEGAL QUANTITY ERROR text.
Code: Select all
100 A=USR(100)
Code: Select all
100 A=SGN(100)
The difference between the CALL and USR functions is that USR can pass a value to the procedure using a 4byte FLOAT and it has a fixed address.
Before calling ZP locations 11 and 12 should be updated to the address (little endian) of your ASM routine.
When RUN, BASIC places the value contained in brackets after the USR call as a FLOAT at $9D. If the function does not need to return a value, just return. However, if a value should be returned and placed in A, place the new FLOAT value at $9D and return.
This example places a short ASM routine at $6000, which returns 4 as a float.
Code: Select all
10 GOSUB 1000
20 A=SGN(100)
30 PRINT A
40 END
1000 POKE 11,0 : POKE 12,96
1010 FOR X=0 TO 12
1020 READ B : POKE24576 + X,B
1030 NEXT X
1040 RETURN
1050 DATA 169,131,133,157,169,0,133,158,133,159,133,160,60
The DATA statement contains
LDA #$83
STA $9D
LDA #0
STA $9E
STA $9F
STA $A0
RTS