Post Reply 
EXC/ x<>Rn for stack efficiency
06-12-2017, 12:08 PM (This post was last modified: 06-12-2017 12:17 PM by Dieter.)
Post: #7
RE: EXC/ x<>Rn for stack efficiency
(06-11-2017 11:57 PM)Matt Agajanian Wrote:  save program steps or clutter up my program with save/restore stack code.

When translating a program from one calculator to another it's usually not a good idea to mirror the original code 1:1 on the other device. IMHO the best approach is trying to understand how the original code works and translate this idea (!!, not the code) into code for the other machine.

So if you have, say, TI-programs with Exc-commands you should not try to simulate this Exc-instruction in your HP code. Instead see how the program works and do it in RPN with the special features of the target calculator – which may be even shorter and more effective.

Often in RPN things can be done quite relaxed. Here is an example:

Code:
TI-58/59    HP-25/33
---------------------
 (           RCL 1
 RCL         RCL 2
 01          +
 +           RCL 3
 RCL         x<>y
 02          STO 3
 )           *
 *
 EXC
 03
 =

No need to worry about stack registers or how to emulate that Exc-instruction.

Another example – swap the contents of R1 and R2:

Code:
TI-58/59     HP-25/33
---------------------
 RCL          RCL 2
 01           RCL 1
 EXC          STO 2
 02           x<>y
 STO          STO 1
 01

Again, there's no need to save the stack or emulate the Exc-instruction.

Dieter
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: EXC/ x<>Rn for stack efficiency - Dieter - 06-12-2017 12:08 PM



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