From 6a4548df5e405adb080320080c67b7054b75bcaf Mon Sep 17 00:00:00 2001 From: sanine Date: Mon, 22 May 2023 23:56:50 -0500 Subject: implement MOV --- 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 ac4cd83..c991643 100644 --- a/src/vm/instruction.js +++ b/src/vm/instruction.js @@ -7,3 +7,18 @@ exports.DAT = function(core, pc, ins) { // do nothing and die return []; } + + +exports.MOV = 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 dstLocation = core.getLocation(pc, ins.b); + // hacky deep copy + core.data[dstLocation] = JSON.parse(JSON.stringify(src)); + } + + return [pc + 1]; +} -- cgit v1.2.1