1
0
mirror of https://github.com/ggambetta/libz80.git synced 2025-04-18 18:44:02 +03:00

Merge pull request #14 from internalregister/fix_debug_two_bytes_op

Fix Z80Debug function when printing OPs with two bytes.
This commit is contained in:
Gabriel Gambetta 2022-03-01 08:55:57 +01:00 committed by GitHub
commit 7371ee85a1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 8 deletions

View File

@ -372,10 +372,11 @@ typedef enum
OP_NONE,
OP_BYTE,
OP_OFFSET,
OP_WORD
OP_WORD,
OP_BYTE_BYTE
} Z80OperandType;
char* OpTypeName[] = { "OP_NONE", "OP_BYTE", "OP_OFFSET", "OP_WORD" };
char* OpTypeName[] = { "OP_NONE", "OP_BYTE", "OP_OFFSET", "OP_WORD", "OP_BYTE_BYTE" };
struct Z80OpcodeTable;
@ -604,7 +605,14 @@ void scanOpcodes(FILE* opcodes, struct Z80OpcodeTable* mainTable)
}
else if ((tt == TT_N) | (tt == TT_D))
{
opType = OP_BYTE;
if (opType == OP_NONE)
{
opType = OP_BYTE;
}
else
{
opType = OP_BYTE_BYTE;
}
}
else if (tt == TT_E)
{

View File

@ -582,7 +582,7 @@ static const struct Z80OpcodeTable opcodes_DD = { 0, {
{ NULL , OP_NONE , NULL , NULL },
{ INC_off_IX_d , OP_BYTE , "INC (IX+0%02Xh)" , NULL },
{ DEC_off_IX_d , OP_BYTE , "DEC (IX+0%02Xh)" , NULL },
{ LD_off_IX_d_n , OP_BYTE , "LD (IX+0%02Xh),0%02Xh", NULL },
{ LD_off_IX_d_n , OP_BYTE_BYTE, "LD (IX+0%02Xh),0%02Xh", NULL },
{ NULL , OP_NONE , NULL , NULL },
{ NULL , OP_NONE , NULL , NULL },
{ ADD_IX_SP , OP_NONE , "ADD IX,SP" , NULL },
@ -1362,7 +1362,7 @@ static const struct Z80OpcodeTable opcodes_FD = { 0, {
{ NULL , OP_NONE , NULL , NULL },
{ INC_off_IY_d , OP_BYTE , "INC (IY+0%02Xh)" , NULL },
{ DEC_off_IY_d , OP_BYTE , "DEC (IY+0%02Xh)" , NULL },
{ LD_off_IY_d_n , OP_BYTE , "LD (IY+0%02Xh),0%02Xh", NULL },
{ LD_off_IY_d_n , OP_BYTE_BYTE, "LD (IY+0%02Xh),0%02Xh", NULL },
{ NULL , OP_NONE , NULL , NULL },
{ NULL , OP_NONE , NULL , NULL },
{ ADD_IY_SP , OP_NONE , "ADD IY,SP" , NULL },

12
z80.c
View File

@ -101,7 +101,8 @@ typedef enum
OP_NONE,
OP_BYTE,
OP_OFFSET,
OP_WORD
OP_WORD,
OP_BYTE_BYTE
} Z80OperandType;
typedef void (*Z80OpcodeFunc) (Z80Context* ctx);
@ -816,14 +817,19 @@ void Z80Debug (Z80Context* ctx, char* dump, char* decode)
size++;
else
size += 2;
if (entries[opcode].operand_type != OP_WORD)
if (entries[opcode].operand_type != OP_WORD && entries[opcode].operand_type != OP_BYTE_BYTE)
{
parm &= 0xFF;
size--;
}
if (decode)
sprintf(decode, fmt, parm);
{
if (entries[opcode].operand_type == OP_BYTE_BYTE)
sprintf(decode, fmt, parm & 0xFF, parm >> 8);
else
sprintf(decode, fmt, parm);
}
PC += offset;
break;