Implemented a load more Z80 OpCodes

This commit is contained in:
2026-04-13 18:00:19 +01:00
parent ed0772f27a
commit c642f7a6c6
2 changed files with 63 additions and 3 deletions

View File

@@ -235,6 +235,11 @@ namespace Desktop
case 0x04:
mnemonic = "INC B";
break;
case 0x0E:
byte cImm = _memoryBus.Read((ushort)(currentPc + 1));
mnemonic = $"LD C, 0x{cImm:X2}";
instructionLength = 2;
break;
case 0x10:
sbyte djnzOffset = (sbyte)_memoryBus.Read((ushort)(currentPc + 1));
ushort djnzDest = (ushort)(currentPc + 2 + djnzOffset);
@@ -435,8 +440,11 @@ namespace Desktop
sbyte d = (sbyte)_memoryBus.Read((ushort)(currentPc + 2));
byte cbOpcode = _memoryBus.Read((ushort)(currentPc + 3));
string sign = d >= 0 ? "+" : "";
if (cbOpcode == 0xCE)
if (cbOpcode == 0x4E)
{
mnemonic = $"BIT 1, (IY{sign}{d})";
}
else if (cbOpcode == 0xCE)
{
mnemonic = $"SET 1, (IY{sign}{d})";
}
@@ -453,6 +461,26 @@ namespace Desktop
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 == 0xCE)
{
mnemonic = $"SET 1, (IY{sign}{d})";
}
else if (cbOpcode == 0x8E)
{
mnemonic = $"RES 1, (IY{sign}{d})";
}
else
{
mnemonic = $"FD CB {d:X2} {cbOpcode:X2}"; // Fallback
}
instructionLength = 4;
}
else
{
mnemonic = $"FD PREFIX UNKNOWN (0x{fdOpcode:X2})";