diff options
author | sanine <sanine.not@pm.me> | 2023-05-22 23:56:50 -0500 |
---|---|---|
committer | sanine <sanine.not@pm.me> | 2023-05-22 23:56:50 -0500 |
commit | 6a4548df5e405adb080320080c67b7054b75bcaf (patch) | |
tree | e75502d7fde865d27a689a14794b023ad3bc88d0 /src/vm/instruction.js | |
parent | c1709249728cb9ad7011b0d39d18ad87d4636f4b (diff) |
implement MOV
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 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]; +} |