[Coco] USRx() and adding more parameters?
Sean Conner
sean at conman.org
Wed Nov 5 00:02:16 EST 2025
It was thus said that the Great William Astle via Coco once stated:
> On 2025-11-04 20:14, Allen Huffman via Coco wrote:
> >The BASIC ROM has the USR function:
> >
> >DEF USR0=&H3F00
> >
> >A=USR0(42)
> >
> >It accepts one parameter.
> >
> >Since it jumps from BASIC into the USR assembly, couldn’t that code just
> >parse a “,” and more numbers, allowing it to accept whatever needed to
> >be passed in?
> >
> >A=USR0(1,2,3,4)
>
> Almost. It would have to look like:
>
> A=USR0(1),2,3,4
>
> The closing parenthesis is already validated by the time the USR handler
> starts.
I did a proof-of-concept:
include "basic.i"
org $7F00
.opt basic defusr0 pokew
pokew jsr INTCVT
std $F4 ; unused by BASIC
jsr $B26D ; skip comma
jsr $B156 ; evaluate expression
jsr INTCVT ; get value
std $F6 ; unused by BASIC
clra
clrb
jmp GIVABF
end
basic.i defines INTCVT and GIVABF. This works. BASIC program:
10 DATA189,179,237,221,244,189,178,109,189,177,86,189,179,237,221,246,79,95,126, 180,244
20 CLEAR200,32511:FORA=32512TO32532:READB:POKEA,B:NEXT:DEFUSR0=32512
30 X=USR0(1234),5678:PRINT"HELLO"
40 PRINTPEEK(&HF4)*256+PEEK(&HF5)
50 PRINTPEEK(&HF6)*256+PEEK(&HF7)
-spc
More information about the Coco
mailing list