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

26 lines
508 B

import { ButtonMachine } from '../src/buttons.js';
let code = [
['PUSH', -10],
['PUSH', 1],
['ADD'],
['POKE', 1],
['JNZ', 1],
['STOR', 'IX'],
['POP'],
['PEEK', 1],
['JNZ', 6],
];
let machine = new ButtonMachine();
machine.load(code);
const ops = ButtonMachine.operations();
const registers = machine.register_names();
machine.run();
console.log("STACK TOP", machine.stack_top);
console.log("REGISTERS", registers);
console.log("STACK", machine.stack);
console.log("RAM", machine.ram);