HP67 Flags

The HP67 calculator has 4 flags. These can be set, cleared or tested. You use them in a user program to remember situations and to behave differently according to the situations. One example might be: the user entered a value (or not) and your program behaves suitably either way. There were a whole stack of programs at the time where you could enter a value and press [A], [B], [C] etc to store the value; or just press the button to calculate it. These included tax calculators, principal and interest calculators and ohms law – key in any two and press the third button for it to work out the third value.

Flag 3 was ideally suited to this type of situation because it gets automatically set if you type in a number. All you need to do is test it.

Flags 2 and 3 are “test-cleared”. This means that anytime you test them they automatically get cleared too. With Flags 0 and 1 you have to clear them whenever you need them cleared. There are merits to both approaches and HP included both so you could choose whichever suits best.

The commands are:
h SF {0-3} = 35 51 01 – 35 51 03
h CF {0-3} = 35 61 01 – 35 61 03
h F? {0-3} = 35 71 01 – 35 71 03

Program Codes

Internally, user program steps are stored as 8-bit values. The values used are:
h CF 0 – h CF 3 = 0x6a – 0x6d,
h SF 0 – h SF 3 = 0x8a – 0x8d, and
h F? 0 – h F? 3 = 0x58 – 0x5b.

If you have the hp67u emulator, you can see these internal codes in program memory by looking at menu, advanced, View RAM. Program memory is banks 1 and 2. That is registers 16-47 inclusive. As you key in program steps values start appearing in those registers. Each program step occupies two nibbles in a register so if you key in “h SF 0” you’ll see “8a” appear somewhere in one of the registers.

Extra Program Codes

There are a number of unused internal codes as 8 bits allows for 256 program codes and only 250 are used. Two of these are relevant to the HP67 flags as internal code 0x6e and 0x8e show up in the W/PRGM display as “35 61 04” and “35 51 04” (h CF 4 and h SF 4). There are only 4 flags in the HP67 (flags 0-3). Flag 4 doesn’t exist and it can’t actually be set or cleared. Conventional thought says the two instructions do nothing. This could be checked in the microcode simulator.

When the HP67 was released, people discovered that they could enter extra program codes by writing data cards, rewriting the card as a program, and physically pulling the card back out (or switching the calculator off) whilst it was still writing. This gave the mag card a “this is a program” header but it contained data. The calculator would load the data as program steps. If you got the right data and stopped the W/PRGM in the right place, you’d end up with the remaining 6 program codes loaded as a user program.

With the HP67u emulator life is a lot easier. You can use the “menu, Advanced, View RAM” button to change the contents of user program memory directly. Despite the button name, any edits you make get copied directly into the calculator’s internal RAM.

If you place an “8e” or “6e” in one of the bank 2 registers (ram[32-47]) it will show up somewhere in program steps 001-112. As a hint, ram[47] is program steps 001-007, ram[46] is steps 008-014, and so on. Bank 1 (registers ram[16-31]) is program steps 113-224.

However, with the HP67u, there is an even easier way. If you use “menu, Program” and key in program code “99 01 42” it will put a 0x8e in that step for you. If you go to the W/PRGM display, it will show “35 51 04” or h SF 4. 0x8e is 142 decimal. The convention I used for the 6 extra program codes is “99 0n nn” so 0x6e is 96+14=110 so “99 01 10” will insert program code 0x6e. Only the 6 extra codes use this convention. You should use normal key codes (eg “31 25 11” for f LBL A) for normal user program steps.

HP67 Internals

The flags are actually stored in the bottom 4 nibbles of register 62 (bank 3 register 14). Again you can see this via the Advanced page of the microcode simulator.

Microcode

A summary of the microcode for h SF 2 is:

(wait loop 00167 - 00213)
[h] pressed

(wait loop 00167 - 00213)
[SF] pressed

(wait loop 00167 - 00213)
[2] pressed
(scan code = 0x61)
00256 a -> rom address
01437 ...
01440 if n/c go to 01612
01612 ...
01623 if n/c go to 01474
01474 ...
01503 if n/c go to 01566
01566 delayed rom 01
01567 if n/c go to 0437
00437 ...
00441 delayed rom 02
00442 jsb 01205            ; clear s 4,6,7,8,10,13
00443 ...
00445 delayed rom 014
00446 if n/c go to 06021
06021 ...
06027 a -> rom address 
06010 if n/c go to 06266
06266 jsb 06335
06267 if 1 = s 12 
06270 then go to 07422
07422 ...
07423 jsb 07430
.07430 jsb 07706           ; select ram bank 3
.07431 data register -> c 14 ; c= ram[48+14=62] p=3-0 for F0-F3
.C=00000012220101          ; 0101= f0 f1 f2 f3
.07432 ...
.A=00000000000e00 P=13
.A=00000000000f00 P=0
.A=00000000000000 P=1
.07440 return
07424 load constant 1 
C=00000012220111           ; 0111 ie f2 now set
07425 c -> data register 14
*** ram[62]=00000012220111
07426 delayed rom 00 
07427 if n/c go to 0074
00074 ... ; clear up
00077 if n/c go to 0124
00124 ...
00157 delayed rom 02       ; update display
00160 jsb 01162
.A=000000000f1000 C=60000000000222 P=4
.A=00000000ff1000 C=50000000000222 P=5
.A=0000000fff1000 C=40000000000222 P=6
.A=000000ffff1000 C=30000000000222 P=7
.A=00000fffff1000 C=20000000000222 P=8
.A=0000ffffff1000 C=10000000000222 P=9
.A=000fffffff1000 C=00000000000222 P=10
.A=0000fffffff100
.01202 load constant 3
.C=03000000000022
.01203 b exchange c[w]
.B=03000000000022 (display now "0.00")
.01204 return
00161 hi im woodstock
00162 display off
00163 display toggle
00164 0 -> s 15
00165 if 1 = s 15
00166 then go to 0164

(wait loop 00167 - 00213)
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 *