Exemple #1
0
        public FPUEntity(DataFormat format, ExecutionState state)
        {
            m_BufferPtr = Marshal.AllocHGlobal(8);

            m_Tag = format;
            m_Wide = state.CP0Regs.StatusReg.AdditionalFPR;
            m_FPR = state.Fpr;

            switch (m_Tag)
            {
                case DataFormat.Double:
                    {
                        m_DynamicGet = (e) => { return e.m_Double; };
                        m_DynamicSet = (e, v) => { e.m_Double = v; };
                        break;
                    }
                case DataFormat.Doubleword:
                    {
                        m_DynamicGet = (e) => { return e.m_Long; };
                        m_DynamicSet = (e, v) => { e.m_Long = v; };
                        break;
                    }
                case DataFormat.Single:
                    {
                        m_DynamicGet = (e) => { return e.m_Single; };
                        m_DynamicSet = (e, v) => { e.m_Single = v; };
                        break;
                    }
                case DataFormat.Word:
                    {
                        m_DynamicGet = (e) => { return e.m_Word; };
                        m_DynamicSet = (e, v) => { e.m_Word = v; };
                        break;
                    }
                default:
                case DataFormat.Reserved: throw new InvalidOperationException("Cannot return a value with reserved data format");
            }
        }
 public ExecutionStateViewModel(MachineViewModel machineVm, ExecutionState state)
     : base(machineVm)
 {
     m_State = state;
 }
 public override sealed void Initialize()
 {
     base.Initialize();
     m_CPUState = ParentMips.State;
     m_InstReader = new InstructionReader(MemoryAccessMode.Virtual);
     m_DataManipulator = new MipsDataManipulator(ParentMips.VirtualMemoryStream);
     InitializeOpcodes();
 }
Exemple #4
0
        private void AssertPIFCodes(RegionType region, CICKeyType cic, ExecutionState state)
        {
            Assert.Equal(0x00000000A4000040L, state.PC);
            Assert.Equal(0x0000000000000000UL, state.GPRRegs[0]);
            Assert.Equal(0xFFFFFFFFA4001F0CUL, state.GPRRegs[6]);
            Assert.Equal(0xFFFFFFFFA4001F08UL, state.GPRRegs[7]);
            Assert.Equal(0x00000000000000C0UL, state.GPRRegs[8]);
            Assert.Equal(0x0000000000000000UL, state.GPRRegs[9]);
            Assert.Equal(0x0000000000000040UL, state.GPRRegs[10]);
            Assert.Equal(0xFFFFFFFFA4000040UL, state.GPRRegs[11]);
            Assert.Equal(0x0000000000000000UL, state.GPRRegs[16]);
            Assert.Equal(0x0000000000000000UL, state.GPRRegs[17]);
            Assert.Equal(0x0000000000000000UL, state.GPRRegs[18]);
            Assert.Equal(0x0000000000000000UL, state.GPRRegs[19]);
            Assert.Equal(0x0000000000000000UL, state.GPRRegs[21]);
            Assert.Equal(0x0000000000000000UL, state.GPRRegs[26]);
            Assert.Equal(0x0000000000000000UL, state.GPRRegs[27]);
            Assert.Equal(0x0000000000000000UL, state.GPRRegs[28]);
            Assert.Equal(0x0000000000000000UL, state.GPRRegs[28]);
            Assert.Equal(0xFFFFFFFFA4001FF0UL, state.GPRRegs[29]);
            Assert.Equal(0x0000000000000000UL, state.GPRRegs[30]);

            switch (Cartridge.Current.RomImage.Region)
            {
                case RegionType.MPAL:
                case RegionType.PAL:
                    {
                        switch (Cartridge.Current.RomImage.BootRomInformation.CIC)
                        {
                            default:
                            case CICKeyType.Unknown:
                            case CICKeyType.CIC_X102:
                                {
                                    Assert.Equal(0xFFFFFFFFC0F1D859UL, state.GPRRegs[5]);
                                    Assert.Equal(0x000000002DE108EAUL, state.GPRRegs[14]);
                                    Assert.Equal(0x0000000000000000UL, state.GPRRegs[24]);

                                    break;
                                }
                            case CICKeyType.CIC_X101:
                                {
                                    break;
                                }
                            case CICKeyType.CIC_X103:
                                {
                                    Assert.Equal(0xFFFFFFFFD4646273UL, state.GPRRegs[5]);
                                    Assert.Equal(0x000000001AF99984UL, state.GPRRegs[14]);
                                    Assert.Equal(0x0000000000000000UL, state.GPRRegs[24]);
                                    break;
                                }
                            case CICKeyType.CIC_X105:
                                {
                                    Assert.Equal(0xFFFFFFFFDECAAAD1UL, state.GPRRegs[5]);
                                    Assert.Equal(0x000000000CF85C13UL, state.GPRRegs[14]);
                                    Assert.Equal(0x0000000000000002UL, state.GPRRegs[24]);
                                    AssertEqualMemoryReadU32(0xA4001004, 0xBDA807FC);
                                    break;
                                }
                            case CICKeyType.CIC_X106:
                                {
                                    Assert.Equal(0xFFFFFFFFB04DC903UL, state.GPRRegs[5]);
                                    Assert.Equal(0x000000001AF99984UL, state.GPRRegs[14]);
                                    Assert.Equal(0x0000000000000002UL, state.GPRRegs[24]);
                                    break;
                                }
                        }

                        Assert.Equal(0x0000000000000000UL, state.GPRRegs[20]);
                        Assert.Equal(0x0000000000000006UL, state.GPRRegs[23]);
                        Assert.Equal(0xFFFFFFFFA4001554UL, state.GPRRegs[31]);
                        break;
                    }

                default:
                case RegionType.Unknown:
                case RegionType.NTSC:
                    {
                        switch (Cartridge.Current.RomImage.BootRomInformation.CIC)
                        {
                            default:
                            case CICKeyType.Unknown:
                            case CICKeyType.CIC_X102:
                                {
                                    Assert.Equal(0xFFFFFFFFC95973D5UL, state.GPRRegs[5]);
                                    Assert.Equal(0x000000002449A366UL, state.GPRRegs[14]);
                                    break;
                                }
                            case CICKeyType.CIC_X101:
                                {
                                    Assert.Equal(0x000000000000003FUL, state.GPRRegs[22]);
                                    break;
                                }
                            case CICKeyType.CIC_X103:
                                {
                                    Assert.Equal(0xFFFFFFFF95315A28UL, state.GPRRegs[5]);
                                    Assert.Equal(0x000000005BACA1DFUL, state.GPRRegs[14]);
                                    break;
                                }
                            case CICKeyType.CIC_X105:
                                {
                                    AssertEqualMemoryReadU32(0xA4001004, 0x8DA807FC);
                                    Assert.Equal(0x000000005493FB9AUL, state.GPRRegs[5]);
                                    Assert.Equal(0xFFFFFFFFC2C20384UL, state.GPRRegs[14]);
                                    break;
                                }
                            case CICKeyType.CIC_X106:
                                {
                                    Assert.Equal(0xFFFFFFFFE067221FUL, state.GPRRegs[5]);
                                    Assert.Equal(0x000000005CD2B70FUL, state.GPRRegs[14]);
                                    break;
                                }
                        }

                        Assert.Equal(0x0000000000000001UL, state.GPRRegs[20]);
                        Assert.Equal(0x0000000000000000UL, state.GPRRegs[23]);
                        Assert.Equal(0x0000000000000003UL, state.GPRRegs[24]);
                        Assert.Equal(0xFFFFFFFFA4001550UL, state.GPRRegs[31]);
                        break;
                    }
            }

            switch (cic)
            {
                case CICKeyType.CIC_X101:
                    {
                        Assert.Equal(0x000000000000003FUL, state.GPRRegs[22]);
                        break;
                    }
                case CICKeyType.Unknown:
                default:
                case CICKeyType.CIC_X102:
                    {
                        Assert.Equal(0x0000000000000001UL, state.GPRRegs[1]);
                        Assert.Equal(0x000000000EBDA536UL, state.GPRRegs[2]);
                        Assert.Equal(0x000000000EBDA536UL, state.GPRRegs[3]);
                        Assert.Equal(0x000000000000A536UL, state.GPRRegs[4]);
                        Assert.Equal(0xFFFFFFFFED10D0B3UL, state.GPRRegs[12]);
                        Assert.Equal(0x000000001402A4CCUL, state.GPRRegs[13]);
                        Assert.Equal(0x000000003103E121UL, state.GPRRegs[15]);
                        Assert.Equal(0x000000000000003FUL, state.GPRRegs[22]);
                        Assert.Equal(0xFFFFFFFF9DEBB54FUL, state.GPRRegs[25]);
                        break;
                    }
                case CICKeyType.CIC_X103:
                    {
                        Assert.Equal(0x0000000000000001UL, state.GPRRegs[1]);
                        Assert.Equal(0x0000000049A5EE96UL, state.GPRRegs[2]);
                        Assert.Equal(0x0000000049A5EE96UL, state.GPRRegs[3]);
                        Assert.Equal(0x000000000000EE96UL, state.GPRRegs[4]);
                        Assert.Equal(0xFFFFFFFFCE9DFBF7UL, state.GPRRegs[12]);
                        Assert.Equal(0xFFFFFFFFCE9DFBF7UL, state.GPRRegs[13]);
                        Assert.Equal(0x0000000018B63D28UL, state.GPRRegs[15]);
                        Assert.Equal(0x0000000000000078UL, state.GPRRegs[22]);
                        Assert.Equal(0xFFFFFFFF825B21C9UL, state.GPRRegs[25]);
                        break;
                    }
                case CICKeyType.CIC_X105:
                    {
                        AssertEqualMemoryReadU32(0xA4001000, 0x3C0DBFC0);
                        AssertEqualMemoryReadU32(0xA4001008, 0x25AD07C0);
                        AssertEqualMemoryReadU32(0xA400100C, 0x31080080);
                        AssertEqualMemoryReadU32(0xA4001010, 0x5500FFFC);
                        AssertEqualMemoryReadU32(0xA4001014, 0x3C0DBFC0);
                        AssertEqualMemoryReadU32(0xA4001018, 0x8DA80024);
                        AssertEqualMemoryReadU32(0xA400101C, 0x3C0BB000);
                        Assert.Equal(0x0000000000000000UL, state.GPRRegs[1]);
                        Assert.Equal(0xFFFFFFFFF58B0FBFUL, state.GPRRegs[2]);
                        Assert.Equal(0xFFFFFFFFF58B0FBFUL, state.GPRRegs[3]);
                        Assert.Equal(0x0000000000000FBFUL, state.GPRRegs[4]);
                        Assert.Equal(0xFFFFFFFF9651F81EUL, state.GPRRegs[12]);
                        Assert.Equal(0x000000002D42AAC5UL, state.GPRRegs[13]);
                        Assert.Equal(0x0000000056584D60UL, state.GPRRegs[15]);
                        Assert.Equal(0x0000000000000091UL, state.GPRRegs[22]);
                        Assert.Equal(0xFFFFFFFFCDCE565FUL, state.GPRRegs[25]);
                        break;
                    }
                case CICKeyType.CIC_X106:
                    {
                        Assert.Equal(0x0000000000000000UL, state.GPRRegs[1]);
                        Assert.Equal(0xFFFFFFFFA95930A4UL, state.GPRRegs[2]);
                        Assert.Equal(0xFFFFFFFFA95930A4UL, state.GPRRegs[3]);
                        Assert.Equal(0x00000000000030A4UL, state.GPRRegs[4]);
                        Assert.Equal(0xFFFFFFFFBCB59510UL, state.GPRRegs[12]);
                        Assert.Equal(0xFFFFFFFFBCB59510UL, state.GPRRegs[13]);
                        Assert.Equal(0x000000007A3C07F4UL, state.GPRRegs[15]);
                        Assert.Equal(0x0000000000000085UL, state.GPRRegs[22]);
                        Assert.Equal(0x00000000465E3F72UL, state.GPRRegs[25]);
                        break;
                    }
            }
        }