From 65c818acf64915aa6b1de12774abab855cb6437b Mon Sep 17 00:00:00 2001 From: Ian C Date: Mon, 21 Aug 2006 00:01:01 +0000 Subject: Added disassembler --- z80.c | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) (limited to 'z80.c') diff --git a/z80.c b/z80.c index 11e466b..0b74bf5 100644 --- a/z80.c +++ b/z80.c @@ -29,6 +29,7 @@ */ #include +#include #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 } -- cgit v1.2.3