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