Post Reply 
[WP 34s] emulator ENTER key behaviour
05-28-2015, 08:07 PM
Post: #12
RE: 34s emulator ENTER key problem?
(05-28-2015 07:34 PM)Marcio Wrote:  
(05-28-2015 06:59 PM)rprosperi Wrote:  Such a discussion would (and has, more than once) fill thousands of messages. Search both the current and old Museum archives for topics such as "RPN vs RPL" or look for phrases like "classic RPN". There are many advantages (and limitations) to both styles, but comparing them is really much more of a religious dicussion than a technical one. And the good thing about that is, whichever one you believe is best for you, is best for you.

Well, yes, I have browsed the forums and read lots of threads about the differences between RPN and RPL. My question however was more like centered around why the ENTER key will duplicate entries therefore taking 2 registers instead of 1 only.

Thanks.

Marcio

Simplest way to think of it:

In traditional RPN, whatever you're typing is going directly into the x register as you type it. There's no "command line" that has to be processed. So pressing + terminates entry, and operates on that value and y. Pressing Enter means "copy x to y". Most operations enable auto stack lift, so when you start typing something else, there's an implicit Enter first, and your new entry immediately overwrites x. A few functions like Enter and CLX disable stack lift, so your next entry overwrites x without pushing it to y.

In RPL (28, 48, etc.), there's a command line that's separate from the stack. Whatever you're typing isn't part of the stack yet. Pressing Enter means "parse and process the command line". If there happen to be numbers or other objects in there, they'll be pushed to level 1, and everything else lifted one level. You can enter a whole series of numbers and commands separated by spaces, and pressing Enter will process them all in one go. Try this: enter "3 5 " (with a space at the end, but without quotes), then turn on alpha mode and type "+" so you have "3 5 +". Press Enter, and you'll get 8.

It's a very subtle distinction, but it can have significant implications. Compare two program snippets with crude stack diagrams for taking a value from x/level 1, and calculating x / 2, but leaving the original x/level 1 value in y/level 2.

RPN: (Stack lift disabled after ENTER)
ENTER x:12 y:12
ENTER x:12 y:12 z:12
2 x:2 y:12 z:12
/ x:6 y:12

RPL: (No concept of disabling stack lift, everything pushes the stack)
ENTER (acting as DUP with no command line active) 1:12 y:12
2 1:2 2:12 3:12
/ 1:6 2:12

With RPN, it's very easy to forget that second Enter and accidentally clobber the original value you were trying to keep. I just made this mistake a few minutes ago fiddling around with the Collatz conjecture on my 41. Though a trick you can do with the 41 and 42S is to use "RCL X" instead of Enter, effectively recalling/copying the value in x, but RCL enables stack lift as opposed to Enter disabling it. So the above program could be written "RCL X, 2, /" on a 41.
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: 34s emulator ENTER key problem? - Dave Britten - 05-28-2015 08:07 PM



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