The HP67 saves the user program counter in the bottom 3 nibbles (2,1,0) of ram[61]. However, you could be forgiven for thinking that those three digits don’t look anything like the program counter display. Here’s why
Internally it stores ram[61][2,1,0] as n,b,r where:
n is the instruction number (0-6) within the program register
b is the program ram bank (1-2)
r is the register (0-0x0f) within the ram bank.
Program steps 001-112 reside in ram bank 2. You see this as registers 32-47 in the hp67u under menu, Advanced, View RAM.
Program steps 113-224 reside in ram bank 1. This is registers 16-31 in the same menu option.
Each ram register contains 14 nibbles (4 bit digits – these show up as “0”-“9” in data registers). When a ram register is used to store a program step, the full range of “0-9a-f” is used for each nibble – so don’t be too surprised if you see things in there other than “0”-“9”.
Each merged user program step is stored internally as an 8-bit instruction so each program register stores 7 steps and each step is 2 nibbles long.
This program:
001: 31 25 11 002: 09 003: 71 004: 05 005: 81 006: 03 007: 02 008: 61 009: 35 22 010: 84 011: 84
gets stored as:
45: 00000000000000 46: 00000000000e37 47: 12131e153919fa
“fa” is the 8-bit code for “31 25 11” (f LBL A).
The content of ram[61] looks like this:
61: 0000000000042f
That combination has b=2, r=0x0f(=15) and n=4.
What you see displayed as the program step number is:
((b==2)? 120 : 232) – (r+1)*7 – (n+1)
In this case:
=120 – (15+1)*7 – (4+1)
=120 – 16*7 – 5
=120 – 112 – 5 = 003
Effectively the three n,b,r nibbles form a counter of
(0-6)*(1-2)*(0-15) = 7*2*16 = 2*112 = 224 (program steps).
It’s hard for us to follow but it makes it easier for the calculator to find the next user program step:
– select ram bank 1 or 2
– access register 0-15 within that bank
– get the 0-6th set of 2 “digits” from that register.