Emit branches to stdout
authorAlyssa Rosenzweig <alyssa@backtick.town>
Thu, 23 Jun 2016 02:16:43 +0000 (19:16 -0700)
committerAlyssa Rosenzweig <alyssa@backtick.town>
Thu, 23 Jun 2016 02:16:43 +0000 (19:16 -0700)
src/CPU/branch-maker.js

index 211f2b3..6dd26a2 100644 (file)
@@ -14,3 +14,27 @@ var branches = {
     "V": ["BVC", "BVS"],
     "N": ["BPL", "BMI"]
 };
+
+function emit(name, flag, value) {
+    var emission = [];
+
+    // header
+    emission.push("BRANCH");
+    emission.push("mapper read PC+1");
+
+    // emission
+    var flagNum = value ? flag : "(1 - " + flag + ")";
+
+    emission.push(
+            "change PC by " +
+            flagNum +
+            " * (M + 256 * (<M < 128> - 1))"
+    );
+
+    console.log(emission.join("\n"));
+}
+
+for(var flag in branches) {
+    emit(branches[flag][0], flag, 0);
+    emit(branches[flag][1], flag, 0);
+}
This page took 0.02005 seconds and 4 git commands to generate.