private readonly Action[] instructionTable = new Action[256];
// in ctor, for example:
instructionTable[0x48] = () => LD_R_R(C, B); // LD C, B
instructionTable[0x49] = () => LD_R_R(C, C); // LD C, C
instructionTable[0x4A] = () => LD_R_R(C, D); // LD C, D
private void LD_R_R(byte dest, byte source)
{
Registers.RegisterSet[dest] = Registers.RegisterSet[source];
LogInstructionExec($"0x{_currentInstruction:X2}: LD {Registers.RegisterName(dest)}, {Registers.RegisterName(source)}:0x{Registers.RegisterSet[source]:X2}");
}
// calling:
_currentInstruction = Fetch();
switch (_currentInstruction)
{
case 0xDD:
DDInstructionTable[_currentInstruction](); break;
case 0xFD:
FDInstructionTable[_currentInstruction](); break;
case 0xED:
EDInstructionTable[_currentInstruction](); break;
case 0xCB:
CBInstructionTable[_currentInstruction](); break;
default:
instructionTable[_currentInstruction](); break;
}
private readonly Action[] instructionTable = new Action[256];
// in ctor, for example:
instructionTable[0x48] = () => LD_R_R(C, B); // LD C, B
instructionTable[0x49] = () => LD_R_R(C, C); // LD C, C
instructionTable[0x4A] = () => LD_R_R(C, D); // LD C, D
private void LD_R_R(byte dest, byte source)
{
Registers.RegisterSet[dest] = Registers.RegisterSet[source];
LogInstructionExec($"0x{_currentInstruction:X2}: LD {Registers.RegisterName(dest)}, {Registers.RegisterName(source)}:0x{Registers.RegisterSet[source]:X2}");
}
// calling:
_currentInstruction = Fetch();
switch (_currentInstruction)
{
case 0xDD:
DDInstructionTable[_currentInstruction](); break;
case 0xFD:
FDInstructionTable[_currentInstruction](); break;
case 0xED:
EDInstructionTable[_currentInstruction](); break;
case 0xCB:
CBInstructionTable[_currentInstruction](); break;
default:
instructionTable[_currentInstruction](); break;
}