[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Introducing: Magic Gosub



> Ivan X <ivan@ivanx.com> writes:
> > 
> > The major thing Magic Gosub does differently is exploit the native
> 
> > behavior of  the GOSUB command (it uses line 0 by default)
> 
On Wednesday, August 15, 2012 1:01:46 AM UTC-4, Jerry wrote:
> 
> Hey, that is a cool find.  I didn't know GOSUB had a default and one
> 
> could leave the parameter blank.  But sure enough, it works!
> 

Yes, I was pretty excited when I figured that out. It works with GOTO as well; I just can't make use of it in Magic Gosub because once it successfully makes it to line 0, GOTO leaves no trace of what line sent it there, so there's no way to see what label was specified. But with GOSUB, it needs to RETURN, so it's possible to get info about the line that contained the GOSUB.

In fact, it even works in immediate mode, like so:

0 PRINT "HI"

]GOTO

output:
HI

Weird, right? I took a look at the Applesoft ROM and saw that it does indeed set line 0 as a target for GOTO/GOSUB before anything happens; then it tries to parse the target line number and if it can, it changes it. If not, off to line 0 it goes.