parent
1c655b9b53
commit
c905af1214
@ -0,0 +1,23 @@ |
||||
import { ButtonMachine } from '../src/buttons.js'; |
||||
import fs from "fs"; |
||||
import assert from "assert"; |
||||
|
||||
let machine = new ButtonMachine(); |
||||
|
||||
const ops = ButtonMachine.operations(); |
||||
const registers = machine.register_names(); |
||||
|
||||
assert(process.argv[2] !== undefined, "USAGE: runner.js [source.btn]"); |
||||
|
||||
const source = fs.readFileSync(process.argv[2]); |
||||
|
||||
const code = machine.parse(source.toString()); |
||||
console.log("CODE", code); |
||||
|
||||
machine.load(code); |
||||
machine.run(); |
||||
|
||||
console.log("STACK TOP", machine.stack_top); |
||||
console.log("REGISTERS", machine.registers); |
||||
console.log("STACK", machine.stack); |
||||
console.log("RAM", machine.ram); |
@ -1,7 +1,6 @@ |
||||
PUSH 10 |
||||
PUSH 1 |
||||
SUB |
||||
JZ 5 |
||||
ADD |
||||
JZ 6 |
||||
JUMP 1 |
||||
PUSH 100 |
||||
HALT |
||||
|
Loading…
Reference in new issue