{"id":1142,"date":"2015-10-03T22:52:43","date_gmt":"2015-10-03T22:52:43","guid":{"rendered":"http:\/\/www.sydneysmith.com\/wordpress\/?p=1142"},"modified":"2017-05-14T01:49:58","modified_gmt":"2017-05-14T01:49:58","slug":"hp67-keypress-routine","status":"publish","type":"post","link":"https:\/\/www.sydneysmith.com\/wordpress\/1142\/hp67-keypress-routine\/","title":{"rendered":"The HP67 Keypress Routine"},"content":{"rendered":"<p>When the HP67 detects that a key has been pressed, it exits the <a href=\"http:\/\/www.sydneysmith.com\/wordpress\/1134\/the-hp67-keypress-wait-loop\/\">HP67 Keypress Wait Loop<\/a> and gets to instruction 0214 (octal). Then this happens: <!--more--><\/p>\n<pre>\r\n00214: display off\r\n00215: b exchange c[w]\r\n00216: CRC 400          ; sets a_key=true. tested by crc 500. maybe SF3 on keypress\r\n00217: keys to a        ; a[2]=scan row (a9134567) a[1]=scan col (43210, 3210 on 4 col rows)\r\n00220: 0 -&gt; c[x]\r\n00221: a exchange c[xs] ; c[xs]=scan row\r\n00222: shift right a[x] ; a[x] =scan col\r\n\r\n; a[x]= 5*scan_row + scan_col\r\n00223: p &lt;- 0\r\n00224: load constant 5\r\n00225: a + c -&gt; a[x]\r\n00226: c - 1 -&gt; c[xs]\r\n00227: if n\/c go to 0225\r\n00230: a - c -&gt; a[x]\r\n\r\n00231: shift left a[x]  ; result to a[2,1]\r\n00232: 0 -&gt; c[x]\r\n00233: p &lt;- 2\r\n00234: load constant 4\r\n00235: 0 -&gt; s 3\r\n00236: if 0 = s 4       ; if no prefix key\r\n00237: then go to 0254\r\n00254: m1 exch c\r\n\r\n; go to bank 0 rom 3 instruction nn (014nn), nn= octal(a[2,1])\r\n00255: delayed rom 03\r\n00256: a -&gt; rom address\r\n<\/pre>\n<p>Each rom contains 0400 addresses (Octal 0000-0377 = 2 bits + 3 bits + 3 bits = 8 bits = 256 in decimal).<\/p>\n<p>Rom 0 starts at address 00000.<br \/>\nRom 3 starts at address 0400+0400+0400 = 01400.<\/p>\n<p>The key scan codes and go to addresses are:<\/p>\n<p>\/\/ A B C D E<br \/>\n0xa4 (row=10, col=4, 5*10+4=54 =6*8+6 = 066) addr=01466<br \/>\n0xa3 (row=10, col=3, 5*10+3=53 =6*8+5 = 065) addr=01465<br \/>\n0xa2 (r=10 c=2 so 52, =6*8+4 = 064) addr=01464<br \/>\n0xa1 (r=10 c=1 so 51, =6*8+3 = 063) addr=01463<br \/>\n0xa0 (r=10 c=0 so 50, =6*8+2 = 062) addr=01462<\/p>\n<p>\/\/ SUM GTO DSP (i) SST<br \/>\n0x94 (r=9 c=4 so &#8220;n&#8221;=45+4=49 =6*8+1 = 061) addr=01461<br \/>\n0x93 (r=9 c=3 n=48 =6*8+0 = 060) addr=01460<br \/>\n0x92 (r=9 c=2 n=47 =5*8+7 = 057) addr=01457<br \/>\n0x91 (9,1,46 =5*8+6 =056) 01456<br \/>\n0x90 (9,0,45 =5*8+5 =055) 01455<\/p>\n<p>\/\/ f g STO RCL h<br \/>\n0x14 (1,4,9 =1*8+1 =011) 01411<br \/>\n0x13 (1,3,8 =1*8+0 =010) 01410<br \/>\n0x12 (1,2,7 =0*8+7 =007) 01407<br \/>\n0x11 (1,1,6 =0*8+6 =006) 01406<br \/>\n0x10 (1,0,5 =0*8+5 =005) 01405<\/p>\n<p>\/\/ ENTER CHS EEX CLX<br \/>\n0x33 (,,18 =2*8+2 =022) 01422<br \/>\n0x32 (,,17 =2*8+1 =021) 01421<br \/>\n0x31 (,,16 =2*8+0 =020) 01420<br \/>\n0x30 (,,15 =1*8+7 =017) 01417<\/p>\n<p>\/\/ &#8211; 7 8 9<br \/>\n0x43 (23 027) 01427<br \/>\n0x42 (22 026) 01426<br \/>\n0x41 (21 025) 01425<br \/>\n0x40 (20 024) 01424<\/p>\n<p>\/\/ + 4 5 6<br \/>\n0x53 (28 034) 01434<br \/>\n0x52 (27 033) 01433<br \/>\n0x51 (26 032) 01432<br \/>\n0x50 (25 031) 01431<\/p>\n<p>\/\/ * 1 2 3<br \/>\n0x63 (33 041) 01441<br \/>\n0x62 (32 040) 01440<br \/>\n0x61 (31 037) 01437<br \/>\n0x60 (30 036) 01436<\/p>\n<p>\/\/ \/ 0 . R\/S<br \/>\n0x73 (38 046) 01446<br \/>\n0x72 (37 045) 01445<br \/>\n0x71 (36 044) 01444<br \/>\n0x70 (35 043) 01443<\/p>\n<p>If you&#8217;ve pressed a prefix key ([f], [g] or [h]) then it ends up running instructions to go to rom1 (004nn) instead of to rom3 (014nn).<\/p>\n<p>If also adds 4 to a[2] a number of times depending on whether [f], [g] or [h] was pressed. This is equivalent to adding 0100 octal each time so you get:<\/p>\n<p>normal to 01400 + 5*r+c<br \/>\nf, key to 00400 + 3*0100 =00700, + 5*r+c<br \/>\ng, key to 00400 + 2*0100 =00600, + 5*r+c<br \/>\nh, key to 00400 + 1*0100 =00500, + 5*r+c<\/p>\n<p>[h] [3] (ie h REG) would go to 00500 + 036 = 00536<\/p>\n","protected":false},"excerpt":{"rendered":"<p>When the HP67 detects that a key has been pressed, it exits the HP67 Keypress Wait Loop and gets to instruction 0214 (octal). Then this 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,3],"tags":[30,33,32],"_links":{"self":[{"href":"https:\/\/www.sydneysmith.com\/wordpress\/wp-json\/wp\/v2\/posts\/1142"}],"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=1142"}],"version-history":[{"count":11,"href":"https:\/\/www.sydneysmith.com\/wordpress\/wp-json\/wp\/v2\/posts\/1142\/revisions"}],"predecessor-version":[{"id":1358,"href":"https:\/\/www.sydneysmith.com\/wordpress\/wp-json\/wp\/v2\/posts\/1142\/revisions\/1358"}],"wp:attachment":[{"href":"https:\/\/www.sydneysmith.com\/wordpress\/wp-json\/wp\/v2\/media?parent=1142"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sydneysmith.com\/wordpress\/wp-json\/wp\/v2\/categories?post=1142"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sydneysmith.com\/wordpress\/wp-json\/wp\/v2\/tags?post=1142"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}