Exemple #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);
                }
            }
        }
Exemple #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);
                }
            }
        }
Exemple #3
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);
            }
        }
Exemple #4
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;
            }
        }