Ejemplo n.º 1
0
        //Extract adress according to register offset specification
        int DecodeRegisterOffset()
        {
            char Rm       = (char)ExtractBits(code, 0, 3);
            char Sh       = (char)ExtractBits(code, 5, 6);
            int  shiftVal = ExtractBits(code, 7, 11);

            shiftVal *= U ? 1 : -1;

            stringValue = ", " + (shiftVal == 0 ? (U ? "" : "-") : "") + "r" + (int)Rm;

            int regval = Regs.ReadWord(GetReg(Rm));

            if (Rm == 15)
            {
                regval += 8;
            }

            if (shiftVal != 0)
            {
                stringValue += ", " + BarrelShifter.CodeToString(Sh) + " #" + shiftVal;
            }
            else if (!U)
            {
                regval *= -1;
            }

            return(BarrelShifter.ShiftByCode(regval, shiftVal, Sh));
        }
Ejemplo n.º 2
0
        //Calcultes and returns the immediate shift operand
        int CalulateImmediateValue()
        {
            short shift = Convert.ToInt16(ExtractBits(code, 8, 11));

            shift *= 2;
            int immediate = ExtractBits(code, 0, 7);

            immediate = BarrelShifter.ShiftByCode(immediate, shift, (char)3);

            strVal = "#" + immediate;

            return(immediate);
        }
Ejemplo n.º 3
0
        //Calcultes and returns the register shift operand
        int CalculateRegisterOperand3()
        {
            int shiftVal;

            Rm = (char)ExtractBits(code, 0, 3);
            char Sh   = (char)ExtractBits(code, 5, 6);
            bool bit4 = TestFlag(code, 4);
            char Rs   = '0';

            strShift = "r" + (int)Rm;

            if (!bit4)
            {
                shiftVal = ExtractBits(code, 7, 11);
            }
            else
            {
                Rs       = (char)ExtractBits(code, 8, 11);
                shiftVal = Regs.ReadWord(GetReg(Rs));
                if (Rs == 15)
                {
                    shiftVal += 8;
                }
            }
            if (shiftVal != 0)
            {
                strShift += ", " + BarrelShifter.CodeToString(Sh) + (bit4 ? " r" + (int)Rs : " #" + shiftVal);
            }

            int val = Regs.ReadWord(GetReg(Rm));

            if (Rm == 15)
            {
                val += 8;
            }

            return(BarrelShifter.ShiftByCode(val, shiftVal, Sh));
        }