示例#1
0
        //stores word to memory address:
        public override void Execute(uint Rn, uint Rd, Offset offst)
        {
            int EA = GetEffAddr(Rn, offst);        //((int)Rn + (U == 1 ? offst.GetValue() : -offst.GetValue())) & 0xFFFFFFFF;

            if (EA == 0x100000)
            {
                I_Console_Ref.Append((char)CPU.GetRegr(I_Reg, (int)Rd));
            }
            else
            {
                if (B == 1)
                {
                    byte b = Convert.ToByte(CPU.GetRegr(I_Reg, (int)Rd) & 0xFF);
                    I_RAM.WriteByte(b, EA);
                }
                else
                {
                    I_RAM.WriteWord(CPU.GetRegr(I_Reg, (int)Rd), EA);
                }

                if (W == 1)
                {
                    CPU.SetReg(I_Reg, (int)Rn, EA);
                }
            }
        }
示例#2
0
        //Loads word from memory address:
        public override void Execute(uint Rn, uint Rd, Offset offst)
        {
            //LDR   <Rd>, <addressing_mode>
            int EA = GetEffAddr(Rn, offst);         //((int)Rn + (U == 1 ? offst.GetValue(): -offst.GetValue())) & 0xFFFFFFFF;

            if (EA == 0x100001)
            {
                //check after check if input buff is empty
                I_Last_Char = I_Input_Buff.Count != 0 ? I_Input_Buff[I_Input_Buff.Count - 1] : (char)0;
                CPU.SetReg(I_Reg, (int)Rd, Convert.ToInt32(I_Last_Char));
            }
            else
            {
                if (B == 1)
                {
                    CPU.SetReg(I_Reg, (int)Rd, I_RAM.ReadByte((uint)EA));
                }
                else
                {
                    CPU.SetReg(I_Reg, (int)Rd, I_RAM.ReadWord(EA)); //Remember to check what memreads return if invalid EA
                }

                if (W == 1)
                {
                    CPU.SetReg(I_Reg, (int)Rn, EA);
                }
            }
        }
        //Rd := Rm * Rs;
        public override void Execute(uint Rd, uint Rm, uint Rs)
        {
            int  first  = CPU.GetRegr(I_Reg, (int)Rm);
            int  second = CPU.GetRegr(I_Reg, (int)Rs);
            long res    = (first * second) & 0xFFFFFFFF;

            CPU.SetReg(I_Reg, (int)Rd, (int)res);
        }
        public override void Execute(int offset)
        {
            int pc = CPU.GetRegr(I_Reg, 15); //returns pc + 8;

            pc -= 4;                         //this might be a problem
            if (L == 1)
            {
                CPU.SetReg(I_Reg, 14, pc);
            }
            CPU.SetReg(I_Reg, 15, ((int)InstAddr + 8 + offset));
        }
示例#5
0
        public override void Execute(uint Rn, List <int> Reglist)
        {
            int EA = CPU.GetRegr(I_Reg, (int)Rn);

            foreach (int i in Reglist)
            {
                int val = I_RAM.ReadWord(EA);
                CPU.SetReg(I_Reg, i, val);
                EA += 4;
            }

            if (W == 1)
            {
                CPU.SetReg(I_Reg, (int)Rn, EA);
            }
        }
示例#6
0
        //pushes register list onto stack
        public override void Execute(uint Rn, List <int> Reglist)
        {
            int EA = CPU.GetRegr(I_Reg, (int)Rn);

            EA -= (4 * Reglist.Count);

            if (W == 1)
            {
                CPU.SetReg(I_Reg, (int)Rn, EA);
            }

            foreach (int i in Reglist)
            {
                int val = CPU.GetRegr(I_Reg, i);
                I_RAM.WriteWord(val, EA);
                EA += 4;
            }
        }
        //Rd := shifter_operand (no Rn)
        public override void Execute(uint Rn, uint Rd, Operand2 oper2)
        {
            CPU.SetReg(I_Reg, (int)Rd, oper2.GetValue());

            int mode = (int)Memory.ExtractBits((uint)CPU.GetRegr(I_Reg, 16), 27, 31);

            if (sbit && Rd == 15)
            {
                int spsr = CPU.GetRegr(I_Reg, 16);
                if (mode == 0b10010)
                {
                    spsr = CPU.GetRegr(I_Reg, 19); //because I had to place them weirdly.
                    //CPU.SetReg(I_Reg, (int)Rd, oper2.GetValue() - 4); //adjust the LR for the PC when IRQ
                }
                else if (mode == 0b10011)
                {
                    spsr = CPU.GetRegr(I_Reg, 22);
                }

                CPU.SetReg(I_Reg, 16, spsr);
            }
        }
        public override void Execute(int Rm)
        {
            uint rm0 = (uint)CPU.GetRegr(I_Reg, Rm) & 0xFFFFFFFE;

            CPU.SetReg(I_Reg, 15, (int)(rm0));
        }
        //Rd := Rn AND NOT(shifter_operand)
        public override void Execute(uint Rn, uint Rd, Operand2 oper2)
        {
            int val = CPU.GetRegr(I_Reg, (int)Rn) & (~oper2.GetValue());

            CPU.SetReg(I_Reg, (int)Rd, val);
        }
 //Rd := NOT shifter_operand (no Rn)
 public override void Execute(uint Rn, uint Rd, Operand2 oper2)
 {
     CPU.SetReg(I_Reg, (int)Rd, ~oper2.GetValue());
 }