Created
October 2, 2015 21:09
-
-
Save chickencoder/a22ef3abb46968a240a9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict" | |
/** | |
HLT - 0000 | |
*/ | |
let accumulator = 0 | |
let halt = false | |
let decode = (instruction) => { | |
const operator = instruction.slice(2) | |
const operand = Math.floor(instruction / 16) | |
return [operator, operand]; | |
} | |
let execute = (operator, operand) => { | |
if (operator == "00") { | |
halt = true; | |
} | |
} | |
let run = () => { | |
const insts = ["0000", ""] | |
let line = 0 | |
while (halt != false) { | |
let instruction = insts[line] | |
let operator, operand = decode(instruction)[0], decode(instruction)[1] | |
execute(operator, operand) | |
line += 1 | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment