Ejemplo n.º 1
0
        public void DecExecDP_RegReg_MUL_Success()
        {
            // e0050291        mul     r5, r1, r2
            Memory regs = new Memory(regsize);

            regs.WriteWord(Reg.R2, 0x1014);
            uint uop = 0xA1000000; int op = (int)~uop; op = ~op;

            regs.WriteWord(Reg.R1, op);
            regs.WriteWord(Reg.R2, 0x1050);
            uint u = 0xe0050291;
            int  r = Convert.ToInt32(~u); r = ~r;

            Instruction inst = new DataProcessing(r, ref regs);

            inst = new DataProcessing(r, ref regs);
            inst.Decode();
            inst.Execute();

            uop = 0x50000000; op = (int)~uop; op = ~op;
            int res = regs.ReadWord(Reg.R5);

            Assert.IsTrue(res == op);
            Assert.IsTrue(inst.ToString() == "mul r5, r1, r2");
        }
Ejemplo n.º 2
0
        public void DecExecDP_RegImm_Success()
        {
            // eor r1, r2, r3, lsr #2
            uint u = 0b11100000001000100001000100100011;
            int  r = Convert.ToInt32(~u);

            r = ~r;

            Memory regs = new Memory(regsize);

            regs.WriteWord(Reg.R2, 4);
            regs.WriteWord(Reg.R3, 3);

            //using not on original command code because c# won't let me alter the sign bit.
            Instruction inst = new DataProcessing(r, ref regs);

            inst.Decode();
            inst.Execute();

            int exp = 3 >> 2;
            int res = regs.ReadWord(Reg.R1);

            Assert.IsTrue(res == (4 ^ exp));
            Assert.IsTrue(inst.ToString() == "eor r1, r2, r3, lsr #2");
        }
Ejemplo n.º 3
0
        public void DecExecDP_RegReg_ADD_Success()
        {
            //add r1, r2, r3, ror r4
            uint u = 0b11100000100000100001010001110011;
            int  r = Convert.ToInt32(~u);

            r = ~r;

            Memory regs = new Memory(regsize);

            regs.WriteWord(Reg.R2, 4);
            regs.WriteWord(Reg.R3, 3);
            regs.WriteWord(Reg.R4, 5);

            //using not on original command code because c# won't let me alter the sign bit.
            Instruction inst = new DataProcessing(r, ref regs);

            inst.Decode();
            inst.Execute();

            int exp = (((3) >> (5)) | ((3) << (32 - (5)))); //ror
            int res = regs.ReadWord(Reg.R1);

            Assert.IsTrue(res == (4 + exp));
            Assert.IsTrue(inst.ToString() == "add r1, r2, r3, ror r4");
        }
Ejemplo n.º 4
0
        public void DecExec_DP_Imm_Mov_Success()
        {
            //e3a02030 mov r2, #48
            Memory regs = new Memory(regsize);
            //using not on original command code because c# won't let me alter the sign bit.
            int            r    = ~0x1C5FDFCF; //Original command: e3a02030
            DataProcessing inst = new DataProcessing(r, ref regs);

            inst.Decode();
            inst.Execute();

            Assert.IsTrue(inst.ToString() == "mov r2, #48");
            Assert.IsTrue(regs.ReadWord(Reg.R2) == 48);
        }
Ejemplo n.º 5
0
        public void DecExecDP_Imm_MOV_Success()
        {
            Memory regs = new Memory(regsize);

            //  mov     r1, #-1593835520
            uint u = 0xe3a014a1;
            int  r = Convert.ToInt32(~u);

            r = ~r; DataProcessing inst = new DataProcessing(r, ref regs);
            inst.Decode();
            inst.Execute();

            Assert.IsTrue(regs.ReadWord(Reg.R1) == -1593835520);
            Assert.IsTrue(inst.ToString() == "mov r1, #-1593835520");
        }
Ejemplo n.º 6
0
        public void DecExec_DP_Imm_Mov2_Success()
        {
            // mov     r0, #724
            uint u = 0xe3a00fb5;
            int  r = Convert.ToInt32(~u);

            r = ~r;
            Memory         regs = new Memory(regsize);
            DataProcessing inst = new DataProcessing(r, ref regs);

            inst.Decode();
            inst.Execute();

            Assert.IsTrue(regs.ReadWord(Reg.R0) == 724);
            Assert.IsTrue(inst.ToString() == "mov r0, #724");
        }
Ejemplo n.º 7
0
        public void DecExecDP_RegImm_MOV_Success()
        {
            Memory regs = new Memory(regsize);

            // mov     r0, #724
            regs.WriteWord(Reg.R2, 4);
            regs.WriteWord(Reg.R0, 3);

            uint u = 0xe1a02000;
            int  r = Convert.ToInt32(~u);

            r = ~r; DataProcessing inst = new DataProcessing(r, ref regs);
            inst.Decode();
            inst.Execute();

            Assert.IsTrue(regs.ReadWord(Reg.R2) == 3);
            Assert.IsTrue(inst.ToString() == "mov r2, r0");
        }
Ejemplo n.º 8
0
        public void DecExecDP_RegImm_ASR_Success()
        {
            Memory regs = new Memory(regsize);

            //  e1a02141        asr r2, r1, #2
            regs.WriteWord(Reg.R2, 0x1014);
            uint uop = 0xA1000000; int op = (int)~uop; op = ~op;

            regs.WriteWord(Reg.R1, op);

            uint u = 0xe1a02141;
            int  r = Convert.ToInt32(~u);

            r = ~r; DataProcessing inst = new DataProcessing(r, ref regs);
            inst.Decode();
            inst.Execute();

            uop = 0xE8400000; op = (int)~uop; op = ~op;
            Assert.IsTrue(regs.ReadWord(Reg.R2) == op);
            Assert.IsTrue(inst.ToString() == "mov r2, r1, asr #2");
        }
Ejemplo n.º 9
0
        public void DecExecDP_RegImm_ORR_Success()
        {
            Memory regs = new Memory(regsize);

            //  e3802012        orr r2, r0, #18
            regs.WriteWord(Reg.R2, 0x1014);
            uint uop = 0x000002D4; int op = (int)~uop; op = ~op;

            regs.WriteWord(Reg.R0, op);

            uint u = 0xe3802012;
            int  r = Convert.ToInt32(~u);

            r = ~r;
            DataProcessing inst = new DataProcessing(r, ref regs);

            inst.Decode();
            inst.Execute();

            uop = 0x000002D6; op = (int)~uop; op = ~op;
            Assert.IsTrue(regs.ReadWord(Reg.R2) == op);
            Assert.IsTrue(inst.ToString() == "orr r2, r0, #18");
        }