{"id":1299,"date":"2015-11-21T22:57:39","date_gmt":"2015-11-21T22:57:39","guid":{"rendered":"http:\/\/www.sydneysmith.com\/wordpress\/?p=1299"},"modified":"2017-05-14T01:25:11","modified_gmt":"2017-05-14T01:25:11","slug":"hp67-h-sf-4-and-h-cf-4","status":"publish","type":"post","link":"https:\/\/www.sydneysmith.com\/wordpress\/1299\/hp67-h-sf-4-and-h-cf-4\/","title":{"rendered":"HP67 &#8211; h SF 4 and h CF 4"},"content":{"rendered":"<p>There are two unused codes in the HP-67 calculator that actually do things. These are &#8220;h SF 4&#8221; and &#8220;h CF 4&#8221;. Now, if you know the HP-67 calculator, you know it doesn&#8217;t have a &#8220;flag 4&#8221;. There are only flags 0-3 and you can set, test and clear these to your heart&#8217;s content. What&#8217;s flag 4? <!--more--><\/p>\n<p>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&#8217;t (normally) key in the other six.<\/p>\n<p>Two of the six, if you could key them in, show up in the W\/PRGM display as &#8220;35 51 04&#8221; and &#8220;35 61 04&#8221;. That is &#8220;h SF 4&#8221; and &#8220;h CF 4&#8221;.<\/p>\n<p>What do they do? To my surprise they do exactly what their names suggest. They set and clear flag 4.<\/p>\n<p>Now hang on, there&#8217;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&#8217;t room for a flag 4.<\/p>\n<p>Flag 4 is right over the other side of ram[62]. It isn&#8217;t supposed to exist. It isn&#8217;t documented. It shouldn&#8217;t be accessible. But there is space for it in nibble 13 of ram[62]. And you can set and clear it using the &#8220;unused&#8221; codes bearing its name.<\/p>\n<p>However, it isn&#8217;t much use to us because we are missing the other instruction in the set &#8211; a &#8220;h F? 4&#8221; to allow us to choose a course of action that depends on it. That said, nibble 13 is the &#8220;sign bit&#8221; so it is possible that the microcode will behave differently if this (which should never be non-zero in real life) happens to be &#8220;1&#8221;. That&#8217;d require checking every use of ram[62] to see if any will do something different under those circumstances. <\/p>\n<p>Here&#8217;s a summary of the microcode for the 0x8e and 0x6e hex codes (h SF 4 and h CF 4) instructions:<\/p>\n<div class=\"codebox2\">\n<pre>\r\n; ***** h SF 4\r\n\r\n06266 jsb 06335              ; set s 12 if 0x6[a-f] or 0x8[a-f]\r\n06267 if 1 = s 12\r\n06270 then go to 07422\r\n07422 ...\r\n07423 jsb 07430              ; get ram[62], set P to flag nibble \r\n(07431 data register -&gt; c 14 ; ram[62] -&gt; C= 00000012220000)\r\n(07435 p + 1 -&gt; p ; P= 13)\r\n07424 load constant 1        ; C= 10000012220000 (=SF 4)\r\n07425 c -&gt; data register 14  ; c -&gt; ram[62] (=10000012220000)\r\n\r\n; ***** END\r\n\r\n; ***** h CF 4\r\n\r\n06040 ...\r\n07413 a + 1 -&gt; a[p]          ; A= 004fff35f6106f\r\n07414 if n\/c go to 07417\r\n07417 jsb 07430              ; set P to flag nibble (as above)\r\n; (ram[62] -&gt; C= 10000012220000 P= 13 A= 004fff35f61000)\r\n07420 load constant 0        ; C= 00000012220000 P= 12\r\n07421 if n\/c go to 07425\r\n07425 c -&gt; data register 14  ; c -&gt; ram[62] (=00000012220000)\r\n\r\n; ***** END\r\n<\/pre>\n<\/div>\n<p>The key microcode instructions are:<br \/>\n&#8220;07424 load constant 1 ; C= 10000012220000&#8221; and<br \/>\n&#8220;07420 load constant 0 ; C= 00000012220000&#8221;.<\/p>\n<p>When placed inside a set of<br \/>\n&#8220;07431 data register -&gt; c 14 ; ram[62] -&gt; C&#8221; and<br \/>\n&#8220;07425 c -&gt; data register 14 ; c -&gt; ram[62]&#8221;<br \/>\nthe flag is really getting set and cleared.<\/p>\n<p>P=13 is the starting point for working out which nibble holds which flag. Normally the codes for &#8220;h SF [0-3]&#8221; (0x8a &#8211; 0x8d) and &#8220;h CF [0-3]&#8221; (0x6a &#8211; 0x6d) result in P=[3-0]. Codes 0x8e and 0x6e exit the 07435-7437 loop early and leave P=13.<\/p>\n<p>You can see more detail of the h SF  4, h CF 4 process in <a href=\"http:\/\/www.sydneysmith.com\/products\/gss-hp67u\/downloads\/67-h-sf-4-cf-4.txt\" target=\"_blank\">67-h-sf-4-cf-4.txt<\/a>.<\/p>\n<p>You can find details about the missing codes and how to enter them in <a href=\"http:\/\/www.sydneysmith.com\/wordpress\/1262\/hp67-unused-program-codes\/\">HP67 Unused Program Codes<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>There are two unused codes in the HP-67 calculator that actually do things. These are &#8220;h SF 4&#8221; and &#8220;h CF 4&#8221;. Now, if you know the HP-67 calculator, you know it doesn&#8217;t have a &#8220;flag 4&#8221;. There are only flags 0-3 and you can set, test and clear these to your heart&#8217;s content. What&#8217;s &hellip; <a href=\"https:\/\/www.sydneysmith.com\/wordpress\/1299\/hp67-h-sf-4-and-h-cf-4\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">HP67 &#8211; h SF 4 and h CF 4<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[16,5,3],"tags":[33,32],"_links":{"self":[{"href":"https:\/\/www.sydneysmith.com\/wordpress\/wp-json\/wp\/v2\/posts\/1299"}],"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=1299"}],"version-history":[{"count":3,"href":"https:\/\/www.sydneysmith.com\/wordpress\/wp-json\/wp\/v2\/posts\/1299\/revisions"}],"predecessor-version":[{"id":1336,"href":"https:\/\/www.sydneysmith.com\/wordpress\/wp-json\/wp\/v2\/posts\/1299\/revisions\/1336"}],"wp:attachment":[{"href":"https:\/\/www.sydneysmith.com\/wordpress\/wp-json\/wp\/v2\/media?parent=1299"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sydneysmith.com\/wordpress\/wp-json\/wp\/v2\/categories?post=1299"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sydneysmith.com\/wordpress\/wp-json\/wp\/v2\/tags?post=1299"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}