From 70c42ab50d6eb78d0cc825d2d7f0b318398819ba Mon Sep 17 00:00:00 2001 From: sanine-a Date: Tue, 23 May 2023 12:20:41 -0500 Subject: implement JMZ --- src/vm/instruction.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/vm/instruction.js') diff --git a/src/vm/instruction.js b/src/vm/instruction.js index 878d20b..2afd3f7 100644 --- a/src/vm/instruction.js +++ b/src/vm/instruction.js @@ -107,3 +107,20 @@ exports.JMP = function(core, pc, ins) { const dstLoc = core.getLocation(pc, ins.a); return [dstLoc]; } + + +exports.JMZ = function(core, pc, ins) { + let test + if (ins.b.mode === AddrMode.Immediate) { + test = (ins.b.value === 0); + } else { + const src = core.getValue(pc, ins.b); + test = (src.b.value === 0); + } + + if (test) { + return [core.getLocation(pc, ins.a)]; + } else { + return [core.normalize(pc, 1)]; + } +} -- cgit v1.2.1