Post Reply 
EXC/ x<>Rn for stack efficiency
06-14-2017, 07:38 PM
Post: #17
RE: EXC/ x<>Rn for stack efficiency
(06-14-2017 06:39 PM)Dieter Wrote:  
(06-14-2017 10:19 AM)Matt Agajanian Wrote:  I've been trying to figure this out and I'm getting confused and forgetting the stack at the exchange steps. So, please help me. Maybe you've already responded with the answer. But, the ends I'm trying to accomplish removes the former value from the stack and leaves the exchanged value on the stack with Y, Z, and (if possible) the T registers intact.

This – leaving the whole stack or most of it unchanged – usually is not required at all. At least after some slight recoding usually you do not have to hold three intermediate values on the stack.

Example: Calculate R1 + R2*R3^R4 while pushing pi into R4

Code:
AOS      RPN
--------------
RCL      RCL 3
01       RCL 4
+        Pi
RCL      STO 4
02       R↓
*        y^x
RCL      RCL 2
03       *
y^x      RCL 1
Pi       +
EXC
04
=

RPN is different. You can do most calculations without having to keep track of lots of intermediate results – you always work with just two numbers. ;-)

(06-14-2017 10:19 AM)Matt Agajanian Wrote:  All I'm trying to do is leave the exchanged value in the X register without the forner register content in the Y register.

?!? After the exchange the former register content is in X of course.
That's what the EXC command does. As well as the four-step-code in my first post. Y and Z are preserved.

Dieter

Dieter, again, sorry for my mixup. Yes, your methods accomplish what I need. For some reason, a mental block on my part is gettiing in the way of imagining/picturing the stack. Perhaps, I should create an Excel or Word six-row table to help me physically visualise these.

Thanks
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-14-2017 07:38 PM



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