parent
40da242bd7
commit
2902842fcc
@ -1,17 +1,25 @@ |
|||||||
import { ButtonMachine } from "../src/buttons.js"; |
import { ButtonMachine } from '../src/buttons.js'; |
||||||
|
|
||||||
const cpu = new ButtonMachine([ |
let code = [ |
||||||
["PUSH", 10], |
['PUSH', -10], // start at -10
|
||||||
["PUSH", 1], |
['PUSH', 1], // increment by 1
|
||||||
["SUB"], |
['ADD'], |
||||||
["JZ", 5], |
['POKE', 1], // put it in ram, IX++
|
||||||
["JUMP", 1], |
['JNZ', 1], // the previous test fails so it jumps to loop again
|
||||||
["PUSH", 100], |
['STOR', 'IX'], |
||||||
["HALT"] |
['POP'], |
||||||
]); |
['PEEK', 1], |
||||||
|
['JNZ', 6], |
||||||
|
]; |
||||||
|
|
||||||
cpu.run(); |
let machine = new ButtonMachine(code); |
||||||
|
|
||||||
console.log("STACK TOP", cpu.stack_top); |
const ops = ButtonMachine.operations(); |
||||||
console.log("REGISTER", cpu.register_entries); |
const registers = ButtonMachine.register_names(); |
||||||
console.log("STACK", cpu.stack); |
|
||||||
|
machine.run(); |
||||||
|
|
||||||
|
console.log("STACK TOP", machine.stack_top); |
||||||
|
console.log("REGISTER", machine.register_entries); |
||||||
|
console.log("STACK", machine.stack); |
||||||
|
console.log("RAM", machine.ram); |
||||||
|
Loading…
Reference in new issue