![]() |
wp34s INC s function - Printable Version +- HP Forums (https://archived.hpcalc.org/museumforum) +-- Forum: HP Museum Forums (https://archived.hpcalc.org/museumforum/forum-1.html) +--- Forum: Old HP Forum Archives (https://archived.hpcalc.org/museumforum/forum-2.html) +--- Thread: wp34s INC s function (/thread-232315.html) |
wp34s INC s function - Jeff O. - 10-02-2012 I apologize in advance if this question has been asked and answered previously. I did read the fine manual, and attempted to search the archives, but could not find the answer. The question is, is it intentional behavior that register L is not updated when applying the INC function to the value in the stack X register. In other words, this happens: Keystroke X display Instead of this: Keystroke X display Thanks.
Re: wp34s INC s function - Walter B - 10-02-2012 If I'd document it the way it works (i.e. not loading L), it would be a feature ;-) After all, LASTx is primarily for error recovery IMHO, so not loading L in INC doesn't hurt, it's just not documented. Or is there any *need* for loading L here?
Re: wp34s INC s function - Jeff O. - 10-02-2012 Well, I "needed" it when I determined that it did not operate that way :-) LASTx’s primary use may be error recovery, but seeing as how functions like RCL+L, RCL-L, X<>L, etc. are allowed, it is also useful for general data manipulation. So should INC X, which is after all a function that could be called “X+1”, load L just like any* other function operating on X? * - I did not do an exhaustive search to determine if there are any other situations where something is done to the value in X that does not load L.
Re: wp34s INC s function - Paul Dale - 10-02-2012 This behaviour is intentional. Likewise for DEC. The only register it might make sense for is X and if we did it then, we'd have an exception which is bad. Better for these to just not touch L unless it is their argument.
Re: wp34s INC s function - Gerson W. Barbosa - 10-02-2012 One of these days I intended to use INC X in a program, but I quit because it didn't update the L register. I shifted to the HP-42S instead and used NOT, even though this is equivalent to 1 + +/- (for integers in the valid range). I think both DEC and INC should update the L register, but only when they act on X, if this is not difficult to implement.
Re: wp34s INC s function - Paul Dale - 10-02-2012 What does the 41C/42S do with "STO+ ST X" and the LastX register? This is the same case.
Re: wp34s INC s function - Gerson W. Barbosa - 10-02-2012 I see your point. Fortunately on the HP-42S we have "RCL+ST X", which behaves differently regarding the LastX register :-)
Gerson.
Re: wp34s INC s function - Paul Dale - 10-02-2012 On the 34S RCL register arithmetic sets L appropriately too :-) This makes sense since X is always changes. For STO arithmetic (and INC and DEC), X isn't always changed so L is left alone. There is some logic here :-)
Re: wp34s INC s function - Jeff O. - 10-02-2012 I see your points. Probably a trivial issue, one that will never impact me again. I just wanted to make sure it was intentional. In this case, I was to trying create x(x+1) without disturbing the stack by the following steps:
INC X But the following does the job:
X^2
Edited: 3 Oct 2012, 7:40 a.m.
Re: wp34s INC s function - Reth - 10-03-2012 Quote:Than it should be stated in section "last x behaviour" if one exists. Similar to stack lift/disable characteristic of different functions. Intuitively I would think DEC would load L with X. Re: wp34s INC s function - Ángel Martin - 10-03-2012 I certainly wouldn't argue about such a minor point but my SandMath's INCX and DECX functions do store X in L. If you consider Inc() and Dec() to be -trivial- functions then x is their argument. However DSE/ISG ST X do not save it, so that's supporting your approach. Either way is good, a consistent implementation is better... but "consistency is in the eye of the beholder"
Cheers, Re: wp34s INC s function - Paul Dale - 10-03-2012 Remember the 34S's INC and DEC take a register argument and increment or decrement that. In fact, the share code with DSE/ISG/DSZ/iSZ/DSL/ISE. If we'd implemented an explicit INCX/DECX, it would have saved X into L.
Re: wp34s INC s function - Marcus von Cube, Germany - 10-03-2012 To add to Pauli's comment, what about INC->nn where nn contains 100? Updating LastX would be dependent on the data, not only on the command alone. Looks like a Pandoara's box to me which should be better left unopened.
Re: wp34s INC s function - Walter B - 10-03-2012 Quote:There isn't such a section yet, but it may change ;-) OTOH, stack lift should be documented completely. Re: wp34s INC s function - Paul Dale - 10-03-2012 We should also get sections for carry and overflow in integer mode like the 16c manual has.
- Pauli
Re: wp34s INC s function - Walter B - 10-04-2012 For carry please see p. 55 :-)
Re: wp34s INC s function - Paul Dale - 10-04-2012 That's seven of the carry altering functions. See the 16c manual page 98 for some more. That is still not a comprehensive list.
Re: wp34s INC s function - Walter B - 10-04-2012 Literally copying old manuals is little fun :-( So I may point to that manual instead ...
Re: wp34s INC s function - Paul Dale - 10-04-2012 I find 55 commands that change carry and/or overflow. The 16c manual only lists 16 commands.
Command Carry Overflow - Pauli
Edited: 4 Oct 2012, 5:41 a.m.
|