Begin parsing reference
authorAlyssa Rosenzweig <alyssa@backtick.town>
Wed, 22 Jun 2016 18:05:20 +0000 (11:05 -0700)
committerAlyssa Rosenzweig <alyssa@backtick.town>
Wed, 22 Jun 2016 18:05:20 +0000 (11:05 -0700)
src/CPU/parse-reference.js [new file with mode: 0644]

diff --git a/src/CPU/parse-reference.js b/src/CPU/parse-reference.js
new file mode 100644 (file)
index 0000000..2d613f6
--- /dev/null
@@ -0,0 +1,34 @@
+/**
+ * parse-reference.js
+ * argv[2] is a text-only 6502 reference sheet
+ */
+
+var fs = require("fs");
+
+var reference = fs.readFileSync(process.argv[2])
+                  .toString()
+                  .split("\n");
+
+// an instruction is delimited by a character on column 0
+// split into instructions
+
+var instructions = [[]];
+var temp = 0;
+
+for(var i = 0; i < reference.length; ++i) {
+    if(reference[i].length == 0 || reference[i][0] == " ") {
+        instructions[temp].push(reference[i]);
+    } else {
+        instructions.push([reference[i]]);
+        ++temp;
+    }
+}
+
+// remove car
+instructions = instructions.slice(1);
+
+console.log(instructions.map(parseInstruction));
+
+function parseInstruction(instruction) {
+    return instruction; // stub
+}
This page took 0.023844 seconds and 4 git commands to generate.