Format CP0 instructions in its own function.

master
Nabile Rahmani 2018-11-29 04:08:17 +01:00
parent 6132f8ec15
commit f05442bb40
2 changed files with 13 additions and 14 deletions

View File

@ -119,19 +119,6 @@
return Format(instruction, FormatRegister(instruction.RD, cpu), FormatRegister(instruction.RT, cpu), (sbyte)instruction.SA);
}
switch (instruction.OP)
{
case VR4300.OpCode.COP0:
switch ((VR4300.SystemControlUnit.OpCode)instruction.RS)
{
case VR4300.SystemControlUnit.OpCode.MT:
case VR4300.SystemControlUnit.OpCode.MF:
return Format(instruction, FormatRegister(instruction.RT, cpu), FormatCP0Register(instruction.RD, cpu));
default:
return FormatOpCode(instruction);
}
}
return Format(instruction, FormatRegister(instruction.RD, cpu), FormatRegister(instruction.RS, cpu), FormatRegister(instruction.RT, cpu));
}
@ -140,6 +127,18 @@
/// </summary>
public static string J(VR4300.Instruction instruction, VR4300 cpu) => Format(instruction, $"0x{((cpu != null ? (cpu.DelaySlot ?? cpu.PC) : 0) & ~(ulong)((1 << 28) - 1)) | (instruction.Target << 2):X8}");
public static string CP0(VR4300.Instruction instruction, VR4300 cpu)
{
switch ((VR4300.SystemControlUnit.OpCode)instruction.RS)
{
case VR4300.SystemControlUnit.OpCode.MT:
case VR4300.SystemControlUnit.OpCode.MF:
return Format(instruction, FormatRegister(instruction.RT, cpu), FormatCP0Register(instruction.RD, cpu));
default:
return FormatOpCode(instruction);
}
}
public static string Unknown(VR4300.Instruction instruction) => FormatOpCode(instruction);
#endregion
}

View File

@ -28,7 +28,7 @@ namespace DotN64.Diagnostics
[VR4300.Instruction.From(VR4300.OpCode.BNE)] = InstructionFormat.I,
[VR4300.Instruction.From(VR4300.OpCode.BNEL)] = InstructionFormat.I,
[VR4300.Instruction.From(VR4300.OpCode.CACHE)] = null,
[VR4300.Instruction.From(VR4300.OpCode.COP0)] = InstructionFormat.R, // FIXME: all CP0 ops are treated as such at the moment.
[VR4300.Instruction.From(VR4300.OpCode.COP0)] = InstructionFormat.CP0,
[VR4300.Instruction.From(VR4300.OpCode.JAL)] = InstructionFormat.J,
[VR4300.Instruction.From(VR4300.OpCode.J)] = InstructionFormat.J,
[VR4300.Instruction.From(VR4300.OpCode.LB)] = InstructionFormat.I,