lab17: part 5

This commit is contained in:
2026-04-23 01:24:04 -07:00
parent c11daa808f
commit 95bb649249
3 changed files with 51 additions and 6 deletions

View File

@@ -27,6 +27,17 @@ let opcodes = {
let value = vm.stack.pop();
vm.memory[offset] = value;
}},
0x56: { mnemonic: 'JUMP', evaluate: (vm) => {
let offset = vm.stack.pop();
vm.pc = offset;
}},
0x57: { mnemonic: 'JUMPI', evaluate: (vm) => {
let offset = vm.stack.pop();
let condition = vm.stack.pop();
if (condition) {
vm.pc = offset;
}
}},
0x5B: { mnemonic: 'JUMPDEST', evaluate: (vm) => {
// Does nothing. We could check to make sure that jumps
// always land at JUMPDEST opcodes, but it is not totally