HP-21 Low Power

Here’s what the HP-21 looks like with low power:

Here’s how that happens :

Step 1 (for an emulator), lower the battery voltage and run it:


C:\Test\hp21w>hp21w -d

HP21w Ver 0.01
Copyright 2018 Greg Sydney-Smith

CPU speed is 200 kHz

>>> si voltage 1
>>> di
Display          : on (12 digits)
Arithmetic base  : 10
Ram address      : 0
f                : 0
carry            : false
bank/dlyrom      : 0/-1
sp, stack        : 0 [00000,00000]
lastkey          : 00
voltage          : 1.0
>>> g


For a real calculator, just leave it on for a while. (Press a key from time to time because the low power warning doesn’t come on when it is sitting in the wait loop).

If you have an emulator, you should see the s5 flag disappear (go to 0), like this:

>>> dr
A=0000FFFFFFFFFF D=00000000000000 M1=00000000000000 P= 0
B=28999999900000 E=00000000000000 M2=00000000000000
C=00000000000000 F=00000000000000 S =...3............
>>>


The only thing set is s3 (so the DEG-RAD switch is set to RADians).

If we press the CLx key, it goes through the keypress routine. The scancode for the CLx key is 0xd0 (1101 0000 = 11 010 000 = 0320) so the keypress routine goes to 0400+0320 = address 0720 to do the CLx function. That looks like:

00720: if n/c goto 0254                    ;
00654: if 0 = s 13 then goto 00004         ; if g not pressed
00004: 0 -> c[w]                           ; 0 -> X register
00005: 0 -> s 2                            ; clear auto_enter ie don't lift stack after CLx
00006: clear s                             ; clear everything else (other prefixes?)


Then we get into display instructions which get A and B ready to display the new X value (0.00):

00007: display off                         ;
00010: jsb 0347                            ;
...
00014: 0 -> b[w]                           ; B=00000000000000
00015: jsb 0111                            ;
...                                        ; A=0000FFFFFFFFFF B=21000000000000


Then we check the s5 flag and find we have low power

00135: 0 -> s 5                            ;
00136: if 0 = s 5 then goto 00736          ;


So we end up at the low power routine:

00736: p <- 12                             ; P=12
00737: b exchange c[p]                     ; B=20000000000000 C=01000000000000
00740: 0 - c - 1 -> c[p]                   ; C=08000000000000
00741: b exchange c[p]                     ; B=28000000000000 C=00000000000000
00742: p - 1 -> p                          ; P=11
00743: if p = 4 then goto 00140            ;
00745: if n/c goto 0337                    ;

00737: b exchange c[p]                     ;
00740: 0 - c - 1 -> c[p]                   ; C=00900000000000
00741: b exchange c[p]                     ; B=28900000000000 C=00000000000000
00742: p - 1 -> p                          ; P=10
00743: if p = 4 then goto 00140            ;
00745: if n/c goto 0337                    ;

00737: ...                                 ; B=28990000000000 P= 9
00737: ...                                 ; B=28999000000000 P= 8
...
00737: ...                                 ; B=28999999000000 P= 5
00737: ...                                 ; B=28999999900000 P= 4
00743: if p = 4 then goto 00140            ;

00140: jsb 0364                            ;
00364: c -> a[s]                           ; get the sign of X from the C register
00365: display toggle                      ; "0 0.0. . . . . ."


Adding all those extra 9s to the B register turns on all those extra dots.

00736-00741 swapped the “1” in B[12] for an “8” in B[12]. It needs to be an odd number for the decimal point to get added, so those first steps turned off the real decimal point.

This is part of the HP-21 topic.

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 *