Implemented a load more Z80 OpCodes

This commit is contained in:
2026-04-14 09:56:26 +01:00
parent 08d718f41e
commit 695db41f60
2 changed files with 121 additions and 8 deletions

View File

@@ -362,10 +362,20 @@ namespace Desktop
case 0x37:
mnemonic = "SCF";
break;
case 0x38:
sbyte dC = (sbyte)_memoryBus.Read((ushort)(currentPc + 1));
ushort targetC = (ushort)(currentPc + 2 + dC);
mnemonic = $"JR C, 0x{targetC:X4}";
instructionLength = 2;
break;
case 0x3E:
mnemonic = $"LD A, 0x{_memoryBus.Read((ushort)(currentPc + 1)):X2}";
instructionLength = 2;
break;
case 0x3F:
mnemonic = "CCF";
break;
case 0x47:
mnemonic = "LD B, A";
break;
@@ -384,12 +394,21 @@ namespace Desktop
case 0x62:
mnemonic = "LD H, D";
break;
case 0x67:
mnemonic = "LD H, A";
break;
case 0x6B:
mnemonic = "LD L, E";
break;
case 0x6F:
mnemonic = "LD L, A";
break;
case 0x72:
mnemonic = "LD (HL), D";
break;
case 0x73:
mnemonic = "LD (HL), E";
break;
case 0x77:
mnemonic = "LD (HL), A";
break;
@@ -408,6 +427,9 @@ namespace Desktop
case 0xA7:
mnemonic = "AND A";
break;
case 0xAE:
mnemonic = "XOR (HL)";
break;
case 0xAF:
mnemonic = "XOR A";
break;
@@ -461,6 +483,11 @@ namespace Desktop
mnemonic = $"SBC A, 0x{sbcValue:X2}";
instructionLength = 2;
break;
case 0xE6:
byte andImm = _memoryBus.Read((ushort)(currentPc + 1));
mnemonic = $"AND 0x{andImm:X2}";
instructionLength = 2;
break;
case 0xE9:
mnemonic = "JP (HL)";
break;
@@ -543,12 +570,24 @@ namespace Desktop
mnemonic = $"LD (IY{sign}{d}), 0x{n:X2}";
instructionLength = 4;
}
else if (fdOpcode == 0x6E)
{
sbyte offsetL = (sbyte)_memoryBus.Read((ushort)(currentPc + 2));
string signL = offsetL >= 0 ? "+" : "";
mnemonic = $"LD L, (IY{signL}{offsetL})";
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 == 0x4E)
if (cbOpcode == 0x46)
{
mnemonic = $"BIT 0, (IY{sign}{d})";
}
else if (cbOpcode == 0x4E)
{
mnemonic = $"BIT 1, (IY{sign}{d})";
}
@@ -608,7 +647,7 @@ namespace Desktop
else if (cbOpcode == 0xE6)
{
mnemonic = $"SET 4, (IY{sign}{d})";
}
}
else
{
mnemonic = $"FD CB {d:X2} {cbOpcode:X2}"; // Fallback