Question about GOSUB/RETURN in multi page program on BS2e
Jonmar
Posts: 9
Greetings all,
If I have a FOR/NEXT loop running and GOSUB out to do some thing that has a jump, via a RUN command to another program page;
when my program comes back to the originating page,
will a RETURN instruction Return to the next instruction line after the original GOSUB?
Thanks in advance,
Jonmar
If I have a FOR/NEXT loop running and GOSUB out to do some thing that has a jump, via a RUN command to another program page;
when my program comes back to the originating page,
will a RETURN instruction Return to the next instruction line after the original GOSUB?
Thanks in advance,
Jonmar
Comments
hope this helps
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Diamonddredges.com
Gaudware.net84.net
When you do a RUN any return addresses are lost. The only thing that can be passed to another bank is the variables (and the Scratchpad RAM).
Post Edited (Mike Green) : 9/25/2008 7:34:55 PM GMT
If you want to return to a certain point after jumping to another slot with RUN, you will have to do so from the MAIN program level. Your own PBASIC program will have to manage the pointer of where to jump to in the other slot and where to jump to upon return. And if it is part of a looping structure, you have to use DO:LOOP and manage your own loop counter, not FOR:NEXT.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
So, I do not know if there is a problem yet with the GOSUB's return.
Based on the feedback so far, I am redoing the code to implement my own Save the world and restore it using the SPram space.
Thanks to everyone who responded to my question.
Jonmar
P. S. I will let everyone know how my efforts turn out when I finish the program. Hopefully next week.
www.parallax.com/dl/docs/cols/nv/vol3/col/nv87.pdf
and I have a writeup at www.emesys.com/BS2SX.htm#Crossbank.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com