You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
617 B
24 lines
617 B
2 years ago
|
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);
|