EXC/ x<>Rn for stack efficiency
|
06-15-2017, 11:05 AM
(This post was last modified: 06-17-2017 07:23 PM by Dieter.)
Post: #24
|
|||
|
|||
RE: EXC/ x<>Rn for stack efficiency
(06-14-2017 11:31 PM)Matt Agajanian Wrote: General Aircraft Weight and Balance A strange program – I'm not sure at all what it does. But there are lots of EXC instructions between line 10 and 27. There are even consecutive EXC commands that neutralize each other. #-) If you take a closer look at this you will realize that the sequence with all these obscured EXC commands simply does this: Store an entry in R4, then check if R0 is zero. If yes, add the previous entry to R2, otherwise add R3*entry to R2. At the end R0 is left unchanged. Of course this can be coded much more effectively and simpler: Code: ... That's shorter and less obscure. BTW, the STO 4 is not required, neither in the SR56 program nor in the translation above: R4 is not used elsewhere in the program. Edit: the instructions for this program say that the previous entry may be recalled by RCL 4, e.g. for correcting the last entry, so this is the reason why the input is stored in R4 although this register is not recalled in the program itself. While I am still not sure what the program is supposed to do (what are these 3, 4 and 5 prompts for?) I think it can be done in 30 steps on an HP25 or 33. Or three more if the program initially resets R1 and R2 to zero, which I think it should do. Here is an experimental, completely untested first attempt at this: Code: 01 STO 0 And finally in the original SR56 program all these obscure EXC-sequences could be avoided like this: Code: ... That's even four steps shorter. Dieter |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)