The Museum of HP Calculators

HP Forum Archive 06

 Register arithmetic: sometimes it uses MORE space?Message #1 Posted by Luca de Alfaro on 25 Oct 2001, 1:02 a.m. I tried the following on my HP 42S: RCL 01 x uses 2 bytes (one for each instruction). Instead, RCL x 01 uses 3 bytes! Hence, it seems that RCL-arithmetic is not a good idea on the 42S. Instead, on the 32SII, I have: RCL A x takes 3 bytes, while RCL x A takes only 1.5! What are the trade-offs in other calculators? Best, Luca

 Re: Register arithmetic: sometimes it uses MORE space?Message #2 Posted by Cameron on 25 Oct 2001, 2:13 a.m.,in response to message #1 by Luca de Alfaro Luca, I've only just learned about register arithmetic so I may have misunderstood something. However, your comparisons don't appear to be valid. The non-register variant must be: ```rcl A x sto A ``` Which is possibly longer than you calculated. Cameron

 Re: Register arithmetic: sometimes it uses MORE space?Message #3 Posted by Luca de Alfaro on 25 Oct 2001, 2:26 a.m.,in response to message #2 by Cameron Hello Cameron. Not quite: RCL x A; is similar (except for stack effect) to RCL A; x; (where ; separates instructions), while STO x A is similar (except for stack effect) to RCL A; x; STO A; In the 42S, the RCL-arithmetic seems to be useful to conserve stack (in case T contains something useful), but incurs a penalty in memory. I wonder about execution time... Cheers, Luca.

 Re: Register arithmetic: sometimes it uses MORE space?Message #4 Posted by Vieira, Luiz C. (Brazil) on 25 Oct 2001, 10:00 a.m.,in response to message #3 by Luca de Alfaro Hello. Register arithmetic in the HP42S is only two-bytes longer for numbered registers (the same in the 15C). When dealing with variables (as shown by Mr. Luca), each letter in the variable name will consume one extra byte; the instruction itself - STO - needs 1 byte, plus one extra for the addressed object - in the basic set: stack registers, numbered registers AND indirect for both - . If the addressed objet is referred to by a string - variable´s name -, the string will consume as much memory as it would in a program step. One single experiment: try STO ST X STO "X" ST X is the stack register; so, STO ST X needs 2 bytes. Instead, STO "X" uses three. The fact is that the variable addressing in the 32S is already the basic set; it does not have numbered registers AND the existence of any variable depends on its creation. The 42S expanded the concept for variables later, extending the basic 41's set, over the penalty of consuming more memory. And the shortest instruction in the half/fullnuts is still based in a one-byte count. New generation Saturn-based machine count one-(byte+nible) program space for most data. Best regards.

Go back to the main exhibit hall