diff options
author | sanine-a <sanine.not@pm.me> | 2023-05-23 12:26:50 -0500 |
---|---|---|
committer | sanine-a <sanine.not@pm.me> | 2023-05-23 12:26:50 -0500 |
commit | 86793f0afd74092be507325a40d85bc62bd47597 (patch) | |
tree | 98d7b2cbf32e45032dd7cfbf524d7b4d875dbcc1 /src/vm/instruction.js | |
parent | 70c42ab50d6eb78d0cc825d2d7f0b318398819ba (diff) |
implement JMN
Diffstat (limited to 'src/vm/instruction.js')
-rw-r--r-- | src/vm/instruction.js | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/vm/instruction.js b/src/vm/instruction.js index 2afd3f7..f323f84 100644 --- a/src/vm/instruction.js +++ b/src/vm/instruction.js @@ -124,3 +124,21 @@ exports.JMZ = function(core, pc, ins) { return [core.normalize(pc, 1)]; } } + + +exports.JMN = 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)]; + } +} |