HP67 – h SF 4 and h CF 4

There are two unused codes in the HP-67 calculator that actually do things. These are “h SF 4” and “h CF 4”. Now, if you know the HP-67 calculator, you know it doesn’t have a “flag 4”. There are only flags 0-3 and you can set, test and clear these to your heart’s content. What’s flag 4?

Program steps are stored internally as 8-bit numbers. That allows 256 different merged keycodes to be stored. But only 250 are actually used. You can’t (normally) key in the other six.

Two of the six, if you could key them in, show up in the W/PRGM display as “35 51 04” and “35 61 04”. That is “h SF 4” and “h CF 4”.

What do they do? To my surprise they do exactly what their names suggest. They set and clear flag 4.

Now hang on, there’s only space for flags 0-3. They occupy the bottom 4 nibbles of ram[62], just to the right of the display settings. There isn’t room for a flag 4.

Flag 4 is right over the other side of ram[62]. It isn’t supposed to exist. It isn’t documented. It shouldn’t be accessible. But there is space for it in nibble 13 of ram[62]. And you can set and clear it using the “unused” codes bearing its name.

However, it isn’t much use to us because we are missing the other instruction in the set – a “h F? 4” to allow us to choose a course of action that depends on it. That said, nibble 13 is the “sign bit” so it is possible that the microcode will behave differently if this (which should never be non-zero in real life) happens to be “1”. That’d require checking every use of ram[62] to see if any will do something different under those circumstances.

Here’s a summary of the microcode for the 0x8e and 0x6e hex codes (h SF 4 and h CF 4) instructions:

; ***** h SF 4

06266 jsb 06335              ; set s 12 if 0x6[a-f] or 0x8[a-f]
06267 if 1 = s 12
06270 then go to 07422
07422 ...
07423 jsb 07430              ; get ram[62], set P to flag nibble 
(07431 data register -> c 14 ; ram[62] -> C= 00000012220000)
(07435 p + 1 -> p ; P= 13)
07424 load constant 1        ; C= 10000012220000 (=SF 4)
07425 c -> data register 14  ; c -> ram[62] (=10000012220000)

; ***** END

; ***** h CF 4

06040 ...
07413 a + 1 -> a[p]          ; A= 004fff35f6106f
07414 if n/c go to 07417
07417 jsb 07430              ; set P to flag nibble (as above)
; (ram[62] -> C= 10000012220000 P= 13 A= 004fff35f61000)
07420 load constant 0        ; C= 00000012220000 P= 12
07421 if n/c go to 07425
07425 c -> data register 14  ; c -> ram[62] (=00000012220000)

; ***** END

The key microcode instructions are:
“07424 load constant 1 ; C= 10000012220000” and
“07420 load constant 0 ; C= 00000012220000”.

When placed inside a set of
“07431 data register -> c 14 ; ram[62] -> C” and
“07425 c -> data register 14 ; c -> ram[62]”
the flag is really getting set and cleared.

P=13 is the starting point for working out which nibble holds which flag. Normally the codes for “h SF [0-3]” (0x8a – 0x8d) and “h CF [0-3]” (0x6a – 0x6d) result in P=[3-0]. Codes 0x8e and 0x6e exit the 07435-7437 loop early and leave P=13.

You can see more detail of the h SF 4, h CF 4 process in 67-h-sf-4-cf-4.txt.

You can find details about the missing codes and how to enter them in HP67 Unused Program Codes.

It's only fair to share...Share on FacebookTweet about this on TwitterShare on Google+Share on LinkedInShare on StumbleUponDigg thisPin on PinterestEmail this to someone

Leave a Reply

Your email address will not be published. Required fields are marked *