Fix TSX
authorAlyssa Rosenzweig <alyssa@backtick.town>
Thu, 23 Jun 2016 14:50:12 +0000 (07:50 -0700)
committerAlyssa Rosenzweig <alyssa@backtick.town>
Thu, 23 Jun 2016 14:50:12 +0000 (07:50 -0700)
src/CPU/build-transfer.js

index d348b94..53707ee 100644 (file)
@@ -1,4 +1,5 @@
 /* builds TAX-family instructions */
+/* note these get a little funky because of differences in encoding */
 
 var fs = require("fs");
 
@@ -7,9 +8,22 @@ list.forEach(emit);
 
 function emit(name) {
     var emission = [
-        "IMPLIED",
-        "set " + name[0] + " to " + name[1]
+        "IMPLIED"
     ];
 
+    if(name.indexOf("S") > -1) {
+        if(name[0] == "S") {
+            // transfer stack in
+            // encode it to hex
+            emission.push("set " + name[0] + "to item (" + name[1] + "+1) of hex");
+        } else {
+            // transfer stack out
+            // decode hex
+            emission.push("set " + name[0] + "to (join \"0x\" (" + name[1] + "))");
+        }
+    } else {
+        emission.push("set " + name[0] + " to " + name[1]);
+    }
+
     fs.writeFileSync("instructions/T" + name, emission.join("\n"));
 }
This page took 0.024214 seconds and 4 git commands to generate.