From 4d5377870ee554036ac9aab570ac2bc809fc88bd Mon Sep 17 00:00:00 2001 From: sanine-a Date: Tue, 23 May 2023 12:33:39 -0500 Subject: implement DJN --- src/vm/instruction.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src/vm/instruction.js') diff --git a/src/vm/instruction.js b/src/vm/instruction.js index f323f84..c235b9a 100644 --- a/src/vm/instruction.js +++ b/src/vm/instruction.js @@ -142,3 +142,23 @@ exports.JMN = function(core, pc, ins) { return [core.normalize(pc, 1)]; } } + + +exports.DJN = function(core, pc, ins) { + let test; + + if (ins.b.mode === AddrMode.Immediate) { + ins.b.value -= 1; + test = (ins.b.value !== 0); + } else { + const src = core.getValue(pc, ins.b); + src.b.value -= 1; + test = (src.b.value !== 0); + } + + if (test) { + return [core.getLocation(pc, ins.a)]; + } else { + return [core.normalize(pc, 1)]; + } +} -- cgit v1.2.1