parent
17cbaa7455
commit
40da242bd7
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,26 @@ |
||||
{ |
||||
"name": "buttons-computer", |
||||
"version": "1.0.0", |
||||
"description": "A simple toy fantasty computer to learn about computer using javascript.", |
||||
"main": "src/index.js", |
||||
"type": "module", |
||||
"directories": { |
||||
"test": "tests" |
||||
}, |
||||
"scripts": { |
||||
"test": "ava test tests" |
||||
}, |
||||
"repository": { |
||||
"type": "git", |
||||
"url": "git@git.learnjsthehardway.com:learn-javascript-the-hard-way/buttons-computer" |
||||
}, |
||||
"keywords": [ |
||||
"javascript", |
||||
"fantasy-computer" |
||||
], |
||||
"author": "Zed A. Shaw", |
||||
"license": "AGPL-3.0-or-later", |
||||
"dependencies": { |
||||
"ava": "^4.2.0" |
||||
} |
||||
} |
@ -0,0 +1,7 @@ |
||||
PUSH 10 |
||||
PUSH 1 |
||||
SUB |
||||
JZ 5 |
||||
JUMP 1 |
||||
PUSH 100 |
||||
HALT |
@ -0,0 +1,17 @@ |
||||
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); |
Loading…
Reference in new issue