{"id":1391,"date":"2020-05-10T21:23:36","date_gmt":"2020-05-10T19:23:36","guid":{"rendered":"https:\/\/www.pagetable.com\/?p=1391"},"modified":"2020-05-10T21:23:36","modified_gmt":"2020-05-10T19:23:36","slug":"typos-in-the-c64-programmers-reference-guide-c3po-or-c3p0","status":"publish","type":"post","link":"https:\/\/www.pagetable.com\/?p=1391","title":{"rendered":"Typos in the C64 Programmer&#039;s Reference Guide: C3PO or C3P0?"},"content":{"rendered":"<p>The <a href=\"https:\/\/archive.org\/details\/c64-programmer-ref\/\">Commodore 64 Programmer&rsquo;s Reference Guide<\/a> contains a memory map with a complete description of the zeropage and system variables used by KERNAL and BASIC, but now that we have the <a href=\"https:\/\/github.com\/mist64\/cbmsrc\">original source<\/a>, we know there are three typos in this table.<\/p>\n<h2 id=\"c3p0\">C3P0<\/h2>\n<p>The first one is the symbol at address $94. Here is the full page from the Programmer&rsquo;s Reference Guide:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"docs\/prg_typos\/prg-04.png\" height=\"726\" width=\"423\" alt=\"\" \/><\/p>\n<p>If you look closely, the symbol at $94 is <code>C3PO<\/code>, with a capital Oh.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"docs\/prg_typos\/c3p0-prg.png\" height=\"86\" width=\"180\" alt=\"\" \/><\/p>\n<p>But it should end in a zero. Here is the original source:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"docs\/prg_typos\/c3p0-src.png\" height=\"45\" width=\"366\" alt=\"\" \/><\/p>\n<p>This is a <a href=\"https:\/\/www.pagetable.com\/docs\/C64_KERNAL_03_LST.pdf\">printout of the original assembly log from 1983<\/a>:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"docs\/prg_typos\/c3p0-lst.png\" height=\"30\" width=\"404\" alt=\"\" \/><\/p>\n<p>On the kind of printer Commodore was using, there is no way to tell a <code>0<\/code> from an <code>O<\/code>. Here is the whole page for context:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"docs\/prg_typos\/kernal-001.png\" height=\"566\" width=\"400\" alt=\"\" \/><\/p>\n<p>The <a href=\"https:\/\/www.pagetable.com\/?p=1135\">Commodore Serial Bus<\/a> library uses <code>C3P0<\/code> to buffer a byte that is supposed to be sent to the bus &#8211; similar to the zero page location <code>R2D2<\/code> located at address $A3. Here is <a href=\"https:\/\/www.pagetable.com\/c64disasm\/#ED16\">some code<\/a> that uses the two:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"docs\/prg_typos\/c3p0-r2d2.png\" height=\"205\" width=\"337\" alt=\"\" \/><\/p>\n<p>So yes, the two symbol names are references to the Star Wars characters C-3PO and R2-D2. It is unknown why the former is spelled with a zero in the source, but the typo in the Programmer&rsquo;s Reference Guide is very forgivable.<\/p>\n<p>Disappointingly, the <code>R2D2<\/code> symbol is not mentioned in the Programmer&rsquo;s Reference Guide &#8211; $A3 is just part of a &ldquo;Temp Data Area&rdquo;:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"docs\/prg_typos\/a3.png\" height=\"17\" width=\"422\" alt=\"\" \/><\/p>\n<h2 id=\"bufpt\">BUFPT<\/h2>\n<p>The next typo is the symbol at address $A6, the tape buffer pointer:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"docs\/prg_typos\/bufpt-prg.png\" height=\"18\" width=\"423\" alt=\"\" \/><\/p>\n<p>The Reference Guide calls it <code>BUFPNT<\/code>, but it is in fact called <code>BUFPT<\/code>.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"docs\/prg_typos\/bufpt-lst.png\" height=\"14\" width=\"562\" alt=\"\" \/><\/p>\n<h2 id=\"lsxp\">LSXP<\/h2>\n<p>And the final typo is the symbol at $C9:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"docs\/prg_typos\/lsxp-prg.png\" height=\"32\" width=\"420\" alt=\"\" \/><\/p>\n<p>The correct spelling is <code>LSXP<\/code>:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"docs\/prg_typos\/lsxp-lst.png\" height=\"29\" width=\"484\" alt=\"\" \/><\/p>\n<p>In fact, in the source, the two bytes have individual labels, <code>LSXP<\/code> and <code>LSTP<\/code>. <code>LSXP<\/code> is the cursor line, and <code>LSTP<\/code> the cursor column in the context of inputting text, shadowing the zero page addresses <code>TBLX<\/code> (line) and <code>PNTR<\/code> (column). The following table summarizes this:<\/p>\n<table>\n<thead>\n<tr>\n<th>        <\/th>\n<th> Generic <\/th>\n<th> Input  <\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td> Column <\/td>\n<td> <code>PNTR<\/code>  <\/td>\n<td> <code>LSTP<\/code> <\/td>\n<\/tr>\n<tr>\n<td> Line   <\/td>\n<td> <code>TBLX<\/code>  <\/td>\n<td> <code>LSXP<\/code> <\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>It is confusing that the symbols for the Y coordinates each contain an <code>X<\/code>. It is unclear what these symbol names are supposed to mean in the first place &#8211; if you have any idea, please share them in the comments!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The Commodore 64 Programmer&rsquo;s Reference Guide contains a memory map with a complete description of the zeropage and system variables used by KERNAL and BASIC, but now that we have the original source, we know there are three typos in this table. C3P0 The first one is the symbol at address $94. Here is the &#8230; <a title=\"Typos in the C64 Programmer&#039;s Reference Guide: C3PO or C3P0?\" class=\"read-more\" href=\"https:\/\/www.pagetable.com\/?p=1391\" aria-label=\"Read more about Typos in the C64 Programmer&#039;s Reference Guide: C3PO or C3P0?\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,5,41,8,19],"tags":[],"class_list":["post-1391","post","type-post","status-publish","format-standard","hentry","category-2","category-archeology","category-c64","category-commodore","category-kernal"],"_links":{"self":[{"href":"https:\/\/www.pagetable.com\/index.php?rest_route=\/wp\/v2\/posts\/1391","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.pagetable.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.pagetable.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.pagetable.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.pagetable.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1391"}],"version-history":[{"count":0,"href":"https:\/\/www.pagetable.com\/index.php?rest_route=\/wp\/v2\/posts\/1391\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.pagetable.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1391"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.pagetable.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1391"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.pagetable.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1391"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}