INC-family
authorAlyssa Rosenzweig <alyssa@backtick.town>
Thu, 23 Jun 2016 03:56:00 +0000 (20:56 -0700)
committerAlyssa Rosenzweig <alyssa@backtick.town>
Thu, 23 Jun 2016 03:56:00 +0000 (20:56 -0700)
src/CPU/build-crement.js [new file with mode: 0644]

diff --git a/src/CPU/build-crement.js b/src/CPU/build-crement.js
new file mode 100644 (file)
index 0000000..580cc6c
--- /dev/null
@@ -0,0 +1,28 @@
+/* INC style instructions */
+
+var fs = require("fs");
+
+var registers = {
+    "M": ["INC", "DEC"],
+    "X": ["INX", "DEX"],
+    "Y": ["INY", "DEY"]
+};
+
+for(var reg in registers) {
+    emit(reg, registers[reg][0], 0);
+    emit(reg, registers[reg][1], 1);
+}
+
+function emit(register, name, value) {
+    var emission = [];
+
+    if(register == "M") {
+        emission.push("RW, N, Z");
+        emission.push("set OP to OP " + (value ? "-" : "+") + " 1");
+    } else {
+        emission.push("IMPLIED");
+        emission.push("change " + register + " by " + (value ? "-1" : "1"));
+    }
+
+    fs.writeFileSync("instructions/" + name, emission.join("\n"));
+}
This page took 0.027422 seconds and 4 git commands to generate.