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
 Dieter Senior Member Posts: 2,397 Joined: Dec 2013
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:
... STO 4 RCL 0 X=0? GTO nn  -----+ R↓           | RCL 3        | x            | ENTER        | R↓      <----+ STO+2

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 02  CLX 03  STO 1 04  STO 2 05  3 06  R/S 07  STO 3 08  4 09  R/S 10  RCL 0 11  X=0? 12  GTO 17 13  R↓ 14  RCL 3 15  x 16  ENTER 17  R↓ 18  STO+2 19  RCL 3 20  STO+1 21  5 22  R/S 23  X≠0? 24  GTO 07 25  RCL 1 26  R/S 27  RCL 2 28  R/S 29  RCL 2 30  RCL 1 31  / 32  R/S 33  GTO 21

And finally in the original SR56 program all these obscure EXC-sequences could be avoided like this:

Code:
... 10  STO 11  4 12  CP 13  RCL 14  0 15  x=t? 16  2 17  2 18  RCL 19  3 20  PRD 21  4 22  RCL 23  4 24  SUM 25  2

That's even four steps shorter.

Dieter
 « Next Oldest | Next Newest »

 Messages In This Thread EXC/ x<>Rn for stack efficiency - Matt Agajanian - 06-11-2017, 08:58 PM RE: EXC/ x<>Rn for stack efficiency - Dieter - 06-11-2017, 10:07 PM RE: EXC/ x<>Rn for stack efficiency - Matt Agajanian - 06-11-2017, 10:23 PM RE: EXC/ x<>Rn for stack efficiency - Paul Dale - 06-11-2017, 11:08 PM RE: EXC/ x<>Rn for stack efficiency - Matt Agajanian - 06-11-2017, 11:57 PM RE: EXC/ x<>Rn for stack efficiency - Dieter - 06-12-2017, 12:08 PM RE: EXC/ x<>Rn for stack efficiency - Matt Agajanian - 06-12-2017, 07:48 PM RE: EXC/ x<>Rn for stack efficiency - Dieter - 06-12-2017, 08:51 PM RE: EXC/ x<>Rn for stack efficiency - Matt Agajanian - 06-11-2017, 11:54 PM RE: EXC/ x<>Rn for stack efficiency - Matt Agajanian - 06-12-2017, 03:50 PM RE: EXC/ x<>Rn for stack efficiency - Matt Agajanian - 06-13-2017, 07:26 PM RE: EXC/ x<>Rn for stack efficiency - Matt Agajanian - 06-14-2017, 10:19 AM RE: EXC/ x<>Rn for stack efficiency - Dieter - 06-14-2017, 06:39 PM RE: EXC/ x<>Rn for stack efficiency - Matt Agajanian - 06-14-2017, 07:38 PM RE: EXC/ x<>Rn for stack efficiency - Dieter - 06-14-2017, 08:46 PM RE: EXC/ x<>Rn for stack efficiency - Matt Agajanian - 06-14-2017, 09:40 PM RE: EXC/ x<>Rn for stack efficiency - Paul Dale - 06-14-2017, 10:36 AM RE: EXC/ x<>Rn for stack efficiency - Matt Agajanian - 06-14-2017, 03:04 PM RE: EXC/ x<>Rn for stack efficiency - Dieter - 06-14-2017, 06:23 PM RE: EXC/ x<>Rn for stack efficiency - Matt Agajanian - 06-14-2017, 11:31 PM RE: EXC/ x<>Rn for stack efficiency - Dieter - 06-15-2017, 09:01 AM RE: EXC/ x<>Rn for stack efficiency - Paul Dale - 06-15-2017, 09:09 AM RE: EXC/ x<>Rn for stack efficiency - SlideRule - 06-16-2017, 12:39 PM RE: EXC/ x<>Rn for stack efficiency - Dieter - 06-16-2017, 06:59 PM RE: EXC/ x<>Rn for stack efficiency - rprosperi - 06-16-2017, 09:12 PM RE: EXC/ x<>Rn for stack efficiency - Dieter - 06-17-2017, 07:17 PM RE: EXC/ x<>Rn for stack efficiency - Dieter - 06-15-2017 11:05 AM RE: EXC/ x<>Rn for stack efficiency - Paul Dale - 06-15-2017, 10:29 AM RE: EXC/ x<>Rn for stack efficiency - Matt Agajanian - 06-16-2017, 06:32 PM RE: EXC/ x<>Rn for stack efficiency - Paul Dale - 06-17-2017, 06:03 AM RE: EXC/ x<>Rn for stack efficiency - Dieter - 06-17-2017, 11:46 AM RE: EXC/ x<>Rn for stack efficiency - Dieter - 06-17-2017, 12:49 PM RE: EXC/ x<>Rn for stack efficiency - Paul Dale - 06-18-2017, 12:59 AM RE: EXC/ x<>Rn for stack efficiency - Matt Agajanian - 06-15-2017, 05:28 PM RE: EXC/ x<>Rn for stack efficiency - Matt Agajanian - 06-16-2017, 02:57 AM RE: EXC/ x<>Rn for stack efficiency - Matt Agajanian - 06-16-2017, 05:25 PM RE: EXC/ x<>Rn for stack efficiency - Matt Agajanian - 06-17-2017, 05:38 PM RE: EXC/ x<>Rn for stack efficiency - Dieter - 06-17-2017, 06:10 PM RE: EXC/ x<>Rn for stack efficiency - Matt Agajanian - 06-17-2017, 08:00 PM RE: EXC/ x<>Rn for stack efficiency - GrampaDave - 06-19-2017, 05:44 PM RE: EXC/ x<>Rn for stack efficiency - Matt Agajanian - 06-27-2017, 09:42 PM RE: EXC/ x<>Rn for stack efficiency - Thomas Okken - 06-28-2017, 12:42 AM RE: EXC/ x<>Rn for stack efficiency - Matt Agajanian - 06-28-2017, 01:37 AM RE: EXC/ x<>Rn for stack efficiency - Thomas Klemm - 07-20-2022, 07:03 PM

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