Skip to content

Instantly share code, notes, and snippets.

@chickencoder
Created October 2, 2015 21:09
Show Gist options
  • Save chickencoder/a22ef3abb46968a240a9 to your computer and use it in GitHub Desktop.
Save chickencoder/a22ef3abb46968a240a9 to your computer and use it in GitHub Desktop.
"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