summaryrefslogtreecommitdiff
path: root/disasm.c
diff options
context:
space:
mode:
Diffstat (limited to 'disasm.c')
-rw-r--r--disasm.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/disasm.c b/disasm.c
index 645d17e..38770da 100644
--- a/disasm.c
+++ b/disasm.c
@@ -486,6 +486,20 @@ void disasm(struct sux *cpu, WINDOW *w, uint8_t lines, uint8_t opcode, uint8_t p
case 7 : sign = ((int64_t)value < 0) ? "-" : "+"; break;
}
value = (sign[0] == '-') ? (~value + 1) & mask.u64 : value;
+ if (inst_type == REL) {
+ value = (sign[0] == '-') ? -value : value;
+ value += (cpu->pc + 1);
+ sign = "";
+ }
+
+ addrsize = 0;
+ uint64_t max_val = 0;
+ for (int i = 0; i <= 64; i += 8, addrsize++) {
+ max_val |= (0xFF << i);
+ if (value <= max_val) {
+ break;
+ }
+ }
}
switch (inst_type) {
case BREG :
@@ -498,13 +512,13 @@ void disasm(struct sux *cpu, WINDOW *w, uint8_t lines, uint8_t opcode, uint8_t p
case IND :
case INDX :
case INDY : ind = "("; /* Falls through. */
+ case REL :
case ZMX :
case ZMY :
case ABSX :
case ABSY :
case ZM :
case ABS : wprintw(w, "%s%s %s%s%s$%0*" PRIX64"%s" , op, postfix, ind, of, sign, (addrsize+1) << 1, value, idx); break;
- case REL : wprintw(w, "%s%s %s$%0*"PRIX64 , op, postfix, sign, (addrsize+1) << 1, value); break;
}
} else {
inst_name = ortho_opname[opcode];