public override void run(ref Register[] reg, ref Memory RAM) { //base.run(ref reg, ref RAM); Logger.Instance.writeLog(string.Format("CMD: Data Movement : 0x{0}", Convert.ToString(this.originalBits, 16))); //from register info to memory!!! // ---> uint RdValue = reg[this.rd].ReadWord(0, true); uint RnValue = reg[this.rn].ReadWord(0, true); uint RmValue = reg[this.rm].ReadWord(0, true); this.shiftOp = loadStoreShift(this.R, this.shiftOp, RmValue, reg); //addressing mode uint addr = figureOutAddressing(ref reg); string cmd = ""; if (this.L) { cmd = "ldr"; if (this.B) { byte inpu = RAM.ReadByte(addr); //clear it out first reg[this.rd].WriteWord(0, 0); reg[this.rd].WriteByte(0, inpu); } else { uint inpu = RAM.ReadWord(addr); reg[this.rd].WriteWord(0, inpu); } } else { cmd = "str"; if (this.B) { byte inpu = reg[this.rd].ReadByte(0); RAM.WriteByte(addr, inpu); } else { RAM.WriteWord(addr, RdValue); } } Logger.Instance.writeLog(string.Format("CMD: {0} {1}, 0x{2} : 0x{3} ", cmd, RdValue, Convert.ToString(addr, 16), Convert.ToString(this.originalBits, 16).Replace("__", condStr))); }
public ShifterOperand loadStoreShift(bool R, ShifterOperand shiftOp, uint RmValue, Register[] reg) { if (R) { //it's a register shiftOp = figureOutShift(!R, shiftOp, RmValue, reg); } else { //it's an immediate 12 bit value shiftOp.offset = shiftOp.immed_12; } return(shiftOp); }
public ShifterOperand figureOutShift(bool I, ShifterOperand shiftOp, uint RmVal, Register[] reg) { if (!I) { //it's a register! if (shiftOp.bit4 && !shiftOp.bit7) { //shifted by a register! shiftOp.shiftRM(RmVal, reg[shiftOp.Rs].ReadWord(0, true)); } else { //shifted by an immediate value! shiftOp.shiftRM(RmVal, shiftOp.shift_imm); } } return(shiftOp); }
public override void parse(Memory command) { //PUBWL bool R = command.TestFlag(0, 25); rm = (command.ReadWord(0) & 0x0000000F); this.shiftOp = new ShifterOperand(command); if (!(command.TestFlag(0, 25) && command.TestFlag(0, 4))) { this.R = command.TestFlag(0, 25); this.P = command.TestFlag(0, 24); this.U = command.TestFlag(0, 23); this.B = command.TestFlag(0, 22); this.W = command.TestFlag(0, 21); this.L = command.TestFlag(0, 20); } }