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



#12

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


#13

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


#14

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


#15

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

#16

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.


#17

That'll do, thanks!

Gerson.

#18

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.

#19

I do agree that consistency is to be preferred.

What reasons are there for not incrementing X specifically?


#20

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


#21

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.


#22

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 3,282 12-10-2013, 11:37 PM
Last Post: Les Bell
  WP-34S (Emulator Program Load/Save) Barry Mead 1 1,847 12-09-2013, 05:29 PM
Last Post: Marcus von Cube, Germany
  DIY HP 30b WP 34s serial flash/programming cable Richard Wahl 2 2,591 12-04-2013, 11:14 AM
Last Post: Barry Mead
  WP 34S/43 ?'s Richard Berler 3 2,120 11-10-2013, 02:27 AM
Last Post: Walter B
  My FrankenCulator (wp-34s) FORTIN Pascal 4 2,244 11-09-2013, 06:18 PM
Last Post: FORTIN Pascal
  WP 34S Owner's Handbook Walter B 5 2,748 11-09-2013, 05:34 PM
Last Post: Harald
  wp 34s overlay and programming. FORTIN Pascal 6 2,978 11-08-2013, 01:28 PM
Last Post: Nick_S
  m.dy in display of WP-34S Harold A Climer 3 1,994 11-05-2013, 11:28 AM
Last Post: Andrew Nikitin
  WP 34s : An old problem coming back Miguel Toro 2 1,797 11-05-2013, 03:00 AM
Last Post: Marcus von Cube, Germany
  [WP 34s] Pressure Conversion Factors Timothy Roche 8 3,265 11-04-2013, 07:17 PM
Last Post: Dave Shaffer (Arizona)

Forum Jump: