Thanks for the answer. I used to use GOSUBs for pretty much everything but now I keep it for oft visited chunks and use GOTOs to navigate a more linear path. I think I tripped myself up once by going down to many .SUBs and lost the way home![]()
Thanks for the answer. I used to use GOSUBs for pretty much everything but now I keep it for oft visited chunks and use GOTOs to navigate a more linear path. I think I tripped myself up once by going down to many .SUBs and lost the way home![]()
18Fs using PBP have a 27 level stack. That is a lot of GOSUBs.
Whatever you do - keep track of your GOSUBs. Don't ever GOSUB to a routine and then use
GOTO to get "back".
Every time you GOSUB, you put an address on the stack. Every time you RETURN, you pop that address and resume execution there. If you push addresses there without pop-ing them off, you will eventually get a stack overflow which causes a processor reset.
Charles Linquist
If you have functions or routines used often in your program, then gosub is a must.
It helps keep the program structured and by carefully placing the subroutine in a complete page of pogram memory, the overall program can be reduced in size very much.
It would be nice to see local variables sometime in the next updates of PBP,but even without this, GOSUBs are my preference.
Other languages like C "push" the programmer to use functions or subroutines.
Ioannis
Bookmarks