/// <summary> /// Disassembles an instruction. /// </summary> /// <param name="memory">The memory.</param> /// <returns>A string representing the instruction at <paramref name="memory"/>.R.PC</returns> private static string DisassembleInstructionInternal(GbMemory memory) { byte b = memory.GetMappedMemory(memory.R.Pc); if (b >= 0x40 && b < 0xC0) { if (b < 0x80) { if (b == 0x76) { return("HALT"); } int dest = ((b >> 3) & 7); int src = (b & 7); return("LD " + GetR8(dest) + "," + GetR8(src)); } return(DisassembleInstructionArith(b)); } if (b == 0xCB) { return(DisassembleInstructionCb(memory.GetMappedMemory((ushort)(memory.R.Pc + 1)))); } return(nmOpStrings[b]); }
/// <summary> /// Disassembles an instruction. /// </summary> /// <param name="memory">The memory.</param> /// <returns>A string representing the instruction at <paramref name="memory"/>.R.PC</returns> public static string DisassembleInstruction(GbMemory memory) => "0x" + memory.GetMappedMemory(memory.R.Pc).ToString("X2") + " (" + DisassembleInstructionInternal(memory) + ")";