HP Forums
(11C) 100 virtual registers - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Software Libraries (/forum-10.html)
+--- Forum: General Software Library (/forum-13.html)
+--- Thread: (11C) 100 virtual registers (/thread-10338.html)



(11C) 100 virtual registers - Michael Zinn - 03-18-2018 12:04 AM

Get 100 virtual registers instead of just 20!

These are STO and RCL commands to store a number between 0 and 99 in a virtual register numbered 0 to 99. I recommend using labels D and E because they are in the same columns as STO and RCL.

vRCL x
Recall a number from virtual register X. Notice how this affects the stack:

Before:
T: ?
Z: z
Y: y
X: Register number (0-99)


After:
T: z
Z: z
Y: y
X: Register content



y vSTO x
Stores Y in virtual register X. Unlike regular STO, this removes the value from the stack so if you need it again you'll have to vRCL it. This also destroys T:

Before:
T: ?
Z: z
Y: Data (0-99)
X: Register (0-99)


After:
T: Garbage
Z: z
Y: z
X: z



Only tested on the Android 11i simulator, but it should work on real devices (please comment if it doesn't):

Code:
LBL D
5
/
STO I
FRAC
10
*
10^x
RCL (i)
x><y
/
FRAC
+
2
10^x
/
GSB 0
RCL (i)
x><y
/
INT
+
GSB 0
*
STO (i)
R\/
RTN

LBL 0
RCL I
FRAC
10
*
2
+
10^x
RTN

LBL E
5
/
STO I
FRAC
10
*
2
+
10^x
RCL (i)
x><y
/
FRAC
2
10^x
*
INT
RTN



RE: (11C) 100 virtual registers - Michael Zinn - 03-18-2018 04:23 PM

If you take into account that the program itself takes about 9 registers worth of storage away it is still worth it if numbers in the range 0-99 are enough for your program because you effectively gained 35 more registers (100 - 9*5 - 20).

The method would also work for differenty sized virtual register:

Code:

Number of registers | Possible values
--------------------+----------------
                200 | 0-9
                100 | 0-99 (default)
                 60 | 0-999
                 40 | 0-99999



RE: (11C) 100 virtual registers - Dieter - 03-18-2018 06:29 PM

(03-18-2018 12:04 AM)michaelzinn Wrote:  Get 100 virtual registers instead of just 20!

I see you are rediscovering techniques from the Seventies. ;-) Storing multiple integers in a single data register soon became popular with the advent of the HP67/97 in 1976, as these were – as far as I know – the first HPs that offered indirect addressing.

There are even HP programs where you can see this method at work. Take a look at this moon phase program for the HP41. The initialization routine prestores numerous two-digit integers where each register holds three or five at a time.

By the way: instead of 2 [10^x] you better use [EEX] 2. That's faster and it's also safe on early HPs where 10^x is prone to roundoff errors (HP25: 8 [10^x] => 99999999,60). That's exactly why HP soon switched to 13-digit internal precision.

Dieter