{"id":1398,"date":"2015-12-09T21:37:43","date_gmt":"2015-12-09T21:37:43","guid":{"rendered":"http:\/\/www.sydneysmith.com\/wordpress\/?p=1398"},"modified":"2017-05-14T00:44:58","modified_gmt":"2017-05-14T00:44:58","slug":"hp-65-key-press-routine","status":"publish","type":"post","link":"https:\/\/www.sydneysmith.com\/wordpress\/1398\/hp-65-key-press-routine\/","title":{"rendered":"HP-65 Key Press Routine"},"content":{"rendered":"<p>Here&#8217;s how we get from a key press to the HP-65 (or emulator) actually doing something &#8230; <!--more--><\/p>\n<p>The HP-65 key press routine is part of the wait loop. After all, that is the main thing it is waiting for.<\/p>\n<p>As you know, the wait loop starts at 00726. After a few instructions it gets to 00623 which checks the s0 flag to see if a key has been pressed. If not, it continues to 00452 and then through the rest of the loop. However, if s0 is 1 then we get to 00625 and start processing a key press.<\/p>\n<p>The first thing it does is wait a bit. 00625-00627 simply loops 16 times. It starts with P=12 and adds 1 each time until P gets back to 12.<\/p>\n<p>00630 clears the &#8220;a key has been pressed&#8221; flag (the s0 value that got us to here).<\/p>\n<p>00710 turns off the display and puts a 0 in a[0] as a starting point for what comes later.<\/p>\n<p>00715 puts us in the 01000 address space and causes us to execute a 01316 &#8220;key -&gt; rom&#8221; instruction just after that. In effect we now do a &#8220;switch statement&#8221; to 01000 + the scan code of the pressed key. See below:<\/p>\n<pre>\r\n00726 if s9 = 0\r\n00727 goto 00622\r\n00622 12 -&gt; p                            ; P= 12\r\n00623 if s0 = 0\r\n00624 goto 00452\r\n00625 p + 1 -&gt; p                         ; P= 13\r\n00626 if p # 12\r\n00627 goto 00625\r\n; P= 14, 15, 0, 1, 2, ..., 11\r\n00625 p + 1 -&gt; p                         ; P= 12\r\n00626 if p # 12\r\n00627 goto 00625\r\n00630 0 -&gt; s0                            ; S= ............\r\n00631 if s10 = 0\r\n00632 goto 00641\r\n00641 if s5 = 0\r\n00642 goto 00734\r\n00734 if s8 = 0\r\n00735 goto 00710\r\n00710 jsb 00675\r\n.00675 12 -&gt; p\r\n.00676 1 -&gt; f3\r\n.00677 dispoff\r\n.00700 c &lt;-&gt; m                           ; C= 00000000000221 M =00000000000000\r\n.00701 shiftl a[w]                       ; A= 00000000009990\r\n.00702 return\r\n00711 1 -&gt; f7\r\n00712 if s3 = 0\r\n00713 goto 00715\r\n00715 rom 2\r\n01316 key -&gt; rom\r\n<\/pre>\n<p>Where does it go next? See <a href=\"http:\/\/www.sydneysmith.com\/wordpress\/1383\/hp-65-program-code-jump-table\/\">HP-65 Program Code Jump Table<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Here&#8217;s how we get from a key press to the HP-65 (or emulator) actually doing something &#8230;<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[16,5,39],"tags":[37,32],"_links":{"self":[{"href":"https:\/\/www.sydneysmith.com\/wordpress\/wp-json\/wp\/v2\/posts\/1398"}],"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=1398"}],"version-history":[{"count":3,"href":"https:\/\/www.sydneysmith.com\/wordpress\/wp-json\/wp\/v2\/posts\/1398\/revisions"}],"predecessor-version":[{"id":1402,"href":"https:\/\/www.sydneysmith.com\/wordpress\/wp-json\/wp\/v2\/posts\/1398\/revisions\/1402"}],"wp:attachment":[{"href":"https:\/\/www.sydneysmith.com\/wordpress\/wp-json\/wp\/v2\/media?parent=1398"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sydneysmith.com\/wordpress\/wp-json\/wp\/v2\/categories?post=1398"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sydneysmith.com\/wordpress\/wp-json\/wp\/v2\/tags?post=1398"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}