Post Reply 
Free42 LSTO REGS
09-28-2019, 03:19 AM
Post: #5
RE: Free42 LSTO REGS
To elaborate a bit: every local variable is associated with a level of the RTN stack. LSTO creates variables on the current level, and when that level is popped, the associated variables are deleted. And, any action that clears the entire RTN stack, like GTO, XEQ, or RTN in RUN mode, clears all local variables.

There is one quirk to this: LSTO can also create variables when the RTN stack is already empty. It has to be able to do this, in order to work in a subroutine that is invoked from the keyboard. Say you do XEQ "FOO" from the keyboard with this in program memory:

Code:
01 LBL "FOO"
02 LSTO "X"
03 R↓
04 LSTO "Y"
[...]

When the LSTO instructions are performed, there is nothing on the RTN stack, unlike when the XEQ "FOO" is done from a program, but of course you'd want LSTO to work even in this scenario.

When a program performs RTN while the RTN stack is empty, this causes the empty-stack locals (referred to as "level 0" in the source code, the RTN stack "level" being the number of pending returns) to be deleted, so when the program "FOO" above ends with a RTN, its locals disappear, even though they were never associated with an actual RTN. And this same mechanism can be used in RUN mode.
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Free42 LSTO REGS - Epidiah - 09-25-2019, 03:52 PM
RE: Free42 LSTO REGS - David Hayden - 09-26-2019, 05:50 PM
RE: Free42 LSTO REGS - Guenter Schink - 09-26-2019, 08:10 PM
RE: Free42 LSTO REGS - Thomas Okken - 09-28-2019, 02:53 AM
RE: Free42 LSTO REGS - Thomas Okken - 09-28-2019 03:19 AM
RE: Free42 LSTO REGS - Namir - 10-04-2019, 12:34 PM
RE: Free42 LSTO REGS - Paul Dale - 10-05-2019, 08:46 AM
RE: Free42 LSTO REGS - SammysHP - 10-21-2019, 09:31 AM
RE: Free42 LSTO REGS - Epidiah - 10-21-2019, 03:07 PM
RE: Free42 LSTO REGS - Thomas Okken - 10-23-2019, 12:01 PM
RE: Free42 LSTO REGS - Epidiah - 10-23-2019, 02:22 PM
RE: Free42 LSTO REGS - Epidiah - 10-25-2019, 01:50 AM
RE: Free42 LSTO REGS - SammysHP - 10-25-2019, 07:17 PM
RE: Free42 LSTO REGS - Epidiah - 10-26-2019, 02:52 AM
RE: Free42 LSTO REGS - rprosperi - 10-23-2019, 01:38 PM
RE: Free42 LSTO REGS - Thomas Okken - 10-23-2019, 11:51 PM
RE: Free42 LSTO REGS - Thomas Okken - 10-24-2019, 11:37 AM
RE: Free42 LSTO REGS - Paul Dale - 10-24-2019, 12:26 PM
RE: Free42 LSTO REGS - Epidiah - 10-24-2019, 12:57 PM
RE: Free42 LSTO REGS - Werner - 10-25-2019, 06:21 AM
RE: Free42 LSTO REGS - Epidiah - 10-25-2019, 02:02 PM



User(s) browsing this thread: 4 Guest(s)