From 2880c1565102d8a969846c5e68300ced88066943 Mon Sep 17 00:00:00 2001 From: sanine Date: Tue, 23 May 2023 10:08:35 -0500 Subject: implement SLT --- 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 df5369d..a79427b 100644 --- a/src/vm/instruction.js +++ b/src/vm/instruction.js @@ -81,3 +81,23 @@ exports.CMP = function(core, pc, ins) { } } } + + +exports.SLT = function(core, pc, ins) { + if (ins.a.mode === AddrMode.Immediate) { + const test = core.getValue(pc, ins.b); + if (ins.a.value < test.b.value) { + return [pc + 2]; + } else { + return [pc + 1]; + } + } else { + const left = core.getValue(pc, ins.a); + const right = core.getValue(pc, ins.b); + if (left.b.value < right.b.value) { + return [pc + 2]; + } else { + return [pc + 1]; + } + } +} -- cgit v1.2.1