From f05442bb40c83d89b276882d79d94e19a74b7127 Mon Sep 17 00:00:00 2001 From: Nabile Rahmani Date: Thu, 29 Nov 2018 04:08:17 +0100 Subject: [PATCH] Format CP0 instructions in its own function. --- .../Diagnostics/Debugger.InstructionFormat.cs | 25 +++++++++---------- DotN64/Diagnostics/Debugger.cs | 2 +- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/DotN64/Diagnostics/Debugger.InstructionFormat.cs b/DotN64/Diagnostics/Debugger.InstructionFormat.cs index 4746805..37cd239 100644 --- a/DotN64/Diagnostics/Debugger.InstructionFormat.cs +++ b/DotN64/Diagnostics/Debugger.InstructionFormat.cs @@ -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 @@ /// 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 } diff --git a/DotN64/Diagnostics/Debugger.cs b/DotN64/Diagnostics/Debugger.cs index ac7881c..d16f8fa 100644 --- a/DotN64/Diagnostics/Debugger.cs +++ b/DotN64/Diagnostics/Debugger.cs @@ -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,