{"id":1439,"date":"2017-05-28T10:59:55","date_gmt":"2017-05-28T14:59:55","guid":{"rendered":"http:\/\/www.paleotechnologist.net\/?p=1439"},"modified":"2017-05-28T10:59:55","modified_gmt":"2017-05-28T14:59:55","slug":"programming-the-dracoz80","status":"publish","type":"post","link":"https:\/\/www.paleotechnologist.net\/?p=1439","title":{"rendered":"Programming the DrACo\/Z80"},"content":{"rendered":"<p>Here are instructions on how to program the 8-bit, program counter, breadboard variant of the DrACo\/Z80 computer.<\/p>\n<ul>\n<li><strong><strong><strong><strong>Set the clock to automatic \/ oscillator mode (so the clock is running)<\/strong><\/strong><\/strong><\/strong>&nbsp;<\/li>\n<li><strong><strong><strong>Set Program\/Run to Program (~BUSRQ low)<\/strong><\/strong><\/strong>\n<ul>\n<li>The address should now be controlled by the counter chip.<\/li>\n<\/ul>\n<\/li>\n<li><strong><strong><strong>Enter in the program, one byte at a time:<\/strong><\/strong><\/strong>\n<ul>\n<li>Wait for the BUSAK LED to light<\/li>\n<\/ul>\n<ul>\n<li>Click Up (blue) or Down (green) until you reach the address you want to program. (The buttons\u00a0can be flaky, but you&#8217;ll get there eventually.)<\/li>\n<\/ul>\n<ul>\n<li><span style=\"color: #000000;\">Set the logic switches to the data byte to be written<\/span><\/li>\n<li><span style=\"color: #000000;\">Press Write (white button).<\/span><\/li>\n<li><span style=\"color: #000000;\">Click Up or Down to move to the next address<\/span><\/li>\n<\/ul>\n<ul>\n<li><span style=\"color: #000000;\">Continue until the program has been entered<br \/>\n<\/span><\/li>\n<\/ul>\n<\/li>\n<li><strong><strong>When the program is entered, run it:<\/strong><\/strong>\n<ul>\n<li>Press and hold Reset<\/li>\n<\/ul>\n<ul>\n<li>While holding Reset, switch to Run mode<\/li>\n<li>Wait for the BUSAK LED to go out<\/li>\n<li>Continue to hold down Reset for the length of 15-20 clock cycles<\/li>\n<li>If you want to step through the program, switch the clock to Manual. To have it run automatically, leave the clock in Automatic<\/li>\n<li>Release Reset<\/li>\n<\/ul>\n<ul>\n<li>If stepping through the program, press STEP repeatedly<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p><strong>Remember to start your programs with a NOP (0x00) in address 0x00. (This is because address 00 is sometimes overwritten when running a program. Extra credit for anyone who can help me track down that particular bug, for sure!)<\/strong><\/p>\n<p>A note on the Z80&#8217;s memory refresh sequence:<\/p>\n<p>After execution of each instruction, the Z80 will perform a refresh sequence, where it will call on the next memory location in the refresh sequence. It uses an overflowing 7-bit counter for this (yes, really), so it counts up from 0x00 to 0x7F before resuming at 0x00.<\/p>\n<p>Suppose you entered the following program:<\/p>\n<p>Address \u00a0Data \u00a0 Instruction<br \/>\n&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br \/>\n00 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 00 \u00a0 \u00a0 \u00a0NOP<br \/>\n01 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0C3 \u00a0 \u00a0 \u00a0JMP<br \/>\n02 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 00 \u00a0 \u00a0 \u00a000<br \/>\n03 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 00 \u00a0 \u00a0 \u00a000<\/p>\n<p>You would see the following sequence of addresses accessed:<br \/>\n00 (NOP)<br \/>\n00 (refresh)<br \/>\n01 (jmp)<br \/>\n02 (00) (part of jmp)<br \/>\n03 (00) (part of jmp)<br \/>\n01 (refresh)<br \/>\n00 (NOP)<br \/>\n02 (refresh)<br \/>\n01 (jmp)<br \/>\n02 (00) (part of jmp)<br \/>\n03 (00) (part of jmp)<br \/>\n03 (refresh)<br \/>\n00 (NOP)<\/p>\n<p>All seems more or less correct at this point, but then you might notice numbers appearing outside your code location:<\/p>\n<p>04 (refresh)<br \/>\n01 (jmp)<br \/>\n02 (00)<br \/>\n03 (00)<br \/>\n05 (refresh)<br \/>\n00 (NOP)<br \/>\n06 (refresh)<\/p>\n<p>It looks like your program is running away &#8212; but it&#8217;s just the refresh cycle doing its thing. Watch it run for a few cycles until you see the 00 C3 00 00 interspersed with the 00 01 02 03 04 05 etc.<\/p>\n<p>With the static RAM chips we use, we don&#8217;t actually need all this refresh silliness &#8212; but it&#8217;s baked in to the Z80 and can&#8217;t be disabled. Modern PC hardware does include refresh functionality, but it&#8217;s essentially abstracted away at this point, from a programmer&#8217;s perspective.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Instructions on how to program the DrACo\/Z80, including dealing with the weird Z80 quirks&#8230; <a href=\"https:\/\/www.paleotechnologist.net\/?p=1439\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_exactmetrics_skip_tracking":false,"footnotes":""},"categories":[263,216,210,221,220,400,238,226],"tags":[],"class_list":["post-1439","post","type-post","status-publish","format-standard","hentry","category-assembly","category-coding","category-digital","category-dracoz80","category-drexel","category-eet325","category-electronics","category-how-to"],"_links":{"self":[{"href":"https:\/\/www.paleotechnologist.net\/index.php?rest_route=\/wp\/v2\/posts\/1439","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.paleotechnologist.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.paleotechnologist.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.paleotechnologist.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.paleotechnologist.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1439"}],"version-history":[{"count":10,"href":"https:\/\/www.paleotechnologist.net\/index.php?rest_route=\/wp\/v2\/posts\/1439\/revisions"}],"predecessor-version":[{"id":4064,"href":"https:\/\/www.paleotechnologist.net\/index.php?rest_route=\/wp\/v2\/posts\/1439\/revisions\/4064"}],"wp:attachment":[{"href":"https:\/\/www.paleotechnologist.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1439"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.paleotechnologist.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1439"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.paleotechnologist.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1439"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}