05-17-2017, 05:16 AM
These programs save and recall the stack on the 35s. This has already been tackled by MarkHaysHarris777, but I think I have made a few improvements. These programs store the stack relative to the current value of I, rather than at a fixed location. This allows the user to save several stacks and recall them in sequence. In addition, no variables are clobbered except I and J. A downside to this approach is that it is non-trivial to exchange two stacks, as this is a fundamentally stack-based approach (with regard to indirect variable usage).
Simply execute LBL S to save the current stack (non-destructive), and LBL R to recall it. The user can even pop individual values off the stack by entering 0 [DSE] I [x<>] (I), though they must be careful to ensure I is a multiple of 4 before restoring another stack.
Simply execute LBL S to save the current stack (non-destructive), and LBL R to recall it. The user can even pop individual values off the stack by entering 0 [DSE] I [x<>] (I), though they must be careful to ensure I is a multiple of 4 before restoring another stack.
Code:
S001 LBL S
S002 STO(I)
S003 STO J Store X in J so we can recall it easily later
S004 R|
S005 x<>I
S006 IP Make sure to remove any previous loop counter
S007 3 Upper loop bounds are inclusive
S008 +
S009 1.001
S010 *
S011 2 Don't store in X's slot again
S012 -
S013 x<>I
S014 STO(I)
S015 R|
S016 ISG I
S017 GTO S014
S018 CLx Restore X to the stack
S019 RCL J
S020 RTN
CK=8EB4
LN=67
Code:
R001 LBL R
R002 RCL I
R003 IP
R004 4
R005 -
R006 1.001
R007 *
R008 3
R009 +
R010 STO I
R011 0
R012 x<>(I)
R013 DSE I
R014 GTO R011
R015 0 Lower loop bounds are exclusive (sigh)
R016 x<>(I)
R017 RTN
CK=BC4E
LN=60