From 19a297f42a2f321ead4c03290d38a8ccdbf8dc18 Mon Sep 17 00:00:00 2001 From: sanine Date: Tue, 23 May 2023 00:23:41 -0500 Subject: test & fix indirection & predecrement --- src/vm/instruction.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/vm/instruction.js') diff --git a/src/vm/instruction.js b/src/vm/instruction.js index c991643..c9048e1 100644 --- a/src/vm/instruction.js +++ b/src/vm/instruction.js @@ -22,3 +22,18 @@ exports.MOV = function(core, pc, ins) { return [pc + 1]; } + + +exports.ADD = function(core, pc, ins) { + if (ins.a.mode === AddrMode.Immediate) { + const dst = core.getValue(pc, ins.b); + dst.b.value += ins.a.value; + } else { + const src = core.getValue(pc, ins.a); + const dst = core.getValue(pc, ins.b); + dst.a.value += src.a.value; + dst.b.value += src.b.value; + } + + return [pc + 1]; +} -- cgit v1.2.1