For an interesting application of
LSTO to realise a temporary partial preservation of the stack before any intermediate calculation see my working example of nov 12 at
viewtopic.php?f=19&t=271#p12423.
For the purpose of calculating some new quantity (ending in the X register) derived from other physical constants (by internal calls in the same program), I had to developed simple Push (“
PshST”) and Pop (“
PopST”) subroutines to reinstate the unperturbed remaining stack (Y, Z, T and LastX registers) through the use of temporary
local variables (“
Ys”, “
Zs”, “
Ts”, “
Ls” and “
LBLxx”) where this last variable contains momentarily the numeric label
xx referring precisely to a given target subroutine “
LBLxx” where you can freely perform whatever complicated calculations you need, providing that it ends by a call to “
PopST”. As it is explained, the calling order is important to respect the consecutive RTN order precedencies which allows the proper timely creation and disposal of these
local variables. And what the example shows clearly is that within the very same program you can repeat this at different points without any risk of interference (side effect or memory corruption). You simply need to invoke “
PshST” passing a different numeric label
xx to address another subroutine invoked by the indirect call XEQ IND “
LBLxx” and where a different calculation is performed also terminated by the same call to “
PopST”. Note that in the actual implementation, there was no need or intent to preserve the content of the original T register (since it is pushed out of the stack by the introduction of the new X value), but that would be easy to include if needed eventually.
As said before, let us know about your initiatives on this subject of dynamic memory (and thanks again to
Mr. Thomas Okken for the implementation of
local variables)!
ADDED NOTE (Nov 17, 2019): for an interesting and more thorough implementation (using nested subroutines), look at my last version of this program (
Const0) providing physical constants (including recent exact definitions and related calculations in compliance with the latest SI revisions of May 20 2019) with the new display (through alpha register) of the corresponding physical units, together with a brief description (an added
NOTE describes also the approach):
viewtopic.php?f=19&t=271#p12446.