Post Reply 
EXC/ x<>Rn for stack efficiency
06-12-2017, 07:48 PM
Post: #9
RE: EXC/ x<>Rn for stack efficiency
(06-12-2017 12:08 PM)Dieter Wrote:  
(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:

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

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

Another example – swap the contents of R1 and R2:

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

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


Dieter, on second look I'm confused. This actually loses several stack register value when an exchange occurs in the midst of a calculation. At the end of a calculation, an exchange like this is acceptable. But, if you have seen several SR-56 Application Library and TI-58/59 Specialty Packette/Solid State Module programs, exchange operations occasionally are within a calculation. So, how do I code for those instances?

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 - Matt Agajanian - 06-12-2017 07:48 PM

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