Sort into table :D
authorAlyssa Rosenzweig <alyssa@backtick.town>
Wed, 22 Jun 2016 18:50:18 +0000 (11:50 -0700)
committerAlyssa Rosenzweig <alyssa@backtick.town>
Wed, 22 Jun 2016 18:50:18 +0000 (11:50 -0700)
src/CPU/parse-reference.js

index 309eecf..8c28820 100644 (file)
@@ -28,12 +28,21 @@ for(var i = 0; i < reference.length; ++i) {
 // remove car
 instructions = instructions.slice(1);
 
+// parse instructions individually
 var opcodes = [];
 for(var i = 0; i < instructions.length; ++i) {
     opcodes = opcodes.concat(parseInstruction(instructions[i]));
 }
 
-console.log(opcodes);
+// sort by opcode
+var table = [];
+for(var j = 0; j < 256; ++j) { table.push(null); }
+
+opcodes.forEach(function(opcode) {
+    table[opcode.opcode] = opcode;
+});
+
+console.log(table);
 
 function parseInstruction(instruction) {
     // get instruction name
This page took 0.024652 seconds and 4 git commands to generate.