Register arithmetic: sometimes it uses MORE space?



#5

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


#6

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


#7

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.


#8

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 <op> - 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 <op> ST X
STO <op> "X"

ST X is the stack register; so, STO <op> ST X needs 2 bytes. Instead, STO <op> "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.


Possibly Related Threads...
Thread Author Replies Views Last Post
  Layout of arithmetic keys on early calculators Walter B 10 830 11-20-2013, 11:13 AM
Last Post: Jake Schwartz
  Little curiosity: why the fourth stack register is called "T"? Antlab 34 2,022 07-03-2013, 04:49 PM
Last Post: Walter B
  Arithmetic programs for HP39gII Mic 0 222 12-19-2012, 12:23 PM
Last Post: Mic
  HP50G Max SDcard Storage space?? mr-scorpio 9 705 08-22-2012, 09:57 AM
Last Post: Bart (UK)
  OT - Arduino In Space from HP41 Hacker PeterP 3 382 06-16-2012, 10:43 PM
Last Post: PeterP
  [WP34S] Register use by functions. Chris Tvergard 5 452 05-12-2012, 03:35 AM
Last Post: Walter B
  HP-34C Storage Register Arithmetic & Programming Matt Agajanian 14 978 05-08-2012, 11:04 AM
Last Post: Matt Agajanian
  OT: Space ship Michael Eckstein 18 1,076 04-04-2012, 12:31 PM
Last Post: Michael Eckstein
  Sleek approach to Register Exchange on HP-29C Matt Agajanian 8 563 03-16-2012, 01:04 PM
Last Post: Marcus von Cube, Germany
  Vintage HP15C Key Clicks but Doesn't Register Bruce Zastera 15 907 01-27-2012, 06:18 PM
Last Post: uhmgawa

Forum Jump: