Here's my latest concoction.
I decided to focus solely on Save & Restore functionality, but without use of the STACK matrix.
So, the following programs Save and Restore the Mode (well, display mode FIX/SCI/ENG/ALL, DEGRAD, Thousands separator, comma or decimal point, Rectangular/Polar and Complex or Real results).
Both programs leave the stack intact, whatever it may contain (matrices, complex numbers, ..). Both use the variable 'Mode' and one or two temporary variables that are deleted on exit. Restoring the mode leaves the 'Mode' variable intact.
BTW my previous programs contained a bug, restoring SCI and ENG were swapped. Corrected (and improved) here.
Code: Select all
00 { 200-Byte Prgm }
01▸LBL "RSTMode"
02 STO ".x"
03 R↓
04 STO ".y"
05 CLX
06 RCL "Mode"
07 5
08 DEG
09 BIT?
10 GRAD
11 DSE ST X
12 BIT?
13 RAD
14 DSE ST X
15 RECT
16 BIT?
17 POLAR
18 DSE ST X
19 CPXRES
20 BIT?
21 REALRES
22 DSE ST X
23 CF 28
24 BIT?
25 SF 28
26 CLX
27 CF 29
28 BIT?
29 SF 29
30 CLX
31 64
32 STO÷ ST Y
33 X<> ST L
34 X<>Y
35 IP
36 ABS
37 CLX
38 4
39 STO÷ ST L
40 X<> ST L
41 FP
42 STO+ ST X
43 STO+ ST X
44 SCI IND ST L
45 DSE ST X
46 FIX IND ST L
47 X=0?
48 ENG IND ST L
49 DSE ST X
50 ALL
51 R↓
52 STO ST L
53 GTO 00
54▸LBL "SAVMode"
55 STO ".x"
56 CLX
57 36.043
58 R↓
59 STO ".y"
60 CLX
61 XEQ 04
62 73.074
63 R↓
64 XEQ 04
65 28.029
66 R↓
67 XEQ 04
68 STO "Mode"
69▸LBL 00
70 X<> ".y"
71 RCL ".x"
72 CLV ".x"
73 CLV ".y"
74 RTN
75▸LBL 04
76 STO+ ST X
77 FS? IND ST T
78 ISG ST X
79▸LBL 04
80 ISG ST T
81 GTO 04
82 END
Cheers, Werner