Flatten; simplify opcodes
authorAlyssa Rosenzweig <alyssa@backtick.town>
Wed, 22 Jun 2016 18:46:00 +0000 (11:46 -0700)
committerAlyssa Rosenzweig <alyssa@backtick.town>
Wed, 22 Jun 2016 18:46:00 +0000 (11:46 -0700)
src/CPU/parse-reference.js

index cbf3f16..309eecf 100644 (file)
@@ -28,7 +28,12 @@ for(var i = 0; i < reference.length; ++i) {
 // remove car
 instructions = instructions.slice(1);
 
-console.log(instructions.map(parseInstruction));
+var opcodes = [];
+for(var i = 0; i < instructions.length; ++i) {
+    opcodes = opcodes.concat(parseInstruction(instructions[i]));
+}
+
+console.log(opcodes);
 
 function parseInstruction(instruction) {
     // get instruction name
@@ -42,9 +47,9 @@ function parseInstruction(instruction) {
     var forms = instruction.slice(nums + 1, -2).map(function(form) {
         var addressing = form.slice(6-1, 20-1).trim();
         var assembler = form.slice(20-1, 34-1).trim();
-        var opcode = form.slice(34-1, 40-1).trim();
+        var opcode = ("0x" + form.slice(34-1, 40-1).trim()) * 1;
         var size = form.slice(40-1, 46-1) * 1;
-        var cycles = form.slice(46-1) * 1;
+        var cycles = form.slice(46-1).trim();
 
         return {
             "name": name,
This page took 0.024973 seconds and 4 git commands to generate.