'use strict'; const { AddrMode } = require('./enum.js'); 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]; } 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]; }