Skip to content

Commit

Permalink
Z80Converter: WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
nzeemin committed Mar 31, 2024
1 parent e410a60 commit 2bdd66f
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Z80Converter/dasmz80.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ static const char *Mnemonics[256] =
"RET NC", "POP DE", "JP NC,#h", "OUTA (*h)", "CALL NC,#h", "PUSH DE", "SUB *h", "RST 10h",
"RET C", "EXX", "JP C,#h", "INA (*h)", "CALL C,#h", "PFX_DD", "SBC *h", "RST 18h",
"RET PO", "POP HL", "JP PO,#h", "EX HL,(SP)", "CALL PO,#h", "PUSH HL", "AND *h", "RST 20h",
"RET PE", "LD PC,HL", "JP PE,#h", "EX DE,HL", "CALL PE,#h", "PFX_ED", "XOR *h", "RST 28h",
"RET PE", "JP (HL)", "JP PE,#h", "EX DE,HL", "CALL PE,#h", "PFX_ED", "XOR *h", "RST 28h",
"RET P", "POP AF", "JP P,#h", "DI", "CALL P,#h", "PUSH AF", "OR *h", "RST 30h",
"RET M", "LD SP,HL", "JP M,#h", "EI", "CALL M,#h", "PFX_FD", "CP *h", "RST 38h"
};
Expand Down
56 changes: 45 additions & 11 deletions Z80Converter/recomp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,26 +186,27 @@ string PatternProc_JR_CNC()
return buffer;
}

string PatternProc_RLA()
{
return "ROLB R0";
}
string PatternProc_RRA()
{
return "RORB R0";
}

string PatternProc_ROLL_A()
{
switch (g_command[0])
{
case 0x07: /* rlca */ return "ROLB R0";
case 0x0F: /* rrca */ return "RORB R0";
case 0x17: /* rla */ return "???";
case 0x1F: /* rra */ return "???";
case 0x17: /* rla */ return PatternProc_RLA();
case 0x1F: /* rra */ return PatternProc_RRA();
}
return "";
return "???";
}

string PatternProc_RLA()
{
return "ROLB R0";
}
string PatternProc_RRA()
{
return "RORB R0";
}
string PatternProc_SRL_A()
{
return "ASRB R0 or ASR R0";
Expand Down Expand Up @@ -431,6 +432,31 @@ string PatternProc_XOR_A()
{
return "CLR R0";
}
//NOTE: Íåò îïåðàöèè XORB
string PatternProc_XOR_R()
{
switch (g_command[0])
{
case 0xA8: /* xor b */ return "???";
case 0xA9: /* xor c */ return "XOR R1, R0";
case 0xAA: /* xor d */ return "???";
case 0xAB: /* xor e */ return "XOR R2, R0";
case 0xAC: /* xor h */ return "???";
case 0xAD: /* xor l */ return "XOR R3, R0";
case 0xAE: /* xor (hl) */ return "???"; // òóò ñëîæíîñòè, ïîòîìó ÷òî íóæíà áàéòîâàÿ îïåðàöèÿ
case 0xAF: /* xor a */ return PatternProc_XOR_A();
}
return "???";
}
string PatternProc_XOR_NN()
{
uint8_t bparam = g_command[1];
char buffer[40];
_snprintf(buffer, sizeof(buffer), "XOR #%03o, R0", bparam);
return buffer;
}


string PatternProc_OR_A()
{
return "TST R0 or TSTB R0";
Expand Down Expand Up @@ -472,6 +498,11 @@ string PatternProc_SUB_X()
return "";
}

string PatternProc_JP_HLADDR()
{
return "JMP (R3)";
}

string PatternProc_JP()
{
uint16_t wparam = g_command[1] + g_command[2] * 256;
Expand Down Expand Up @@ -827,6 +858,7 @@ Pattern g_patterns[] =
{ 1, { 0xA6 }, { 0xEF }, PatternProc_ANDOR_A_HLADDR },
{ 1, { 0xA7 }, { 0xFF }, PatternProc_AND_A },
{ 1, { 0xAF }, { 0xFF }, PatternProc_XOR_A },
{ 1, { 0xA8 }, { 0xF8 }, PatternProc_XOR_R }, // xor r, xor (HL)
{ 1, { 0xB7 }, { 0xFF }, PatternProc_OR_A },
{ 1, { 0xBE }, { 0xFF }, PatternProc_CP_HLADDR }, // cp (HL)
{ 1, { 0xC0 }, { 0xC7 }, PatternProc_RET_CC },
Expand All @@ -840,7 +872,9 @@ Pattern g_patterns[] =
{ 1, { 0xCD }, { 0xFF }, PatternProc_CALL },
{ 1, { 0xD6 }, { 0xFF }, PatternProc_SUB_A_NN },
{ 1, { 0xE6 }, { 0xEF }, PatternProc_ANDOR_A_NN },
{ 1, { 0xE9 }, { 0xEF }, PatternProc_JP_HLADDR },
{ 1, { 0xEB }, { 0xEF }, PatternProc_EX_DE_HL },
{ 1, { 0xEE }, { 0xFF }, PatternProc_XOR_NN },
{ 1, { 0xFE }, { 0xFF }, PatternProc_CP_XX },

// CB table
Expand Down

0 comments on commit 2bdd66f

Please sign in to comment.