The Museum of HP Calculators

HP Forum Archive 20

[ Return to Index | Top of Index ]

WP 34S - INC X and RCL L (LASTx)
Message #1 Posted by Gerson W. Barbosa on 26 Dec 2011, 1:10 p.m.

Is there a reason INC X doesn't affect the register L (LASTx)? Thanks!

      
Re: WP 34S - INC X and RCL L (LASTx)
Message #2 Posted by Marcus von Cube, Germany on 26 Dec 2011, 2:47 p.m.,
in response to message #1 by Gerson W. Barbosa

Simplicity. X is just another register. We would need to check for X as a special case (not only for INC).

            
Re: WP 34S - INC X and RCL L (LASTx)
Message #3 Posted by Andrés C. Rodríguez (Argentina) on 26 Dec 2011, 2:57 p.m.,
in response to message #2 by Marcus von Cube, Germany

I think it may be better not to save LastX when just incrementing (or decrementing) a register, to avoid the loss of generality. And, eventually, LastX may well end containing a "1" as the "last" operand added or substracted...

                  
Re: WP 34S - INC X and RCL L (LASTx)
Message #4 Posted by Gerson W. Barbosa on 26 Dec 2011, 3:17 p.m.,
in response to message #3 by Andrés C. Rodríguez (Argentina)

I can't think of a situation in which updating LastX after INC or DEC would be inconvenient. On the other hand here it would save two steps:

001 LBL A		001 LBL A
002 1			002 INC X
003 x<>y		003 RCL L
004 +			    ...
005 RCL L
    ...
                        
Re: WP 34S - INC X and RCL L (LASTx)
Message #5 Posted by Paul Dale on 26 Dec 2011, 4:33 p.m.,
in response to message #4 by Gerson W. Barbosa

How about:

001 LBL A
002 ENTER
003 INC Y
    ...

No steps saved :-)

On the other hand, INC not setting LastX has been a boon several times.

- Pauli

Edited: 26 Dec 2011, 4:34 p.m.

                              
Re: WP 34S - INC X and RCL L (LASTx)
Message #6 Posted by Gerson W. Barbosa on 26 Dec 2011, 5:04 p.m.,
in response to message #5 by Paul Dale

That'll do, thanks!

Gerson.

            
Re: WP 34S - INC X and RCL L (LASTx)
Message #7 Posted by fhub on 26 Dec 2011, 4:12 p.m.,
in response to message #2 by Marcus von Cube, Germany

Quote:
Simplicity. X is just another register. We would need to check for X as a special case (not only for INC).
But it's definitely inconsistent! IMO one should really be able to trust that LastX (L) is set to X whenever X is changed. Otherwise we would need a (complete!) table which operations set L and which not.
                  
Re: WP 34S - INC X and RCL L (LASTx)
Message #8 Posted by gene wright on 26 Dec 2011, 4:14 p.m.,
in response to message #7 by fhub

I do agree that consistency is to be preferred.

What reasons are there for not incrementing X specifically?

                        
Re: WP 34S - INC X and RCL L (LASTx)
Message #9 Posted by Paul Dale on 26 Dec 2011, 4:46 p.m.,
in response to message #8 by gene wright

Get out your trusty 41c and execute ISG X. Is the old X saved in LastX? No. The same is true on the 34S for all six increment and decrement operations. INC and DEC are there because I've seen way too many cases of "ISG nn NOP" in programs. i.e. they are very useful short cuts. In this way INC and DEC are completely consistent with their kindred commands.

Not setting LastX for these operations has actually been a bonus more times than not. There have been a number of rather clever pieces of code written that rely on this behaviour. As an aside: I've contemplated introducing fast arithmetic operations that allow you to add, subtract, multiply or divide X and a constant argument. These would most likely not save LastX either.

Finally, as Marcus mentioned, I'm very unlikely to introduce LastX saving here, checking for X specially would require extra code which we kind of don't have space for. What about ISG, DSE, X<> or even CLx ? They change X but nobody has ever called for them to set LastX that I'm aware of? Must they too be modified to save LastX even though it breaks backward compatibility with everything?

Sorry, but I think it is consistent the way it is and that it is more useful not setting LastX. I'm going to be difficult to convince otherwise I suspect.

- Pauli

                              
Re: WP 34S - INC X and RCL L (LASTx)
Message #10 Posted by Gerson W. Barbosa on 26 Dec 2011, 5:23 p.m.,
in response to message #9 by Paul Dale

Quote:
What about ISG, DSE, X<> or even CLx ? They change X but nobody has ever called for them to set LastX that I'm aware of?

Perhaps because ISG and DSE are used primarily for loop control, unlike INC and DEC. My opinion is the same as Franz's above, but considering that lots of (built-in?) code have been written with this behavior in mind, better keep it this way.

Gerson.

                                    
Re: WP 34S - INC X and RCL L (LASTx)
Message #11 Posted by Paul Dale on 26 Dec 2011, 5:33 p.m.,
in response to message #10 by Gerson W. Barbosa

Quote:
Perhaps because ISG and DSE are used primarily for loop control, unlike INC and DEC.

Go through the 41c software archive -- ISG and DSE are very commonly used for their +1 or -1 effect and are often followed by a NOP instruction: DEG, empty alpha and the like. Not always of course but surprisingly often -- this is the heritage of INC and DEC.

- Pauli


[ Return to Index | Top of Index ]

Go back to the main exhibit hall