diff options
author | sanine <sanine.not@pm.me> | 2023-05-23 00:23:41 -0500 |
---|---|---|
committer | sanine <sanine.not@pm.me> | 2023-05-23 00:23:41 -0500 |
commit | 19a297f42a2f321ead4c03290d38a8ccdbf8dc18 (patch) | |
tree | 0ecac73237caee2a0b5b2b7603fbe98636e634de /src/vm/instruction.js | |
parent | 6a4548df5e405adb080320080c67b7054b75bcaf (diff) |
test & fix indirection & predecrement
Diffstat (limited to 'src/vm/instruction.js')
-rw-r--r-- | src/vm/instruction.js | 15 |
1 files changed, 15 insertions, 0 deletions
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]; +} |