public void Move_MoveRegOneToRegZeroWithRorZeroImmediate_RegZeroCorrectAndCarrySet()
        {
            AgbCpu cpu = CpuUtil.CreateCpu();

            cpu.CurrentRegisterSet.GetRegister(0) = 0xDEADBEEF;
            cpu.CurrentRegisterSet.GetRegister(1) = 0x0000FFFF;

            CpuUtil.RunCpu(cpu, new uint[]
            {
                0xE1B00061 // MOVS r0, r1, ROR#0
            });

            Assert.Equal((uint)0x00007FFF, cpu.CurrentRegisterSet.GetRegister(0));
            Assert.Equal((uint)0x0000FFFF, cpu.CurrentRegisterSet.GetRegister(1));
            Assert.True(cpu.CurrentStatus.Carry);
        }
        public void GetRelativeAddress_LoadRegSevenWithSpRelativeAddress_RegSevenCorrect()
        {
            const uint targetAddress = InternalWramRegion.REGION_START + 0x3FC;

            AgbCpu cpu = CpuUtil.CreateCpu();

            cpu.CurrentRegisterSet.GetRegister(7)          = 0xDEADBEEF;
            cpu.CurrentRegisterSet.GetRegister(CpuUtil.SP) = InternalWramRegion.REGION_START;

            CpuUtil.RunCpu(cpu, new ushort[]
            {
                0xAFFF // ADD r7, SP, #0x3FC
            }, true);

            Assert.Equal(targetAddress, cpu.CurrentRegisterSet.GetRegister(7));
        }
        public void Move_MoveRegOneToRegZeroWithAsr_RegZeroCorrectAndCarrySet()
        {
            AgbCpu cpu = CpuUtil.CreateCpu();

            cpu.CurrentRegisterSet.GetRegister(0) = 0xDEADBEEF;
            cpu.CurrentRegisterSet.GetRegister(1) = 0x801FF000;

            CpuUtil.RunCpu(cpu, new uint[]
            {
                0xE1B006C1 // MOVS r0, r1, ASR#13
            });

            Assert.Equal((uint)0xFFFC00FF, cpu.CurrentRegisterSet.GetRegister(0));
            Assert.Equal((uint)0x801FF000, cpu.CurrentRegisterSet.GetRegister(1));
            Assert.True(cpu.CurrentStatus.Carry);
        }
Exemplo n.º 4
0
        public void Lsr_ShiftRegZeroRightByRegOne_RegZeroCorrect()
        {
            AgbCpu cpu = CpuUtil.CreateCpu();

            cpu.CurrentRegisterSet.GetRegister(0) = 0xFF800000;
            cpu.CurrentRegisterSet.GetRegister(1) = 0xFEFEFE18;

            CpuUtil.RunCpu(cpu, new ushort[]
            {
                0xc840 // LSR r0, r1
            });

            Assert.Equal((uint)0x000000FF, cpu.CurrentRegisterSet.GetRegister(0));
            Assert.Equal((uint)0xFEFEFE18, cpu.CurrentRegisterSet.GetRegister(1));
            Assert.True(cpu.CurrentStatus.Carry);
        }
        public void ShiftedRegister_AsrRegOneWithResultInRegZero_RegZeroCorrect()
        {
            AgbCpu cpu = CpuUtil.CreateCpu();

            cpu.CurrentRegisterSet.GetRegister(0) = 0xDEADBEEF;
            cpu.CurrentRegisterSet.GetRegister(1) = 0x801FF000;

            CpuUtil.RunCpu(cpu, new ushort[]
            {
                0x4813 // ASR r0, r1, #8
            });

            Assert.Equal((uint)0xFFFC00FF, cpu.CurrentRegisterSet.GetRegister(0));
            Assert.Equal((uint)0x801FF000, cpu.CurrentRegisterSet.GetRegister(1));
            Assert.True(cpu.CurrentStatus.Carry);
        }
Exemplo n.º 6
0
        public void Mrs_MoveCpsrToRegZero_RegZeroCorrect()
        {
            AgbCpu cpu = CpuUtil.CreateCpu();

            cpu.CurrentStatus.RegisterValue = (uint)0b11111000000000000000000011011111;

            cpu.CurrentRegisterSet.GetRegister(0) = 0xDEADBEEF;

            CpuUtil.RunCpu(cpu, new uint[]
            {
                0xE10F0000 // MRS r0, CPSR
            });

            Assert.Equal((uint)0b11111000000000000000000011011111, cpu.CurrentStatus.RegisterValue);
            Assert.Equal((uint)0b11111000000000000000000011011111, cpu.CurrentRegisterSet.GetRegister(0));
        }
Exemplo n.º 7
0
        public void Msr_MoveRegZeroToSpsr_SpsrCorrect()
        {
            AgbCpu cpu = CpuUtil.CreateCpu();

            cpu.CurrentStatus.Mode = CpuMode.System;

            cpu.CurrentRegisterSet.GetRegister(0) = 0b11111000000000000000000011000000;

            CpuUtil.RunCpu(cpu, new uint[]
            {
                0xE169F000 // MSR SPSR, r0
            });

            Assert.Equal((uint)0b11111000000000000000000011000000, cpu.CurrentSavedStatus.RegisterValue);
            Assert.Equal((uint)0b11111000000000000000000011000000, cpu.CurrentRegisterSet.GetRegister(0));
        }
Exemplo n.º 8
0
        public void BranchAndExchange_BranchToRegOneInThumb_PcCorrect()
        {
            const uint targetAddress = InternalWramRegion.REGION_START + 0x1000;

            AgbCpu cpu = CpuUtil.CreateCpu();

            cpu.CurrentRegisterSet.GetRegister(1) = targetAddress + 1;

            CpuUtil.RunCpu(cpu, new uint[]
            {
                0xE12FFF11 // BX r1
            });

            Assert.Equal(targetAddress, cpu.CurrentRegisterSet.GetRegister(CpuUtil.PC));
            Assert.True(cpu.CurrentStatus.Thumb);
        }
        public void ShiftedRegister_LslRegOneWithResultInRegZero_RegZeroCorrect()
        {
            AgbCpu cpu = CpuUtil.CreateCpu();

            cpu.CurrentRegisterSet.GetRegister(0) = 0xDEADBEEF;
            cpu.CurrentRegisterSet.GetRegister(1) = 0x000001FF;

            CpuUtil.RunCpu(cpu, new ushort[]
            {
                0x0806 // LSL r0, r1, #24
            });

            Assert.Equal((uint)0xFF000000, cpu.CurrentRegisterSet.GetRegister(0));
            Assert.Equal((uint)0x000001FF, cpu.CurrentRegisterSet.GetRegister(1));
            Assert.True(cpu.CurrentStatus.Carry);
        }
Exemplo n.º 10
0
        public void Move_MoveRegOneToRegZeroWithRor_RegZeroCorrectAndCarrySet()
        {
            AgbCpu cpu = CpuUtil.CreateCpu();

            cpu.CurrentRegisterSet.GetRegister(0) = 0x0000FFFF;
            cpu.CurrentRegisterSet.GetRegister(1) = 0xFEFEFE08;

            CpuUtil.RunCpu(cpu, new ushort[]
            {
                0xc841 // ROR r0, r1
            });

            Assert.Equal((uint)0xFF0000FF, cpu.CurrentRegisterSet.GetRegister(0));
            Assert.Equal((uint)0xFEFEFE08, cpu.CurrentRegisterSet.GetRegister(1));
            Assert.True(cpu.CurrentStatus.Carry);
        }
Exemplo n.º 11
0
        public void Branch_BranchWithPsotiveOffsetAndCondition_PcCorrect(uint flags, uint opcode)
        {
            AgbCpu cpu = CpuUtil.CreateCpu();

            cpu.CurrentStatus.RegisterValue = (cpu.CurrentStatus.RegisterValue & 0x0FFFFFFF) | (flags << 28);

            const uint baseInstruction = 0xD07F;
            uint       instruction     = (opcode << 8) | baseInstruction;

            CpuUtil.RunCpu(cpu, new ushort[]
            {
                (ushort)instruction // B{cond} #0xFE
            }, true);

            Assert.Equal(InternalWramRegion.REGION_START + 0x4 + 0xFE, cpu.CurrentRegisterSet.GetRegister(CpuUtil.PC));
        }
Exemplo n.º 12
0
        public void Asr_ArithmaticShiftRegZeroRightByRegOne_RegZeroCorrect()
        {
            AgbCpu cpu = CpuUtil.CreateCpu();

            cpu.CurrentRegisterSet.GetRegister(0) = 0x801FF000;
            cpu.CurrentRegisterSet.GetRegister(1) = 0xFEFEFE0D;

            CpuUtil.RunCpu(cpu, new ushort[]
            {
                0x0841 // ASR r0, r1
            });

            Assert.Equal((uint)0xFFFC00FF, cpu.CurrentRegisterSet.GetRegister(0));
            Assert.Equal((uint)0xFEFEFE0D, cpu.CurrentRegisterSet.GetRegister(1));
            Assert.True(cpu.CurrentStatus.Carry);
        }
        public void Orr_OrRegOneAndRegTwo_RegZeroCorrect()
        {
            AgbCpu cpu = CpuUtil.CreateCpu();

            cpu.CurrentRegisterSet.GetRegister(0) = 0xDEADBEEF;
            cpu.CurrentRegisterSet.GetRegister(1) = 0xCAFE0000;
            cpu.CurrentRegisterSet.GetRegister(2) = 0x0000BABE;

            CpuUtil.RunCpu(cpu, new uint[]
            {
                0xE0810002 // AND r0, r1, r2
            });

            Assert.Equal((uint)0xCAFEBABE, cpu.CurrentRegisterSet.GetRegister(0));
            Assert.Equal((uint)0xCAFE0000, cpu.CurrentRegisterSet.GetRegister(1));
            Assert.Equal((uint)0x0000BABE, cpu.CurrentRegisterSet.GetRegister(2));
        }
        public void Add_RegTwoAndRegOne_RegZeroCorrect()
        {
            AgbCpu cpu = CpuUtil.CreateCpu();

            cpu.CurrentRegisterSet.GetRegister(0) = 0xDEADBEEF;
            cpu.CurrentRegisterSet.GetRegister(1) = 0x0000F000;
            cpu.CurrentRegisterSet.GetRegister(2) = 0x00001000;

            CpuUtil.RunCpu(cpu, new ushort[]
            {
                0x8818 // ADD r0, r1, r2
            });

            Assert.Equal((uint)0x00010000, cpu.CurrentRegisterSet.GetRegister(0));
            Assert.Equal((uint)0x0000F000, cpu.CurrentRegisterSet.GetRegister(1));
            Assert.Equal((uint)0x00001000, cpu.CurrentRegisterSet.GetRegister(2));
        }
        public void Tst_AndRegOneAndZeroImmediate_FlagsCorrect()
        {
            AgbCpu cpu = CpuUtil.CreateCpu();

            cpu.CurrentRegisterSet.GetRegister(0) = 0xDEADBEEF;
            cpu.CurrentRegisterSet.GetRegister(1) = 0xCAFEBABE;

            CpuUtil.RunCpu(cpu, new uint[]
            {
                0xE3110000 // TST r1, #0x0
            });

            Assert.Equal(0xDEADBEEF, cpu.CurrentRegisterSet.GetRegister(0));
            Assert.Equal(0xCAFEBABE, cpu.CurrentRegisterSet.GetRegister(1));
            Assert.True(cpu.CurrentStatus.Zero);
            Assert.False(cpu.CurrentStatus.Negative);
        }
Exemplo n.º 16
0
        public void StoreByte_UsingAddressInRegOneAndImmediateOffset_StoreSuccess()
        {
            const uint targetAddress = InternalWramRegion.REGION_START + 0x1F;

            AgbCpu cpu = CpuUtil.CreateCpu();

            cpu.CurrentRegisterSet.GetRegister(0) = 0xFEFEFEAA;
            cpu.CurrentRegisterSet.GetRegister(1) = InternalWramRegion.REGION_START;

            CpuUtil.RunCpu(cpu, new ushort[]
            {
                0x77c8 // STRB r0, [r1, #0x1F]
            }, true);

            Assert.Equal(0xAA, cpu.MemoryMap.Read(targetAddress));
            Assert.Equal(InternalWramRegion.REGION_START, cpu.CurrentRegisterSet.GetRegister(1));
        }
Exemplo n.º 17
0
        public void StoreHalf_UsingAddressInRegOneAndImmediateOffset_StoreSuccess()
        {
            const uint targetAddress = InternalWramRegion.REGION_START + 0x3E;

            AgbCpu cpu = CpuUtil.CreateCpu();

            cpu.CurrentRegisterSet.GetRegister(0) = 0xF00D;
            cpu.CurrentRegisterSet.GetRegister(1) = InternalWramRegion.REGION_START;

            CpuUtil.RunCpu(cpu, new ushort[]
            {
                0x87C8 // STRH r0, [r1, #0x3E]
            }, true);

            Assert.Equal((uint)0xF00D, cpu.MemoryMap.ReadU16(targetAddress));
            Assert.Equal(InternalWramRegion.REGION_START, cpu.CurrentRegisterSet.GetRegister(1));
        }
        public void BitClear_BicWithRegOneAndRegTwo_RegZeroCorrect()
        {
            AgbCpu cpu = CpuUtil.CreateCpu();

            cpu.CurrentRegisterSet.GetRegister(0) = 0xDEADBEEF;
            cpu.CurrentRegisterSet.GetRegister(1) = 0x000000FF;
            cpu.CurrentRegisterSet.GetRegister(2) = 0xFFFFFF00;

            CpuUtil.RunCpu(cpu, new uint[]
            {
                0xE1C10002 // BIC r0, r1, r2
            });

            Assert.Equal((uint)0x000000FF, cpu.CurrentRegisterSet.GetRegister(0));
            Assert.Equal((uint)0x000000FF, cpu.CurrentRegisterSet.GetRegister(1));
            Assert.Equal((uint)0xFFFFFF00, cpu.CurrentRegisterSet.GetRegister(2));
        }
Exemplo n.º 19
0
        public void Compare_SubtractImmediateFromRegZero_RegZeroUntouchedAndFlagsCorrect()
        {
            AgbCpu cpu = CpuUtil.CreateCpu();

            cpu.CurrentRegisterSet.GetRegister(0) = 0xDEADBEEF;

            CpuUtil.RunCpu(cpu, new ushort[]
            {
                0xff28 // CMP r0, #0xff
            });

            Assert.Equal((uint)0xDEADBEEF, cpu.CurrentRegisterSet.GetRegister(0));
            Assert.True(cpu.CurrentStatus.Negative);
            Assert.False(cpu.CurrentStatus.Zero);
            Assert.True(cpu.CurrentStatus.Carry);
            Assert.False(cpu.CurrentStatus.Overflow);
        }
Exemplo n.º 20
0
        public void Tst_AndRegOneAndRegTwo_FlagsCorrect()
        {
            AgbCpu cpu = CpuUtil.CreateCpu();

            cpu.CurrentRegisterSet.GetRegister(0) = 0xCAFEBABE;
            cpu.CurrentRegisterSet.GetRegister(1) = 0xFFFF0000;

            CpuUtil.RunCpu(cpu, new ushort[]
            {
                0x0842 // TST r0, r1
            });

            Assert.Equal(0xCAFEBABE, cpu.CurrentRegisterSet.GetRegister(0));
            Assert.Equal(0xFFFF0000, cpu.CurrentRegisterSet.GetRegister(1));
            Assert.False(cpu.CurrentStatus.Zero);
            Assert.True(cpu.CurrentStatus.Negative);
        }
Exemplo n.º 21
0
        public void AddCarry_RegOneAndRegZeroWithCarry_RegZeroCorrect()
        {
            AgbCpu cpu = CpuUtil.CreateCpu();

            cpu.CurrentStatus.Carry = true;

            cpu.CurrentRegisterSet.GetRegister(0) = 0x0000F000;
            cpu.CurrentRegisterSet.GetRegister(1) = 0x00001000;

            CpuUtil.RunCpu(cpu, new ushort[]
            {
                0x4841 // ADC r0, r1
            });

            Assert.Equal((uint)0x00010001, cpu.CurrentRegisterSet.GetRegister(0));
            Assert.Equal((uint)0x00001000, cpu.CurrentRegisterSet.GetRegister(1));
        }
        public void SubtractReverse_RegTwoFromRegOne_RegZeroCorrect()
        {
            AgbCpu cpu = CpuUtil.CreateCpu();

            cpu.CurrentRegisterSet.GetRegister(0) = 0xDEADBEEF;
            cpu.CurrentRegisterSet.GetRegister(1) = 0x00001000;
            cpu.CurrentRegisterSet.GetRegister(2) = 0x0000F000;

            CpuUtil.RunCpu(cpu, new uint[]
            {
                0xE0610002 // RSB r0, r1, r2
            });

            Assert.Equal((uint)0x0000E000, cpu.CurrentRegisterSet.GetRegister(0));
            Assert.Equal((uint)0x00001000, cpu.CurrentRegisterSet.GetRegister(1));
            Assert.Equal((uint)0x0000F000, cpu.CurrentRegisterSet.GetRegister(2));
        }
        public void Eor_RegOneWithRegTwo_RegZeroCorrect()
        {
            AgbCpu cpu = CpuUtil.CreateCpu();

            cpu.CurrentRegisterSet.GetRegister(0) = 0xFEEDFACE;
            cpu.CurrentRegisterSet.GetRegister(1) = 0xCAFEBABE;
            cpu.CurrentRegisterSet.GetRegister(2) = 0xDEADBEEF;

            CpuUtil.RunCpu(cpu, new uint[]
            {
                0xE0210002 // EOR r0, r1, r2
            });

            Assert.Equal((uint)0x14530451, cpu.CurrentRegisterSet.GetRegister(0));
            Assert.Equal((uint)0xCAFEBABE, cpu.CurrentRegisterSet.GetRegister(1));
            Assert.Equal((uint)0xDEADBEEF, cpu.CurrentRegisterSet.GetRegister(2));
        }
Exemplo n.º 24
0
        public void SubtractCarry_RegOneFromRegZeroWithCarry_RegZeroCorrect()
        {
            AgbCpu cpu = CpuUtil.CreateCpu();

            cpu.CurrentStatus.Carry = false;

            cpu.CurrentRegisterSet.GetRegister(0) = 0x0000F000;
            cpu.CurrentRegisterSet.GetRegister(1) = 0x00001000;

            CpuUtil.RunCpu(cpu, new ushort[]
            {
                0x8841 // SBC r0, r1
            });

            Assert.Equal((uint)0x0000DFFF, cpu.CurrentRegisterSet.GetRegister(0));
            Assert.Equal((uint)0x00001000, cpu.CurrentRegisterSet.GetRegister(1));
        }
        public void StoreHalf_UsingAddressInRegOne_StoreSuccess()
        {
            const uint targetAddress = InternalWramRegion.REGION_START + 0x1000;

            AgbCpu cpu = CpuUtil.CreateCpu();

            cpu.CurrentRegisterSet.GetRegister(0) = 0xFFFFCAFE;
            cpu.CurrentRegisterSet.GetRegister(1) = targetAddress;

            CpuUtil.RunCpu(cpu, new uint[]
            {
                0xB000C1E1 // STRH r0, [r1]
            }, true);

            Assert.Equal((uint)0x0000CAFE, cpu.MemoryMap.ReadU16(targetAddress));
            Assert.Equal(targetAddress, cpu.CurrentRegisterSet.GetRegister(1));
        }
Exemplo n.º 26
0
        public void Multiply_RegOneAndRegTwo_RegZeroCorrect()
        {
            AgbCpu cpu = CpuUtil.CreateCpu();

            cpu.CurrentRegisterSet.GetRegister(0) = 0xDEADBEEF;
            cpu.CurrentRegisterSet.GetRegister(1) = 0xFFFFFFF6;
            cpu.CurrentRegisterSet.GetRegister(2) = 0x00000014;

            CpuUtil.RunCpu(cpu, new uint[]
            {
                0xE0000291, // MUL r0, r1, r2
            });

            Assert.Equal((uint)0xFFFFFF38, cpu.CurrentRegisterSet.GetRegister(0));
            Assert.Equal((uint)0xFFFFFFF6, cpu.CurrentRegisterSet.GetRegister(1));
            Assert.Equal((uint)0x00000014, cpu.CurrentRegisterSet.GetRegister(2));
        }
        public void Store_UsingAddressInSpAndImmediateOffset_StoreSuccess()
        {
            const uint targetAddress = InternalWramRegion.REGION_START + 0x3FC;

            AgbCpu cpu = CpuUtil.CreateCpu();

            cpu.CurrentRegisterSet.GetRegister(0)          = 0xDEADBEEF;
            cpu.CurrentRegisterSet.GetRegister(CpuUtil.SP) = InternalWramRegion.REGION_START;

            CpuUtil.RunCpu(cpu, new ushort[]
            {
                0x90FF // STR r0, [SP, #0x3FC]
            }, true);

            Assert.Equal(0xDEADBEEF, cpu.MemoryMap.ReadU32(targetAddress));
            Assert.Equal(InternalWramRegion.REGION_START, cpu.CurrentRegisterSet.GetRegister(CpuUtil.SP));
        }
        public void Ldm_LoadAllRegistersAndPostIncrement_RegistersCorrect()
        {
            const uint targetAddress = InternalWramRegion.REGION_START + 0x1000;

            AgbCpu cpu = CpuUtil.CreateCpu();

            cpu.MemoryMap.WriteU32(targetAddress + (0 * 4), 0x11111111);
            cpu.MemoryMap.WriteU32(targetAddress + (1 * 4), 0x22222222);
            cpu.MemoryMap.WriteU32(targetAddress + (2 * 4), 0x33333333);
            cpu.MemoryMap.WriteU32(targetAddress + (3 * 4), 0x44444444);
            cpu.MemoryMap.WriteU32(targetAddress + (4 * 4), 0x55555555);
            cpu.MemoryMap.WriteU32(targetAddress + (5 * 4), 0x66666666);
            cpu.MemoryMap.WriteU32(targetAddress + (6 * 4), 0x77777777);
            cpu.MemoryMap.WriteU32(targetAddress + (7 * 4), 0x88888888);
            cpu.MemoryMap.WriteU32(targetAddress + (8 * 4), 0x99999999);
            cpu.MemoryMap.WriteU32(targetAddress + (9 * 4), 0xAAAAAAAA);
            cpu.MemoryMap.WriteU32(targetAddress + (10 * 4), 0xBBBBBBBB);
            cpu.MemoryMap.WriteU32(targetAddress + (11 * 4), 0xCCCCCCCC);
            cpu.MemoryMap.WriteU32(targetAddress + (12 * 4), 0xDDDDDDDD);
            cpu.MemoryMap.WriteU32(targetAddress + (13 * 4), 0xEEEEEEEE);
            cpu.MemoryMap.WriteU32(targetAddress + (14 * 4), 0xFFFFFFFF);

            cpu.CurrentRegisterSet.GetRegister(0) = targetAddress;

            CpuUtil.RunCpu(cpu, new uint[]
            {
                0xFEFF90E8 // LDMIA r0, {r1-r15}
            }, true);

            Assert.Equal((uint)0x11111111, cpu.CurrentRegisterSet.GetRegister(1));
            Assert.Equal((uint)0x22222222, cpu.CurrentRegisterSet.GetRegister(2));
            Assert.Equal((uint)0x33333333, cpu.CurrentRegisterSet.GetRegister(3));
            Assert.Equal((uint)0x44444444, cpu.CurrentRegisterSet.GetRegister(4));
            Assert.Equal((uint)0x55555555, cpu.CurrentRegisterSet.GetRegister(5));
            Assert.Equal((uint)0x66666666, cpu.CurrentRegisterSet.GetRegister(6));
            Assert.Equal((uint)0x77777777, cpu.CurrentRegisterSet.GetRegister(7));
            Assert.Equal((uint)0x88888888, cpu.CurrentRegisterSet.GetRegister(8));
            Assert.Equal((uint)0x99999999, cpu.CurrentRegisterSet.GetRegister(9));
            Assert.Equal((uint)0xAAAAAAAA, cpu.CurrentRegisterSet.GetRegister(10));
            Assert.Equal((uint)0xBBBBBBBB, cpu.CurrentRegisterSet.GetRegister(11));
            Assert.Equal((uint)0xCCCCCCCC, cpu.CurrentRegisterSet.GetRegister(12));
            Assert.Equal((uint)0xDDDDDDDD, cpu.CurrentRegisterSet.GetRegister(13));
            Assert.Equal((uint)0xEEEEEEEE, cpu.CurrentRegisterSet.GetRegister(14));
            Assert.Equal((uint)0xFFFFFFFC, cpu.CurrentRegisterSet.GetRegister(15));
        }
        public void Move_MoveRegOneToRegZeroWithLslByRegTwo_RegZeroCorrectAndCarrySet()
        {
            AgbCpu cpu = CpuUtil.CreateCpu();

            cpu.CurrentRegisterSet.GetRegister(0) = 0xDEADBEEF;
            cpu.CurrentRegisterSet.GetRegister(1) = 0x000001FF;
            cpu.CurrentRegisterSet.GetRegister(2) = 0xAABBCC18; // 24 with garbage in higher bits

            CpuUtil.RunCpu(cpu, new uint[]
            {
                0xE1B00211 // MOVS r0, r1, LSL r2
            });

            Assert.Equal((uint)0xFF000000, cpu.CurrentRegisterSet.GetRegister(0));
            Assert.Equal((uint)0x000001FF, cpu.CurrentRegisterSet.GetRegister(1));
            Assert.Equal((uint)0xAABBCC18, cpu.CurrentRegisterSet.GetRegister(2));
            Assert.True(cpu.CurrentStatus.Carry);
        }
        public void Store_UsingAddressInRegOne_StoreSuccess()
        {
            const uint targetAddress = InternalWramRegion.REGION_START + 0x1000;

            AgbCpu cpu = CpuUtil.CreateCpu();

            cpu.CurrentRegisterSet.GetRegister(0) = 0xCAFEBABE;
            cpu.CurrentRegisterSet.GetRegister(1) = targetAddress;

            CpuUtil.RunCpu(cpu, new uint[]
            {
                0x000081E5 // STR r0, [r1]
            }, true);

            Assert.Equal(0xCAFEBABE, cpu.MemoryMap.ReadU32(targetAddress));
            Assert.Equal(0xCAFEBABE, cpu.CurrentRegisterSet.GetRegister(0));
            Assert.Equal(targetAddress, cpu.CurrentRegisterSet.GetRegister(1));
        }