コード例 #1
0
 private void Inst_Addi(MipsInstruction inst)
 {
     if (!MipsState.Operating64BitMode)
     {
         try
         {
             MipsState.WriteGPR32Signed(inst.Rt, MipsState.ReadGPR32Signed(inst.Rs) + (Int32)(Int16)inst.Immediate);
         }
         catch (OverflowException)
         {
             CauseException = ExceptionCode.OverFlow;
         }
     }
     else
     {
         try
         {
             MipsState.WriteGPRSigned(inst.Rt, MipsState.ReadGPRSigned(inst.Rs) + (Int64)(Int16)inst.Immediate);
         }
         catch (OverflowException)
         {
             CauseException = ExceptionCode.OverFlow;
         }
     }
 }
コード例 #2
0
ファイル: Interpreter_Load.cs プロジェクト: TylerCode/Soft64
        private void Inst_Lh(MipsInstruction inst)
        {
            try
            {
                Int64 address = ComputeAddress(inst);

                if ((address & 3) != 0)
                {
                    CauseException = ExceptionCode.AddressErrorLoad;
                    return;
                }

                if (!MipsState.Operating64BitMode)
                {
                    MipsState.WriteGPR32Signed(inst.Rt, DataManipulator.LoadHalfwordSigned(address));
                }
                else
                {
                    MipsState.WriteGPRSigned(inst.Rt, DataManipulator.LoadHalfwordSigned(address));
                }
            }
            catch (TLBException tlbe)
            {
                switch (tlbe.ExceptionType)
                {
                case TLBExceptionType.Invalid: CauseException = ExceptionCode.Invalid; break;

                case TLBExceptionType.Mod: CauseException = ExceptionCode.TlbMod; break;

                case TLBExceptionType.Refill: CauseException = ExceptionCode.TlbStore; break;

                default: break;
                }
            }
        }
コード例 #3
0
 private void Inst_Add(MipsInstruction inst)
 {
     if (!MipsState.Operating64BitMode)
     {
         try
         {
             MipsState.WriteGPR32Signed(inst.Rd, MipsState.ReadGPR32Signed(inst.Rs) + MipsState.ReadGPR32Signed(inst.Rt));
         }
         catch (OverflowException)
         {
             CauseException = ExceptionCode.OverFlow;
         }
     }
     else
     {
         if (MipsState.ReadGPRUnsigned(inst.Rs).IsSigned32() && MipsState.ReadGPRUnsigned(inst.Rt).IsSigned32())
         {
             try
             {
                 MipsState.WriteGPRSigned(inst.Rd, MipsState.ReadGPRSigned(inst.Rs) + MipsState.ReadGPRSigned(inst.Rt));
             }
             catch (OverflowException)
             {
                 CauseException = ExceptionCode.OverFlow;
             }
         }
     }
 }
コード例 #4
0
ファイル: Interpreter_Load.cs プロジェクト: TylerCode/Soft64
        private void Inst_Lbu(MipsInstruction inst)
        {
            try
            {
                if (!MipsState.Operating64BitMode)
                {
                    MipsState.WriteGPR32Signed(inst.Rt, DataManipulator.LoadByteUnsigned(ComputeAddress(inst)));
                }
                else
                {
                    MipsState.WriteGPRSigned(inst.Rt, DataManipulator.LoadByteUnsigned(ComputeAddress(inst)));
                }
            }
            catch (TLBException tlbe)
            {
                switch (tlbe.ExceptionType)
                {
                case TLBExceptionType.Invalid: CauseException = ExceptionCode.Invalid; break;

                case TLBExceptionType.Mod: CauseException = ExceptionCode.TlbMod; break;

                case TLBExceptionType.Refill: CauseException = ExceptionCode.TlbStore; break;

                default: break;
                }
            }
        }
コード例 #5
0
 private void Inst_Xori(MipsInstruction inst)
 {
     if (!MipsState.Operating64BitMode)
     {
         MipsState.WriteGPR32Signed(inst.Rt, MipsState.ReadGPR32Signed(inst.Rs) ^ (Int32)(Int16)inst.Immediate);
     }
     else
     {
         MipsState.WriteGPRSigned(inst.Rt, MipsState.ReadGPRSigned(inst.Rs) ^ (Int64)(Int16)inst.Immediate);
     }
 }
コード例 #6
0
 private void Inst_Dsra32(MipsInstruction inst)
 {
     if (MipsState.Operating64BitMode)
     {
         MipsState.WriteGPRSigned(inst.Rd, (MipsState.ReadGPRSigned(inst.Rt) >> (32 + inst.ShiftAmount)));
     }
     else
     {
         CauseException = ExceptionCode.ReservedInstruction;
     }
 }
コード例 #7
0
 private void Inst_Dsrav(MipsInstruction inst)
 {
     if (MipsState.Operating64BitMode)
     {
         MipsState.WriteGPRSigned(inst.Rd, MipsState.ReadGPRSigned(inst.Rt) >> (MipsState.ReadGPR32Signed(inst.Rs) & 0x3F));
     }
     else
     {
         CauseException = ExceptionCode.ReservedInstruction;
     }
 }
コード例 #8
0
        private void Inst_Srav(MipsInstruction inst)
        {
            Int32 result = MipsState.ReadGPR32Signed(inst.Rt) >> (MipsState.ReadGPR32Signed(inst.Rs) & 0x1F);

            if (!MipsState.Operating64BitMode)
            {
                MipsState.WriteGPR32Signed(inst.Rd, result);
            }
            else
            {
                MipsState.WriteGPRSigned(inst.Rd, result);
            }
        }
コード例 #9
0
        private void Inst_Sra(MipsInstruction inst)
        {
            Int32 result = MipsState.ReadGPR32Signed(inst.Rt) >> inst.ShiftAmount;

            if (!MipsState.Operating64BitMode)
            {
                MipsState.WriteGPR32Signed(inst.Rd, result);
            }
            else
            {
                MipsState.WriteGPRSigned(inst.Rd, result);
            }
        }
コード例 #10
0
 private void Inst_Dsub(MipsInstruction inst)
 {
     if (MipsState.Operating64BitMode)
     {
         try
         {
             MipsState.WriteGPRSigned(inst.Rd, MipsState.ReadGPRSigned(inst.Rs) - MipsState.ReadGPRSigned(inst.Rt));
         }
         catch (OverflowException)
         {
             CauseException = ExceptionCode.OverFlow;
         }
     }
     else
     {
         CauseException = ExceptionCode.ReservedInstruction;
     }
 }
コード例 #11
0
 private void Inst_Dadid(MipsInstruction inst)
 {
     if (MipsState.Operating64BitMode)
     {
         try
         {
             MipsState.WriteGPRSigned(inst.Rd, MipsState.ReadGPRSigned(inst.Rs) + (Int64)(Int16)inst.Immediate);
         }
         catch (OverflowException)
         {
             CauseException = ExceptionCode.OverFlow;
         }
     }
     else
     {
         CauseException = ExceptionCode.ReservedInstruction;
     }
 }
コード例 #12
0
ファイル: Interpreter_Load.cs プロジェクト: TylerCode/Soft64
        private void Inst_Lw(MipsInstruction inst)
        {
            Int64 address = ComputeAddress(inst);

            if ((address & 3) != 0)
            {
                CauseException = ExceptionCode.AddressErrorLoad;
            }
            else
            {
                if (!MipsState.Operating64BitMode)
                {
                    MipsState.WriteGPR32Signed(inst.Rt, DataManipulator.LoadWordSigned(address));
                }
                else
                {
                    MipsState.WriteGPRSigned(inst.Rt, DataManipulator.LoadWordSigned(address));
                }
            }
        }
コード例 #13
0
        private void Inst_Sllv(MipsInstruction inst)
        {
            Int32 shiftAmount = MipsState.ReadGPR32Signed(inst.Rs) & 0x1F;

            if (!MipsState.Operating64BitMode)
            {
                MipsState.WriteGPR32Unsigned(inst.Rd, MipsState.ReadGPR32Unsigned(inst.Rt) << shiftAmount);
            }
            else
            {
                UInt64 result = MipsState.ReadGPRUnsigned(inst.Rt) << shiftAmount;

                /* Truncate */
                if (shiftAmount == 0)
                {
                    MipsState.WriteGPRSigned(inst.Rd, (Int32)(UInt32)result);
                }
                else
                {
                    MipsState.WriteGPRUnsigned(inst.Rd, result);
                }
            }
        }
コード例 #14
0
 private void Inst_Jalr(MipsInstruction inst)
 {
     DoJump(MipsState.ReadGPRSigned(inst.Rs));
     MipsState.WriteGPRSigned(inst.Rd, inst.Address + 8);
 }
コード例 #15
0
 private void Inst_Jal(MipsInstruction inst)
 {
     MipsState.WriteGPRSigned(31, inst.Address + 8);
     DoJump(JumpComputeTargetAddress(inst));
 }
コード例 #16
0
 private void Inst_Bgezall(MipsInstruction inst)
 {
     Inst_Bgezl(inst);
     MipsState.WriteGPRSigned(31, inst.Address + 8);
 }