Negative and zero flag handling
authorAlyssa Rosenzweig <alyssa@backtick.town>
Thu, 23 Jun 2016 17:40:49 +0000 (10:40 -0700)
committerAlyssa Rosenzweig <alyssa@backtick.town>
Thu, 23 Jun 2016 17:40:49 +0000 (10:40 -0700)
src/CPU/build-cpu.js

index e766434..2658c60 100644 (file)
@@ -56,7 +56,7 @@ var sources = table.map(function(x, i) {
             else if(flag == "Z") zeroQ = true;
             else if(["R", "RW", "IMPLIED", "RAW", "BRANCH"].indexOf(flag) > -1)
                 mode = flag;
-            else if (["A", "X", "Y", "tmp"].indexOf(flag) > -1)
+            else if (["A", "X", "Y", "tmp", "OP"].indexOf(flag) > -1)
                 operand = flag;
             else
                 console.error("Unknown flag " + flag + " for instruction " + x.name);
@@ -93,6 +93,14 @@ var sources = table.map(function(x, i) {
         // add the actual code of the instruction
         instruction = instruction.concat(ins);
 
+        if(negQ) {
+            instruction.push("set flagN to <" + operand + " > 127>");
+        }
+
+        if(zeroQ) {
+            instruction.push("set flagZ to <" + operand + " = 0>");
+        }
+
         instruction = instruction.concat([
             'say "' + x.assembler + '" for 2 secs',
             'change PC by ' + x.size
This page took 0.02428 seconds and 4 git commands to generate.