summaryrefslogtreecommitdiff
path: root/src/vm/instruction.js
diff options
context:
space:
mode:
authorsanine <sanine.not@pm.me>2023-05-23 00:29:12 -0500
committersanine <sanine.not@pm.me>2023-05-23 00:29:12 -0500
commitcf71a97881e170fa018bf5fd0f02cdb13b874af8 (patch)
tree02e4a2dbd495498543cce85fd040d0d468cc3df0 /src/vm/instruction.js
parent19a297f42a2f321ead4c03290d38a8ccdbf8dc18 (diff)
implement SUB
Diffstat (limited to 'src/vm/instruction.js')
-rw-r--r--src/vm/instruction.js15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/vm/instruction.js b/src/vm/instruction.js
index c9048e1..146a88b 100644
--- a/src/vm/instruction.js
+++ b/src/vm/instruction.js
@@ -37,3 +37,18 @@ exports.ADD = function(core, pc, ins) {
return [pc + 1];
}
+
+
+exports.SUB = 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];
+}