If you use them often... then maybe one or two need a real register, but I'd still be weary of doing that. Use find_global and its friends.
Eureka!
Oh, find_global/set_global, where have you been all my life?
Thank you for pointing out the obvious. :)
> * Examples of things that are really global in a BASIC machine: current > random number seed, cursor column position, console current character > attributes, last value picked up from a READ/DATA combo (line & position), > structure definition table, and a GOSUB call-stack lookback specifically > for "RETURN x".
Yeah, most of those seem like they can be stored in the global name table instead of a register. Load them in when you need them. Except the latter, which seems like you should be using the call stack, if I'm not misunderstanding.
I thought so too, but no sane language I know would allow this kind of nonsense:
10 GOSUB 100 20 PRINT "I get printed too." 50 REM And the stack is empty at this point. 90 END 100 GOSUB 200 110 PRINT "Nope, won't see me" 199 RETURN 200 GOSUB 1000 210 PRINT "Nope, won't see me either." 299 RETURN 1000 PRINT "You *will* see me" 1010 RETURN 10
I think in PASM this would be something like
bsr USERLABEL_100
eq RETURNTO, "10", CONT_10
eq RETURNTO, "", CONT_10
ret
CONT_10:
print "I get printed too"
end
USERLABEL_100:
bsr USERLABEL_200
eq RETURNTO, "100", CONT_100
eq RETURNTO, "", CONT_100
ret
CONT_100:
print "Nope, won't see me"
set RETURNTO, ""
ret
USERLABEL_200:
bsr USERLABEL_1000
eq RETURNTO, "200", CONT_200
eq RETURNTO, "", CONT_200
ret
CONT_200:
print "Nope, won't see me either."
set RETURNTO, ""
ret
USERLABEL_1000:
print "You *will* see me"
set RETURNTO, "10"
retOf course, this allows for jumping into this GOSUB/RETURN nonsense anywhere in the mix and still a RETURN x takes you back to the right place. Oh and worse? RETURN x can take a variable in some cases. (Literally, x=10, return x)
Without RETURN x, just plain old GOSUB/RETURN I could let PIR/PASM handle all by itself with no supervision.
