Code for the littler Buttons the Computer used in the Turing Machine portion of the book.
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.
 
buttons-computer/tests/basic_tests.js

17 lines
320 B

import { ButtonMachine } from "../src/buttons.js";
const cpu = new ButtonMachine([
["PUSH", 10],
["PUSH", 1],
["SUB"],
["JZ", 5],
["JUMP", 1],
["PUSH", 100],
["HALT"]
]);
cpu.run();
console.log("STACK TOP", cpu.stack_top);
console.log("REGISTER", cpu.register_entries);
console.log("STACK", cpu.stack);