Inline exception processing methods.

master
Nabile Rahmani 2018-12-11 19:39:32 +01:00
parent af652e45b4
commit ca014d07d6
1 changed files with 10 additions and 1 deletions

View File

@ -1,4 +1,6 @@
namespace DotN64.CPU
using System.Runtime.CompilerServices;
namespace DotN64.CPU
{
public partial class VR4300
{
@ -15,12 +17,14 @@
#endregion
#region Methods
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static void HandleReset(VR4300 cpu)
{
cpu.CP0.Registers[(int)SystemControlUnit.RegisterIndex.ErrorEPC] = cpu.PC;
cpu.PC = ResetVector;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static void HandleGeneral(VR4300 cpu, SystemControlUnit.CauseRegister.ExceptionCode excCode, byte? ce = null)
{
cpu.CP0.Cause.ExcCode = excCode;
@ -42,6 +46,7 @@
cpu.PC = (cpu.CP0.Status.DS.BEV ? GeneralVectorBEV : GeneralVector) + GeneralVectorOffset;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void ColdReset(VR4300 cpu)
{
var ds = cpu.CP0.Status.DS;
@ -61,8 +66,10 @@
HandleReset(cpu);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void Interrupt(VR4300 cpu) => HandleGeneral(cpu, SystemControlUnit.CauseRegister.ExceptionCode.Int);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void ReservedInstruction(VR4300 cpu, Instruction instruction)
{
HandleGeneral(cpu, SystemControlUnit.CauseRegister.ExceptionCode.RI);
@ -70,8 +77,10 @@
throw new UnimplementedOperationException(instruction); // TODO: Remove this and the parameter once every instruction gets implemented.
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void CoprocessorUnusable(VR4300 cpu, byte unit) => HandleGeneral(cpu, SystemControlUnit.CauseRegister.ExceptionCode.CpU, unit);
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void FloatingPoint(VR4300 cpu) => HandleGeneral(cpu, SystemControlUnit.CauseRegister.ExceptionCode.FPE);
#endregion
}