Re: USRx() and adding more parameters?

Sean Conner via Coco <coco-uNHYcr1XS/wmlAP/[email protected]>
Newsgroups gmane.comp.hardware.tandy.coco
Message-ID <[email protected]>
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

-- 
Coco mailing list
[email protected]
https://pairlist5.pair.net/mailman/listinfo/coco
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.