Implemented more OpCodes again!
This commit is contained in:
@@ -249,6 +249,7 @@ namespace Desktop
|
||||
byte opcode = _memoryBus.Read(currentPc);
|
||||
string mnemonic;
|
||||
int instructionLength = 1; // Default to 1
|
||||
byte cbOp = 0;
|
||||
|
||||
switch (opcode)
|
||||
{
|
||||
@@ -668,7 +669,7 @@ namespace Desktop
|
||||
mnemonic = "RET";
|
||||
break;
|
||||
case 0xCB:
|
||||
byte cbOp = _memoryBus.Read((ushort)(currentPc + 1));
|
||||
cbOp = _memoryBus.Read((ushort)(currentPc + 1));
|
||||
if (cbOp == 0x7E)
|
||||
{
|
||||
mnemonic = "BIT 7, (HL)";
|
||||
@@ -709,7 +710,6 @@ namespace Desktop
|
||||
case 0xD9:
|
||||
mnemonic = "EXX";
|
||||
break;
|
||||
break;
|
||||
case 0xd5:
|
||||
mnemonic = "PUSH DE";
|
||||
break;
|
||||
@@ -781,6 +781,11 @@ namespace Desktop
|
||||
mnemonic = $"LD DE, (0x{addr5B:X4})";
|
||||
instructionLength = 4;
|
||||
break;
|
||||
case 0x73:
|
||||
ushort addr73 = (ushort)(_memoryBus.Read((ushort)(currentPc + 2)) | (_memoryBus.Read((ushort)(currentPc + 3)) << 8));
|
||||
mnemonic = $"LD (0x{addr73:X4}), SP";
|
||||
instructionLength = 4;
|
||||
break;
|
||||
case 0xB0:
|
||||
mnemonic = "LDIR";
|
||||
instructionLength = 2;
|
||||
@@ -865,34 +870,22 @@ namespace Desktop
|
||||
}
|
||||
else if (fdOpcode == 0xCB) // FD CB prefix
|
||||
{
|
||||
sbyte d = (sbyte)_memoryBus.Read((ushort)(currentPc + 2));
|
||||
byte cbOpcode = _memoryBus.Read((ushort)(currentPc + 3));
|
||||
string sign = d >= 0 ? "+" : "";
|
||||
if (cbOpcode == 0x46)
|
||||
{
|
||||
mnemonic = $"BIT 0, (IY{sign}{d})";
|
||||
}
|
||||
else if (cbOpcode == 0x4E)
|
||||
{
|
||||
mnemonic = $"BIT 1, (IY{sign}{d})";
|
||||
}
|
||||
else if (cbOpcode == 0x86)
|
||||
{
|
||||
mnemonic = $"RES 0, (IY{sign}{d})";
|
||||
}
|
||||
else if (cbOpcode == 0xA6)
|
||||
{
|
||||
mnemonic = $"RES 4, (IY{sign}{d})";
|
||||
}
|
||||
else if (cbOpcode == 0xCE)
|
||||
{
|
||||
mnemonic = $"SET 1, (IY{sign}{d})";
|
||||
}
|
||||
else
|
||||
{
|
||||
mnemonic = $"FD CB {d:X2} {cbOpcode:X2}"; // Fallback
|
||||
}
|
||||
instructionLength = 4;
|
||||
cbOp = _memoryBus.Read((ushort)(currentPc + 1));
|
||||
|
||||
int opGroup = cbOp >> 6;
|
||||
int targetBit = (cbOp >> 3) & 0x07;
|
||||
int regIdx = cbOp & 0x07;
|
||||
|
||||
// Map the 0-7 index directly to the Z80 register names
|
||||
string[] regNames = { "B", "C", "D", "E", "H", "L", "(HL)", "A" };
|
||||
string targetReg = regNames[regIdx];
|
||||
|
||||
if (opGroup == 1) mnemonic = $"BIT {targetBit}, {targetReg}";
|
||||
else if (opGroup == 2) mnemonic = $"RES {targetBit}, {targetReg}";
|
||||
else if (opGroup == 3) mnemonic = $"SET {targetBit}, {targetReg}";
|
||||
else mnemonic = $"CB SHIFT/ROTATE (0x{cbOp:X2})";
|
||||
|
||||
instructionLength = 2;
|
||||
}
|
||||
else if (fdOpcode == 0x71) // LD (IY+d), C
|
||||
{
|
||||
@@ -907,38 +900,7 @@ namespace Desktop
|
||||
string sign = d >= 0 ? "+" : "";
|
||||
mnemonic = $"LD (IY{sign}{d}), L";
|
||||
instructionLength = 3;
|
||||
}
|
||||
else if (fdOpcode == 0xCB) // FD CB prefix
|
||||
{
|
||||
sbyte d = (sbyte)_memoryBus.Read((ushort)(currentPc + 2));
|
||||
byte cbOpcode = _memoryBus.Read((ushort)(currentPc + 3));
|
||||
string sign = d >= 0 ? "+" : "";
|
||||
if (cbOpcode == 0x8E)
|
||||
{
|
||||
mnemonic = $"RES 1, (IY{sign}{d})";
|
||||
}
|
||||
else if (cbOpcode == 0xAE)
|
||||
{
|
||||
mnemonic = $"RES 5, (IY{sign}{d})";
|
||||
}
|
||||
else if (cbOpcode == 0xC6)
|
||||
{
|
||||
mnemonic = $"SET 0, (IY{sign}{d})";
|
||||
}
|
||||
else if (cbOpcode == 0xCE)
|
||||
{
|
||||
mnemonic = $"SET 1, (IY{sign}{d})";
|
||||
}
|
||||
else if (cbOpcode == 0xE6)
|
||||
{
|
||||
mnemonic = $"SET 4, (IY{sign}{d})";
|
||||
}
|
||||
else
|
||||
{
|
||||
mnemonic = $"FD CB {d:X2} {cbOpcode:X2}"; // Fallback
|
||||
}
|
||||
instructionLength = 4;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
mnemonic = $"FD PREFIX UNKNOWN (0x{fdOpcode:X2})";
|
||||
|
||||
Reference in New Issue
Block a user