diff z80inst.c @ 314:54c0e5f22198

Show absolute addresses for JR, JRCC and DJNZ in Z80 disassembler
author Mike Pavone <pavone@retrodev.com>
date Thu, 09 May 2013 19:38:28 -0700
parents a13329645ea3
children 140af5509ce7
line wrap: on
line diff
--- a/z80inst.c	Thu May 09 19:24:18 2013 -0700
+++ b/z80inst.c	Thu May 09 19:38:28 2013 -0700
@@ -1371,7 +1371,7 @@
 	"m"
 };
 
-int z80_disasm(z80inst * decoded, char * dst)
+int z80_disasm(z80inst * decoded, char * dst, uint16_t address)
 {
 	int len = sprintf(dst, "%s", z80_mnemonics[decoded->op]);
 	uint8_t needcomma;
@@ -1438,7 +1438,10 @@
 			len += sprintf(dst+len,  "%s (%s)", needcomma ? "," : "" , z80_regs[decoded->ea_reg]);
 			break;
 		case Z80_IMMED:
-			if (decoded->immed >= 63 || decoded->op == Z80_JP || decoded->op == Z80_JPCC || decoded->op == Z80_CALL || decoded->op == Z80_CALLCC || decoded->op == Z80_RST)
+			if (decoded->op == Z80_JR || decoded->op == Z80_JRCC || decoded->op == Z80_DJNZ) {
+					address += 2 + decoded->immed;
+					len += sprintf(dst+len, "%s %X", needcomma ? "," : "" , address);
+			} else if (decoded->immed >= 63 || decoded->op == Z80_JP || decoded->op == Z80_JPCC || decoded->op == Z80_CALL || decoded->op == Z80_CALLCC || decoded->op == Z80_RST)
 			{
 				len += sprintf(dst+len, "%s $%X", needcomma ? "," : "" , decoded->immed);
 			} else {