Fully parse out each form
authorAlyssa Rosenzweig <alyssa@backtick.town>
Wed, 22 Jun 2016 18:42:26 +0000 (11:42 -0700)
committerAlyssa Rosenzweig <alyssa@backtick.town>
Wed, 22 Jun 2016 18:42:26 +0000 (11:42 -0700)
src/CPU/parse-reference.js

index a894675..cbf3f16 100644 (file)
@@ -30,8 +30,6 @@ instructions = instructions.slice(1);
 
 console.log(instructions.map(parseInstruction));
 
-var bar = '     --------------------------------------------';
-
 function parseInstruction(instruction) {
     // get instruction name
     var name = instruction[0].split(" ")[0];
@@ -42,21 +40,22 @@ function parseInstruction(instruction) {
     });
 
     var forms = instruction.slice(nums + 1, -2).map(function(form) {
-        return [
-                form.slice(6-1, 20-1),
-                form.slice(20-1, 34-1),
-                form.slice(34-1, 40-1),
-                form.slice(40-1, 46-1),
-                form.slice(46-1)
-            ].map(function(x) { return x.trim(); });
-    });
+        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 size = form.slice(40-1, 46-1) * 1;
+        var cycles = form.slice(46-1) * 1;
 
-    console.log(forms);
+        return {
+            "name": name,
+            "addressing": addressing,
+            "size": size,
+            "opcode": opcode,
+            "cycles": cycles
+        };
+    });
 
-    return {
-        "name": name,
-        "forms": forms
-    };
+    return forms;
 }
 
 function PolyFill() {
This page took 0.031204 seconds and 4 git commands to generate.