diff options
Diffstat (limited to 'z80.c')
-rw-r--r-- | z80.c | 30 |
1 files changed, 25 insertions, 5 deletions
@@ -29,6 +29,7 @@ */ #include <stdlib.h> +#include <string.h> #include "z80.h" #include "z80_private.h" @@ -310,13 +311,32 @@ Z80Val Z80Cycles(Z80 *cpu) } -const char *Z80Disassemble(Z80 *cpu, Z80Word *addr) +const char *Z80Disassemble(Z80 *cpu, Z80Word *pc) { -#ifdef Z80_DISASSEMBLER_ENABLED - (*addr)+=4; - return "NO DISASSEMBLER"; +#ifdef ENABLE_DISASSEM + static char s[80]; + Z80Word opc,npc; + Z80Byte op; + int f; + + opc=*pc; + op=Z80_Dis_FetchByte(cpu,pc); + dis_opcode_z80[op](cpu,op,pc); + npc=*pc; + + strcpy(s,Z80_Dis_Printf("%-5s",Z80_Dis_GetOp())); + strcat(s,Z80_Dis_Printf("%-40s ;",Z80_Dis_GetArg())); + + for(f=0;f<5 && opc!=npc;f++) + strcat(s,Z80_Dis_Printf(" %.2x",(int)cpu->memory[opc++])); + + if (opc!=npc) + for(f=1;f<3;f++) + s[strlen(s)-f]='.'; + + return s; #else - (*addr)+=4; + (*pc)+=4; return "NO DISASSEMBLER"; #endif } |