Post Reply 
HP 41 - branching to local label and return stack - FINAL RESULTS AND PROGRAMS
05-20-2019, 06:43 PM
Post: #11
RE: HP 41 - branching to local label and return stack
Here the full routine of softmenu.
The caller programm, or main program, exists for some topic - in my case, there will be a programm for transformers, one for ac motors, one for dc motors, one for auto-transformers, and so on.
Each topic has many functions (equations) for solving: B = u.A; A = N1/N2, etc...
So, each main programa has one menu for these equations "B:A:FMM:..."
Each equation or function has many variables: "B: u: A" for example. As registers for holding them are fixed in softmenu and I would try do not overwrite ones by anothers, I give the user the chance to use from A...E or a...e in first menu and same in a second menu.

It may seems difficult to use, but actually it is very easy.
Main program:
"equations menu"
call SFTMEN
LBL 01
first equation implementation:
"equation name" --> X
"1st variables menu"
call SFT1
"2nd variables menu" //or CLA if there is no 2nd menu
call "SFT2"
tests on variables before the use o SOLVE
everything ok? calls SFT3 (it will call SOLVE)
lbl "Equation"
your equation for SOLVE (Advantage module)
RTN -- end of first equation
second equation ...
third equation ...



1 LBL "SFTMEN" //expects in ALPHA: "menu of functions"
2 CF 01 //clear solution for variable
3 PROMPT // shows functions menu
4 0 //R/S or J return to main program
5 RTN
6 LBL A //BIG PROBLEM - kills return stack
7 1
8 STO 42 //indirect register for numeric label of function
9 RTN
10 LBL B
11 2
12 STO 42
13 RTN
14 LBL C
15 3
16 STO 42
17 RTN
18 LBL D
19 4
20 STO 42
21 RTN
22 LBL E //up to 5 functions by main programm
23 5
24 STO 42
25 RTN
26 LBL "SFT1" //expects in X: name of selected function; ALPHA: variables menu of it
27 CF 05 //no 2nd menu at now
28 STO 43 //name of function (will be used by SOLVE)
29 ASTO 47 // registers 47 and 48 will keep the functions menu
30 ASHF
31 ASTO 48
32 RTN
33 LBL "SFT2" // 2nd variables of menu (receives ALPHA: nothing - if none)
34 ALENG
35 X=0?
36 GTO 15 //no 2nd variables menu
37 SF 05 //there is 2nd variables menu
38 ASTO 49 //Registers 49 and 50 will keep the vars menu (up 12 chars)
39 ASHF
40 ASTO 50
41 LBL 15 //shows the 1st variables menu
42 CLA
43 ARCL 47 first 6 chars
44 ARCL 48 adds the 6 left most chars
45 FS? 05 //is there a second variable menu?
46 XEQ 05 //will add a > character to menu
47 CF 22 //for testing numeric data input
48 PROMPT //shows 1st variables menu
49 FS?C 01 //R/S: if activated solution ...
50 RTN // returns to main programm: will test variables for problems
51 GTO 04 // else, calls 2ns variable menu
52 LBL 05 //just add the > char to menu, indicating there is a second menu (R/S goes to it)
53 41
54 XTOA
55 RTN
56 LBL A //first menu of variables
57 1 //number of register that will hold data (variable)
58 GTO 01
59 LBL B
60 2
61 GTO 01
62 LBL C
63 3
64 GTO 01
65 LBL D
66 4
67 GTO 01
68 LBL E
69 5
70 GTO 01
71 LBL a first shift menu
72 11 //number of register that will hold data (variable)
73 GTO 01
74 LBL b
75 12
76 GTO 01
77 LBL c
78 13
79 GTO 01
80 LBL d
81 14
82 GTO 01
83 LBL e
84 15
85 GTO 01
86 LBL 01 //Receives the register that will hold data
87 STO 44 //stores indirect register that will hold data
88 FS? 22 // was something keyed in?
89 GTO 03 // stores data
90 RCL IND 44 //else, recovers already stored data
91 PSE
92 SF 01 // turns on variable solution
93 RCL 43 //get the function's name to X
94 GTO 15 //returns to 1st variables menu
95 LBL 04 // shows 2ns variables menu
96 FC? 05
97 GTO 15 // has no 2nd variables menu, returns to first one
98 CLA
99 40 // ads a < char indicating there is a previous var menu
100 XTOA
101 ARCL 49
102 ARCL 50
103 CF 22 //will test numeric data input
104 PROMPT //Shows 2nd variables menu
105 FS?C 01 //f R/S and if solution activated ...
106 RTN // returns to main programm with data in registers
107 GTO 15 // goes to begin
108 LBL J //Return to main programm with 0
109 0
110 RTN Volta programa chamador
111 LBL A //second menu for variables: A-E, a-e
112 6
113 GTO 01
114 LBL B
115 7
116 GTO 01
117 LBL C
118 8
119 GTO 01
120 LBL D
121 9
122 GTO 01
123 LBL E
124 10
125 GTO 01
126 LBL a
127 16
128 GTO 01
129 LBL b
130 17
131 GTO 01
132 LBL c
133 18
134 GTO 01
135 LBL d
136 19
137 GTO 01
138 LBL e
139 20
140 GTO 01
141 LBL 03 //stores the input data
142 X<>Y //gets the input data
143 STO IND 44 // indirect register to variable register
144 SF 01 // turns on solution for variable in reg 44
145 RCL 43 // recall the function name to X
146 GTO 15 // returns to 1st menu of variables
147 LBL "SFT3" // will execute SOLVE
148 CLA
149 ARCL 43 // recover the function name to solve
150 SOLVE //runs next step if result found
151 GTO 02
152 "NO SOL."
153 AVIEW
154 RTN
155 LBL "SFT4" //ALPHA: message of error found in variables
156 AVIEW
157 BEEP
158 RTN
159 LBL 02 //shows result found
160 RCL IND 44
161 ABS //I need all solve results positive
162 STO IND 44
163 BEEP
164 PSE
165 END

ARTUR MARIO JUNIOR
BRAZIL
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: HP 41 - branching to local label and return stack - Artur - Brasil - 05-20-2019 06:43 PM



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