Post Reply 
Clear Stack (CLST, CLSTK) and LastX
03-12-2015, 01:55 PM
Post: #1
Clear Stack (CLST, CLSTK) and LastX
When I got my first HP with CLST command, a 41C, I wondered why this command did clear X, Y, Z and T but not LastX. That's not much of a problem since an additional [+] or [×] will do this, but nevertheless it did not seem consistent to me. On the other hand this behaviour was quite handy as it allowed to return a result in an otherwise empty stack by means of a simple ABS CLST LastX sequence.

I now discovered an interesting variation as I tried the latter on my 35s. I was quite surprised to see that instead of the previously computed result a plain zero was returned. As I single-stepped through the program I found that CLSTK obviously also cleared LastX as well. I then tried the same in run mode, i.e. within a normal calculation, and I was surprised even more to find that in this case LastX was preserved.

Code:
001 π
002 5
003 ×
004 CLSTK
005 LASTx
006 RTN

Running the program yields a completely empty stack (including LastX), while doing the same calculation manually returns 5 that is still in LastX.

In other words: within a program, the 35s seems to clear LastX, while in run mode LastX is preserved (as in classic HPs). I could not find this behaviour described anywhere, so I wonder if this is a known "feature". Do you know of any other calculator where CLST / CLSTK behaves this way?

Dieter
Find all posts by this user
Quote this message in a reply
03-12-2015, 02:19 PM (This post was last modified: 03-12-2015 02:52 PM by PANAMATIK.)
Post: #2
RE: Clear Stack (CLST, CLSTK) and LastX
LastX is not part of the Stack. The Clear STK or CLST instruction of any RPN calculator should therefore never affect the LastX register.

HP-25, HP-33E HP-33C Clear STK keystroke doesn't affect LastX either in RUN or in PRGM Mode. Also HP42S as a reference is consistent and doesn't clear LastX in either mode. Other programmables of this series HP29C, HP34C and HP32S, 32Sii don't have a Clear STK or CLST instruction.

IMO this is an inconsistency, which should be considered as a bug and should be included to the HP-35S bug list. The behaviour of any keystroke of a "keystroke programmable" calculator should be always the same in RUN and PRGM mode. The 35S is doing wrong in PRGM mode.

Bernhard

That's one small step for a man - one giant leap for mankind.
Find all posts by this user
Quote this message in a reply
03-12-2015, 03:26 PM
Post: #3
RE: Clear Stack (CLST, CLSTK) and LastX
Great analysis there.

You're very convincing and I'm convinced.

Dieter discovered a bug, and should be in the pantheon of heroes now.


Wink

2speed HP41CX,int2XMEM+ZEN, HPIL+DEVEL, HPIL+X/IO, I/R, 82143, 82163, 82162 -25,35,45,55,65,67,70,80
Find all posts by this user
Quote this message in a reply
03-12-2015, 07:29 PM
Post: #4
RE: Clear Stack (CLST, CLSTK) and LastX
(03-12-2015 02:19 PM)PANAMATIK Wrote:  IMO this is an inconsistency, which should be considered as a bug and should be included to the HP-35S bug list. The behaviour of any keystroke of a "keystroke programmable" calculator should be always the same in RUN and PRGM mode. The 35S is doing wrong in PRGM mode.

Not necessarily. Some commands are intended for interactive use and consideration; LASTX is one of those. The inconsistency is not whether the 35s clears LASTX in program mode, the inconsistency (quirk) is that it 'remembers' a LASTX in the first place, in program mode. LASTX is intended for interactive error correction by being able to recover the X register that existed 'before' the last operation 'destroyed' it. This is not necessary, nor desirable, in program mode. If there is to be a LASTX all at, for program mode, it should be the LASTX 'before' the program ran-- not the LASTX of the last operation within the program!

PS This is the 'only' glitch I find -at all- while playing with the WP34s... it needs a real LASTX (I don't really like the L register thing its doing).

Cheers,
marcus

Kind regards,
marcus
Find all posts by this user
Quote this message in a reply
03-12-2015, 07:49 PM
Post: #5
RE: Clear Stack (CLST, CLSTK) and LastX
(03-12-2015 07:29 PM)MarkHaysHarris777 Wrote:  LASTX is intended for interactive error correction [...]
Please see the manual about the use of last_x (35s manual, chapter 2-8):

2. Resuing a number in a calculation

You should be able to do this in a program also. It's just another bug, unfortunately.
Find all posts by this user
Quote this message in a reply
03-12-2015, 08:34 PM
Post: #6
RE: Clear Stack (CLST, CLSTK) and LastX
(03-12-2015 07:29 PM)MarkHaysHarris777 Wrote:  LASTX is intended for interactive error correction by being able to recover the X register that existed 'before' the last operation 'destroyed' it. This is not necessary, nor desirable, in program mode.

What? Not necessary, not even desirable? You must be kidding. I am using LastX in my programs (41C, 35s, 34s) all the time. It's an absolutely useful tool that simplifies many programs – just as it does in manual calculations. Without LastX (or the L-register on the 34s) most of my programs would be significantly longer and more registers for intermediate results were required.

Dieter
Find all posts by this user
Quote this message in a reply
03-12-2015, 09:14 PM
Post: #7
RE: Clear Stack (CLST, CLSTK) and LastX
(03-12-2015 08:34 PM)Dieter Wrote:  
(03-12-2015 07:29 PM)MarkHaysHarris777 Wrote:  LASTX is intended for interactive error correction by being able to recover the X register that existed 'before' the last operation 'destroyed' it. This is not necessary, nor desirable, in program mode.

What? Not necessary, not even desirable? You must be kidding. I am using LastX in my programs (41C, 35s, 34s) all the time.

hi Dieter, use case please. First, its not necessary because it is not a 'necessary' use case... I can use the 35s all day and 'never' touch the LASTX key; similar, I can use the 35s all day and 'never' touch the [ENTER] key either... they are not necessary. Second, give me one use case where LASTX is a mandated case where the computation could not be done using another method as easily or more easily? I do not question you. You probably do make use of LASTX frequently... the question is not whether you use it, or like it, the question is whether LASTX is mandated, required, or necessary? The answer is a resounding, No. Well, in a bizarre way, the WP34s developers have made my case for me... they removed the LASTX key! They left a way to 'do' LASTX by providing the 'last x' in the L register, but that is (maybe for you even) inconvenient because the RCL (or some other method) has to be employed to take advantage of recalling the L reg containing LASTX; I am not sure of the reasons for the change, but there was probably some lively and active discussion about it at the time/

Cheers,
marcus

Kind regards,
marcus
Find all posts by this user
Quote this message in a reply
03-12-2015, 09:23 PM
Post: #8
RE: Clear Stack (CLST, CLSTK) and LastX
(03-12-2015 09:14 PM)MarkHaysHarris777 Wrote:  Well, in a bizarre way, the WP34s developers have made my case for me... they removed the LASTX key! They left a way to 'do' LASTX by providing the 'last x' in the L register, but that is (maybe for you even) inconvenient because the RCL (or some other method) has to be employed to take advantage of recalling the L reg containing LASTX; I am not sure of the reasons for the change, but there was probably some lively and active discussion about it at the time/

The discussion about this wasn't too active or lively. It came down to:

  1. RCL L is exactly the same as LastX in function;
  2. RCL L is the same number of key strokes as shift LastX and
  3. we saved a shifted keyboard position which are a very scarce resource.


I don't regret this change at all.


The 34S doesn't clear last X when doing a clear stack -- although it did for a while. That was a more lively discussion Smile


- Pauli
Find all posts by this user
Quote this message in a reply
03-12-2015, 10:02 PM (This post was last modified: 03-12-2015 10:11 PM by PANAMATIK.)
Post: #9
RE: Clear Stack (CLST, CLSTK) and LastX
(03-12-2015 07:49 PM)Thomas Radtke Wrote:  
(03-12-2015 07:29 PM)MarkHaysHarris777 Wrote:  LASTX is intended for interactive error correction [...]
Please see the manual about the use of last_x (35s manual, chapter 2-8):

2. Resuing a number in a calculation

You should be able to do this in a program also. It's just another bug, unfortunately.

LastX was invented with the second calculator ever the HP-45. Here is what the manual says:

Quote:The last input argument of a calculation is automatically stored in the
Last x register when a function is executed. This feature provides a
handy error correction device (see page 12 for examples)-as well as a
facility for reusing the same argument in multiple calculations-since
it allows recall of the argument by pressing f LastX. The register
is cleared only when the calculator is turned off or when a new argument
replaces (or overwrites) the previous one.

At the very beginning the reusing of the same number was mentioned.

In the HP-55 manual, the second programmable caculator, this is mentioned even before talking about input error correction.

Quote:LAST X
In addition to the four stack registers and the 20 data storage
registers, an additional register, the LAST X register, is provided
for your convenience. The last displayed number before
a calculation is automatically stored here. To recall the last
displayed number, simply press f LastX.

To Avoid Reentering Numbers
The LAST X register is useful in calculations where a number
occurs more than once.

Bernhard

That's one small step for a man - one giant leap for mankind.
Find all posts by this user
Quote this message in a reply
03-12-2015, 11:01 PM
Post: #10
RE: Clear Stack (CLST, CLSTK) and LastX
Fortunately, no one among us gets to decide if LastX should be allowed in program mode for a specific calculator model. The developers decided that long ago. It is either a valid program instruction, or not. If it is a valid program instruction, then obviously the behavior should be consistent between program mode and non-program mode. If it is not consistent, then it's a bug.

Yet another reason why this calculator is looked upon with disfavor by many.
Find all posts by this user
Quote this message in a reply
03-12-2015, 11:26 PM
Post: #11
RE: Clear Stack (CLST, CLSTK) and LastX
What a pity we hadn't Marcus showing us the intimacies of RPN 40 years ago!

Greetings,
    Massimo

-+×÷ ↔ left is right and right is wrong
Visit this user's website Find all posts by this user
Quote this message in a reply
03-12-2015, 11:36 PM
Post: #12
RE: Clear Stack (CLST, CLSTK) and LastX
(03-12-2015 09:14 PM)MarkHaysHarris777 Wrote:  First, its not necessary because it is not a 'necessary' use case... I can use the 35s all day and 'never' touch the LASTX key; similar, I can use the 35s all day and 'never' touch the [ENTER] key either... they are not necessary. Second, give me one use case where LASTX is a mandated case where the computation could not be done using another method as easily or more easily?

Many of my calculations require me to use LastX , and all my calculations require me to use ENTER. LastX is easier to use than a STO/RCL operation if you need it, and plan accordingly.

-- Sanjeev Visvanatha
Find all posts by this user
Quote this message in a reply
03-13-2015, 04:35 AM (This post was last modified: 03-13-2015 04:37 AM by MarkHaysHarris777.)
Post: #13
RE: Clear Stack (CLST, CLSTK) and LastX
(03-12-2015 09:23 PM)Paul Dale Wrote:  The discussion about this wasn't too active or lively. It came down to:

  1. RCL L is exactly the same as LastX in function;
  2. RCL L is the same number of key strokes as shift LastX and
  3. we saved a shifted keyboard position which are a very scarce resource.


I don't regret this change at all.

Thanks, Pauli... that's something I've wondered about, 'preciate the history. I remember back, before I had my manual, wondering where LASTX went... I actually found it accidentally while I was playing with the emulator and turned on debugging to get the register list up, and noticed that L was appearing to function like a LASTX - voila, eureka!

I use LASTX too, and most of my posting about this topic (as I'm sure you know) has also been tongue-in-cheek devil's advocate stuff... on the other hand, what is your take on whether the LASTX is part of the stack, or tied to the stack? From a single point of view it makes sense (in a way) to clear LASTX when the stack is cleared? Do you remember the lively discussion, or does the thread still exist in the archive?

Also, a point not yet discussed here, does the stack ever really need to be cleared? I argue No. Clearing the stack is not ever necessary. I have only found one reason for needing to clear the stack, and that is when you're not going to use the [ENTER]! If I use the [+] key for enter requires me to have a clear stack initially. Also, if I use the [*] key [X] to clear x the stack needs to be initially clear and kept clear. I often use the [X] to clear x, and use the [+] for entry; the [ENTER] key is then no longer needed, and the replicate of X->Y on [ENTER] stack lift annoyance is gone. Your take?

Cheers,
marcus
Smile

Kind regards,
marcus
Find all posts by this user
Quote this message in a reply
03-13-2015, 05:35 AM
Post: #14
RE: Clear Stack (CLST, CLSTK) and LastX
(03-12-2015 07:29 PM)MarkHaysHarris777 Wrote:  If there is to be a LASTX all at, for program mode, it should be the LASTX 'before' the program ran-- not the LASTX of the last operation within the program!

This makes me wonder what should happen when calling a program from within another program? What if it's called from the same?

Cheers
Thomas
Find all posts by this user
Quote this message in a reply
03-13-2015, 07:27 AM
Post: #15
RE: Clear Stack (CLST, CLSTK) and LastX
(03-12-2015 09:14 PM)MarkHaysHarris777 Wrote:  First, its not necessary because it is not a 'necessary' use case... I can use the 35s all day and 'never' touch the LASTX key; similar, I can use the 35s all day and 'never' touch the [ENTER] key either... they are not necessary.

Sure - you can always store X in a separate register before any operation is performed. This way the additional effort is limited to one STO command (and 7 to 37 bytes of additional memory usage). But the idea behind LastX is to avoid exactly this STO as it is done automatically on every operation.

(03-12-2015 09:14 PM)MarkHaysHarris777 Wrote:  Second, give me one use case where LASTX is a mandated case where the computation could not be done using another method as easily or more easily?

Since you suggest there is always another method at least as easy (if not easier) than LastX, let me ask the question the other way round: please give an example that can be done easier than with the usage of LastX. ;-)

(03-12-2015 09:14 PM)MarkHaysHarris777 Wrote:  I do not question you. You probably do make use of LASTX frequently... the question is not whether you use it, or like it, the question is whether LASTX is mandated, required, or necessary?

Not even the [–] key is necessary as you can always use [+/–] [+]. The same holds for [√x], for [1/x] or for [tan] (which is [SIN] [LastX] [COS] [/] ;-)). With more or less additional effort many functions can be replaced. You can even press [STO][A] before every single operation to avoid LastX and still have the last operand saved somewhere. But that's not the idea behind a decent calculator. ;-)

Dieter
Find all posts by this user
Quote this message in a reply
03-13-2015, 09:48 AM
Post: #16
RE: Clear Stack (CLST, CLSTK) and LastX
In the HP-25/HP-25C the LastX register is physically located in an external RAM chip and occupies 1/16 of total external RAM, whereas the stack is located inside the ACT processor. This cannot resolve whether LastX belongs to the stack or not. But it explains why in HP-25C the LastX is "Continuous", whereas the stack is lost after switching off. In later model HP-29C, where more external memory chips were used, the firmware used also the X-Register to store in external RAM and made it "Continuous" too, but still Y,Z,T were lost. The todays LCD calculators like 35S are "Continuous" thoroughly and even remember the blinking cursor state.

In 35S the UNDO key could have been used to include the LastX functionality, but the designers missed to implement that, they decided that it should do nothing when used directly after an operation. But I don't consider that as a bug?

Bernhard

That's one small step for a man - one giant leap for mankind.
Find all posts by this user
Quote this message in a reply
03-15-2015, 10:19 PM
Post: #17
RE: Clear Stack (CLST, CLSTK) and LastX
(03-12-2015 09:14 PM)MarkHaysHarris777 Wrote:  the question is not whether you use it, or like it, the question is whether LASTX is mandated, required, or necessary?

Marcus, I'm not quite sure how you arrived at that as the "question" at all. I think it is immaterial whether a particular function such as LastX in a particular application is mandated, required, necessary, efficient, advantageous, etc. Coding can be a complex endeavor, as I am sure you know. If I choose to use a particular function, for whatever reason, in my code, as long as it works, my decision cannot be challenged by anyone else. It sounds to me as if you are doing that, correct me if I misinterpret. If you are just "poking fun," so be it, but your words don't convey that.

I think this thread began with a question about how LastX as a programmed instruction on the 35s behaves differently than LastX in a non-program situation. If that is true, most would consider that a bug.
Find all posts by this user
Quote this message in a reply
03-16-2015, 05:20 AM (This post was last modified: 03-16-2015 05:43 AM by Thomas Klemm.)
Post: #18
RE: Clear Stack (CLST, CLSTK) and LastX
(03-12-2015 09:14 PM)MarkHaysHarris777 Wrote:  I can use the 35s all day and 'never' touch the [ENTER] key either...

I wonder how you calculate 7*9+3*13 with your method.

(02-18-2015 08:24 PM)MarkHaysHarris777 Wrote:  Consider the following key sequence: [3] [x↔y] [←] [4] [X]
(...)
How many ways are there to manipulate the stack registers to accomplish the same purpose? Remember it is not important how the operands get into X and Y necessarily, only that they get there. Try this one:

[4] [R↓] [←] [3] [R↑] [X] (or) [4] [R↑] [←] [3] [X] (or) [CLSTK] [4] [+] [3] [X]

From all the alternative key sequences given only one works:
[4] [R↑] [←] [3] [X]

But then e.g. the HP-42S lacks a [R↑] key and thus you might be tempted to use the [R↓] key thrice. Thus you really prefer pressing four keys instead of one?

Cheers
Thomas
Find all posts by this user
Quote this message in a reply
03-16-2015, 05:53 AM
Post: #19
RE: Clear Stack (CLST, CLSTK) and LastX
(03-16-2015 05:20 AM)Thomas Klemm Wrote:  I wonder how you calculate 7*9+3*13 with your method.

Somewhat sadly, I suspect I'd just enter this as 102 even if the ENTER key were allowed. Nothing like some easy mental arithmetic to keep you on the ball.


- Pauli
Find all posts by this user
Quote this message in a reply
03-16-2015, 06:28 AM
Post: #20
RE: Clear Stack (CLST, CLSTK) and LastX
(03-16-2015 05:53 AM)Paul Dale Wrote:  Nothing like some easy mental arithmetic to keep you on the ball.

Feel free to find another more challenging example to calculate a scalar product:

23 apples @ $0.43
47 eggs @ $0.17

Marcus' "trick" to avoid the [ENTER] key only works with simple chain calculations.

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




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