Page 1 of 1

Clearing Last X Register "L"

Posted: Sat Oct 24, 2020 10:04 pm
by amafan
Is it possible to clear the Last X Register "L" without having to operate on the X Register holding a Zero? It doesn't clear when you do a CLSK command. I know it clears if you do a Clear All, but that not a viable situation on anything but a brand new calculator with no stored programs or constants. i don't even know why I would want to do this except to initialize the stack before running a program, but that seems to be a good reason.

Re: Clearing Last X Register "L"

Posted: Sat Oct 24, 2020 10:39 pm
by gmac42
amafan wrote:
Sat Oct 24, 2020 10:04 pm
Is it possible to clear the Last X Register "L" without having to operate on the X Register holding a Zero? It doesn't clear when you do a CLSK command. I know it clears if you do a Clear All, but that not a viable situation on anything but a brand new calculator with no stored programs or constants. i don't even know why I would want to do this except to initialize the stack before running a program, but that seems to be a good reason.
There's no explicit way that I am aware of. What I usually do is

Code: Select all

CLST
+

Re: Clearing Last X Register "L"

Posted: Sat Oct 24, 2020 11:05 pm
by bernouilli
amafan wrote:
Sat Oct 24, 2020 10:04 pm
Is it possible to clear the Last X Register "L" without having to operate on the X Register holding a Zero?
What about :
LASTX
ST- ST L

but with this, X hold the previous value of L

Re: Clearing Last X Register "L"

Posted: Sun Oct 25, 2020 12:00 am
by Thomas Okken
Setting LASTx to zero with no side effects is possible...

X<> ST L
CLX
X<> ST L

Re: Clearing Last X Register "L"

Posted: Sun Oct 25, 2020 1:01 am
by amafan
gmac42 wrote:
Sat Oct 24, 2020 10:39 pm
amafan wrote:
Sat Oct 24, 2020 10:04 pm
Is it possible to clear the Last X Register "L" without having to operate on the X Register holding a Zero? It doesn't clear when you do a CLSK command. I know it clears if you do a Clear All, but that not a viable situation on anything but a brand new calculator with no stored programs or constants. i don't even know why I would want to do this except to initialize the stack before running a program, but that seems to be a good reason.
There's no explicit way that I am aware of. What I usually do is

Code: Select all

CLST
+
This is what I do now. It’s not bad and it can be easily programmed. I was just surprised to find out that CLST didn’t clear “L” at the same time.

Re: Clearing Last X Register "L"

Posted: Sun Oct 25, 2020 11:53 am
by gmac42
amafan wrote:
Sun Oct 25, 2020 1:01 am
I was just surprised to find out that CLST didn’t clear “L” at the same time.
Technically, L is not part of the stack, but I've always found that a bit weird, too.
Does anyone know a better reason why CLST does not clear L?
Is there a common use case where you want to CLST but still need L?

Re: Clearing Last X Register "L"

Posted: Sun Oct 25, 2020 6:09 pm
by amafan
gmac42 wrote:
Sun Oct 25, 2020 11:53 am
amafan wrote:
Sun Oct 25, 2020 1:01 am
I was just surprised to find out that CLST didn’t clear “L” at the same time.
Technically, L is not part of the stack, but I've always found that a bit weird, too.
Does anyone know a better reason why CLST does not clear L?
Is there a common use case where you want to CLST but still need L?
Yes, you're right that its not part of the stack and the behavior emulates the behavior of the original HP41s to maintain software compatibility. My OP was meant to see if there was something I had missed in the clear commands. Since not, I imagine the HP developers had some reasoning behind not Clearing "L" during CLST. So OK, it is what it is. Now that I know that I can deal with it.

Re: Clearing Last X Register "L"

Posted: Sun Oct 25, 2020 6:31 pm
by firai
gmac42 wrote:
Sun Oct 25, 2020 11:53 am
Technically, L is not part of the stack, but I've always found that a bit weird, too.
Does anyone know a better reason why CLST does not clear L?
Is there a common use case where you want to CLST but still need L?
I found a discussion about the general topic of LASTX at https://www.hpmuseum.org/forum/thread-3345.html. The reason seems to between not considering L as part of the (operational) stack and a bit of tradition starting from HP-45. If you use a variant of the swap operation Thomas suggested (CLST instead of CLX), then you could also use this quirk/feature to wipe the rest of the stack (including L) but still keep x without storing to a variable or register. I suppose the reason why someone would want to do that would be similar to the reason why someone would want to clear the stack in the first place.