WP 34S - INC X and RCL L (LASTx)



#2

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


#3

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


#4

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...


#5

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
...

#6

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.


#7

That'll do, thanks!

Gerson.

#8

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.

#9

I do agree that consistency is to be preferred.

What reasons are there for not incrementing X specifically?


#10

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


#11

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.


#12

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


Possibly Related Threads...
Thread Author Replies Views Last Post
  [WP-34S] Unfortunate key damage with update to V3 :( svisvanatha 5 353 12-10-2013, 11:37 PM
Last Post: Les Bell
  WP-34S (Emulator Program Load/Save) Barry Mead 1 193 12-09-2013, 05:29 PM
Last Post: Marcus von Cube, Germany
  DIY HP 30b WP 34s serial flash/programming cable Richard Wahl 2 264 12-04-2013, 11:14 AM
Last Post: Barry Mead
  WP 34S/43 ?'s Richard Berler 3 289 11-10-2013, 02:27 AM
Last Post: Walter B
  My FrankenCulator (wp-34s) FORTIN Pascal 4 299 11-09-2013, 06:18 PM
Last Post: FORTIN Pascal
  WP 34S Owner's Handbook Walter B 5 441 11-09-2013, 05:34 PM
Last Post: Harald
  wp 34s overlay and programming. FORTIN Pascal 6 370 11-08-2013, 01:28 PM
Last Post: Nick_S
  m.dy in display of WP-34S Harold A Climer 3 212 11-05-2013, 11:28 AM
Last Post: Andrew Nikitin
  WP 34s : An old problem coming back Miguel Toro 2 214 11-05-2013, 03:00 AM
Last Post: Marcus von Cube, Germany
  [WP 34s] Pressure Conversion Factors Timothy Roche 8 433 11-04-2013, 07:17 PM
Last Post: Dave Shaffer (Arizona)

Forum Jump: