{"id":1993,"date":"2018-03-02T10:12:45","date_gmt":"2018-03-02T10:12:45","guid":{"rendered":"http:\/\/www.sydneysmith.com\/wordpress\/?p=1993"},"modified":"2018-03-02T10:12:45","modified_gmt":"2018-03-02T10:12:45","slug":"hp-21-low-power","status":"publish","type":"post","link":"https:\/\/www.sydneysmith.com\/wordpress\/1993\/hp-21-low-power\/","title":{"rendered":"HP-21 Low Power"},"content":{"rendered":"<p>Here&#8217;s what the HP-21 looks like with low power:<br \/>\n<img loading=\"lazy\" src=\"http:\/\/www.sydneysmith.com\/wordpress\/wp-content\/uploads\/2018\/03\/hp21-low-power.png\" alt=\"\" width=\"311\" height=\"129\" class=\"alignnone size-full wp-image-1994\" srcset=\"https:\/\/www.sydneysmith.com\/wordpress\/wp-content\/uploads\/2018\/03\/hp21-low-power.png 311w, https:\/\/www.sydneysmith.com\/wordpress\/wp-content\/uploads\/2018\/03\/hp21-low-power-300x124.png 300w\" sizes=\"(max-width: 311px) 100vw, 311px\" \/><\/p>\n<p>Here&#8217;s how that happens <!--more-->:<\/p>\n<p>Step 1 (for an emulator), lower the battery voltage and run it:<br \/>\n<code><\/p>\n<pre>\r\n\r\nC:\\Test\\hp21w>hp21w -d\r\n\r\nHP21w Ver 0.01\r\nCopyright 2018 Greg Sydney-Smith\r\n\r\nCPU speed is 200 kHz\r\n\r\n>>> si voltage 1\r\n>>> di\r\nDisplay          : on (12 digits)\r\nArithmetic base  : 10\r\nRam address      : 0\r\nf                : 0\r\ncarry            : false\r\nbank\/dlyrom      : 0\/-1\r\nsp, stack        : 0 [00000,00000]\r\nlastkey          : 00\r\nvoltage          : 1.0\r\n>>> g\r\n<\/pre>\n<p><\/code><br \/>\nFor a real calculator, just leave it on for a while. (Press a key from time to time because the low power warning doesn&#8217;t come on when it is sitting in the wait loop).<\/p>\n<p>If you have an emulator, you should see the s5 flag disappear (go to 0), like this:<br \/>\n<code><\/p>\n<pre>\r\n>>> dr\r\nA=0000FFFFFFFFFF D=00000000000000 M1=00000000000000 P= 0\r\nB=28999999900000 E=00000000000000 M2=00000000000000\r\nC=00000000000000 F=00000000000000 S =...3............\r\n>>>\r\n<\/pre>\n<p><\/code><br \/>\nThe only thing set is s3 (so the DEG-RAD switch is set to RADians).<\/p>\n<p>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:<br \/>\n<code><\/p>\n<pre>\r\n00720: if n\/c goto 0254                    ;\r\n00654: if 0 = s 13 then goto 00004         ; if g not pressed\r\n00004: 0 -> c[w]                           ; 0 -> X register\r\n00005: 0 -> s 2                            ; clear auto_enter ie don't lift stack after CLx\r\n00006: clear s                             ; clear everything else (other prefixes?)\r\n<\/pre>\n<p><\/code><br \/>\nThen we get into display instructions which get A and B ready to display the new X value (0.00):<br \/>\n<code><\/p>\n<pre>\r\n00007: display off                         ;\r\n00010: jsb 0347                            ;\r\n...\r\n00014: 0 -> b[w]                           ; B=00000000000000\r\n00015: jsb 0111                            ;\r\n...                                        ; A=0000FFFFFFFFFF B=21000000000000\r\n<\/pre>\n<p><\/code><br \/>\nThen we check the s5 flag and find we have low power<br \/>\n<\/code><\/p>\n<pre>\r\n00135: 0 -> s 5                            ;\r\n00136: if 0 = s 5 then goto 00736          ;\r\n<\/pre>\n<p><\/code><br \/>\nSo we end up at the low power routine:<br \/>\n<code><\/p>\n<pre>\r\n00736: p <- 12                             ; P=12\r\n00737: b exchange c[p]                     ; B=20000000000000 C=01000000000000\r\n00740: 0 - c - 1 -> c[p]                   ; C=08000000000000\r\n00741: b exchange c[p]                     ; B=28000000000000 C=00000000000000\r\n00742: p - 1 -> p                          ; P=11\r\n00743: if p = 4 then goto 00140            ;\r\n00745: if n\/c goto 0337                    ;\r\n\r\n00737: b exchange c[p]                     ;\r\n00740: 0 - c - 1 -> c[p]                   ; C=00900000000000\r\n00741: b exchange c[p]                     ; B=28900000000000 C=00000000000000\r\n00742: p - 1 -> p                          ; P=10\r\n00743: if p = 4 then goto 00140            ;\r\n00745: if n\/c goto 0337                    ;\r\n\r\n00737: ...                                 ; B=28990000000000 P= 9\r\n00737: ...                                 ; B=28999000000000 P= 8\r\n...\r\n00737: ...                                 ; B=28999999000000 P= 5\r\n00737: ...                                 ; B=28999999900000 P= 4\r\n00743: if p = 4 then goto 00140            ;\r\n\r\n00140: jsb 0364                            ;\r\n00364: c -> a[s]                           ; get the sign of X from the C register\r\n00365: display toggle                      ; \"0 0.0. . . . . .\"\r\n<\/pre>\n<p><\/code><br \/>\nAdding all those extra 9s to the B register turns on all those extra dots.<\/p>\n<p>00736-00741 swapped the &#8220;1&#8221; in B[12] for an &#8220;8&#8221; 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.<\/p>\n<p>This is part of the <a href=\"http:\/\/www.sydneysmith.com\/wordpress\/hp21-main\/\">HP-21 topic<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Here&#8217;s what the HP-21 looks like with low power: Here&#8217;s how that happens<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[16,5,68],"tags":[],"_links":{"self":[{"href":"https:\/\/www.sydneysmith.com\/wordpress\/wp-json\/wp\/v2\/posts\/1993"}],"collection":[{"href":"https:\/\/www.sydneysmith.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.sydneysmith.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.sydneysmith.com\/wordpress\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sydneysmith.com\/wordpress\/wp-json\/wp\/v2\/comments?post=1993"}],"version-history":[{"count":3,"href":"https:\/\/www.sydneysmith.com\/wordpress\/wp-json\/wp\/v2\/posts\/1993\/revisions"}],"predecessor-version":[{"id":1997,"href":"https:\/\/www.sydneysmith.com\/wordpress\/wp-json\/wp\/v2\/posts\/1993\/revisions\/1997"}],"wp:attachment":[{"href":"https:\/\/www.sydneysmith.com\/wordpress\/wp-json\/wp\/v2\/media?parent=1993"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sydneysmith.com\/wordpress\/wp-json\/wp\/v2\/categories?post=1993"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sydneysmith.com\/wordpress\/wp-json\/wp\/v2\/tags?post=1993"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}