/// <summary> /// Deal with some of the knitty gritty that happens /// when we deal with operand2 /// </summary> /// <param name="b25"></param> /// <param name="shifter"></param> /// <param name="RmVal"></param> /// <param name="ra"></param> /// <returns></returns> public Operand2 HandleShift(bool b25, Operand2 shifter, uint RmVal, Register[] ra) { // if this bit is set then we are dealing with a register if (b25) { shifter = Shift(!b25, shifter, RmVal, ra); } // otherwise it is an immediate value else { shifter.offset = shifter.imm12; } return(shifter); }
/// <summary> /// The run method for Load Store. /// Overwrites parent's method /// </summary> /// <param name="ra"></param> /// <param name="mem"></param> public override void Run(ref Register[] ra, ref Memory mem) { Logger.Instance.writeLog(string.Format("Command Type: Data Movement : 0x{0}", Convert.ToString(this.initialBytes, 16))); // Gather information about registers uint RdVal = ra[this.Rd].ReadWord(0, true); uint RnVal = ra[this.Rn].ReadWord(0, true); uint RmVal = ra[this.Rm].ReadWord(0, true); this.shifter = HandleShift(this.b25, this.shifter, RmVal, ra); //addressing mode uint addr = FindAddressingMode(ref ra); string cmd = ""; // Check for Load / Store if (this.L) { cmd = "ldr"; if (this.B) { ra[this.Rd].WriteWord(0, 0); ra[this.Rd].WriteByte(0, mem.ReadByte(addr)); } else { ra[this.Rd].WriteWord(0, mem.ReadWord(addr)); } } // If not load then store else { cmd = "str"; if (this.B) { mem.WriteByte(addr, ra[this.Rd].ReadByte(0)); } else { mem.WriteWord(addr, RdVal); } } Logger.Instance.writeLog(string.Format("Specific Command: {0} {1}, 0x{2} : 0x{3} ", cmd, RdVal, Convert.ToString(addr, 16), Convert.ToString(this.initialBytes, 16))); }
/// <summary> /// Overwrites parent's ParseCommand Method /// </summary> /// <param name="cmd"></param> public override void ParseCommand(Memory cmd) { //PUBWL b25 = cmd.TestFlag(0, 25); b4 = cmd.TestFlag(0, 4); Rm = (cmd.ReadWord(0) & 0x0000000F); this.shifter = new Operand2(cmd); if (!(b25 && b4)) { this.b25 = cmd.TestFlag(0, 25); this.P = cmd.TestFlag(0, 24); this.U = cmd.TestFlag(0, 23); this.B = cmd.TestFlag(0, 22); this.W = cmd.TestFlag(0, 21); this.L = cmd.TestFlag(0, 20); } }
/// <summary> /// This is responsible for the shifts that have /// to take place at times in the operand2 /// </summary> /// <param name="S"></param> /// <param name="shifter"></param> /// <param name="RmVal"></param> /// <param name="reg"></param> /// <returns></returns> public Operand2 Shift(bool S, Operand2 shifter, uint RmVal, Register[] reg) { // Look at our magic bit to see what to do if (!S) { // Check to see if shift is done on a register if (shifter.b4 && !shifter.b7) { shifter.shiftRM(RmVal, reg[shifter.regShiftLength].ReadWord(0, true)); } // otherwise the shift is an immediate value else { shifter.shiftRM(RmVal, shifter.regShiftImm); } } return(shifter); }
/// <summary> /// This is responsible for the shifts that have /// to take place at times in the operand2 /// </summary> /// <param name="S"></param> /// <param name="shifter"></param> /// <param name="RmVal"></param> /// <param name="reg"></param> /// <returns></returns> public Operand2 Shift(bool S, Operand2 shifter, uint RmVal, Register[] reg) { // Look at our magic bit to see what to do if (!S) { // Check to see if shift is done on a register if (shifter.b4 && !shifter.b7) { shifter.shiftRM(RmVal, reg[shifter.regShiftLength].ReadWord(0, true));} // otherwise the shift is an immediate value else {shifter.shiftRM(RmVal, shifter.regShiftImm);} } return shifter; }
/// <summary> /// Deal with some of the knitty gritty that happens /// when we deal with operand2 /// </summary> /// <param name="b25"></param> /// <param name="shifter"></param> /// <param name="RmVal"></param> /// <param name="ra"></param> /// <returns></returns> public Operand2 HandleShift(bool b25, Operand2 shifter, uint RmVal, Register[] ra) { // if this bit is set then we are dealing with a register if (b25) {shifter = Shift(!b25, shifter, RmVal, ra);} // otherwise it is an immediate value else {shifter.offset = shifter.imm12;} return shifter; }