diff options
author | mrb0nk500 <b0nk@b0nk.xyz> | 2021-01-27 13:42:57 -0500 |
---|---|---|
committer | mrb0nk500 <b0nk@b0nk.xyz> | 2021-01-27 13:42:57 -0500 |
commit | cd6982e5da1f5facdc1e0154b3a27c01e8b076c9 (patch) | |
tree | c8db5ade59d054c6f88ff2ab2cb99df45b250fad /disasm.c | |
parent | 1700d8d10453ffe046438de0e6fbd496def915a1 (diff) |
- Fixed some bugs in the emulator.
- Started work on implementing the Super VIA emulation.
- Added support for disabling disassembly per
instruction, when in debug mode.
- Did some more work on rewriting the SuB Suite to
work with the new calling convention.
- Rewrote the symbol handling code in the emulator's
assembler, to make it both simpler, and to add
support for arbitrarily deep symbol scopes.
- Added support for arbitrarily deep local symbol
scopes.
For example, to declare a symbol of depth 2, you add
two '@' characters to the start of the symbol name.
In other words, the number of '@' characters before
the symbol name is what determines the scope of that
symbol.
And to use a symbol thats outside the current
scope, you would use the same syntax as using a
struct member, so you would do `global.local`.
Diffstat (limited to 'disasm.c')
-rw-r--r-- | disasm.c | 16 |
1 files changed, 8 insertions, 8 deletions
@@ -59,6 +59,7 @@ static void sub_dbg(struct sux *cpu, WINDOW *w, uint64_t address, uint64_t *orth adr = read_value(cpu, 0, tmpad, 7, 0, 0); tmpad += 8; wmove(w, 1, 0); + wclrtoeol(w); wprintw(w, "scr_row: %02u, scr_col: %02u, scr_str: %02u, scr_end: %02u", addr[0], addr[1], addr[2], addr[3]); wmove(w, 2, 0); wprintw(w, "bitabl: "); @@ -173,11 +174,10 @@ static uint64_t get_offset(uint64_t value, uint8_t size, char **sign) { size = (size > 8) ? 8 : size; uint8_t msb = size*8; uint64_t mask = (-(uint64_t)1 >> ((8 - size) * 8)); - mask &= (1 << (msb-1)); + mask &= ~(1 << (msb-1)); *sign = ((value >> (msb-1)) & 1) ? "-" : "+"; - if (*sign[0] == '-') { - value &= mask; - value = -(value+1); + if (*sign[0] == '-' && value != (1 << (msb-1))) { + value = (-value) & mask; } return value; } @@ -301,10 +301,6 @@ static void disasm_ortho(struct sux *cpu, WINDOW *w, uint8_t opcode, uint8_t pre uint64_t val = 0; if (op[i].type) { uint8_t addr_size = get_ortho_addrsize(prefix, op[i].id); - if (addr_size != 0xFF) { - uint64_t value = get_offset(op[i].value, addr_size+1, &sign[i]); - sprintf(address[i], "$%0*"PRIX64, (addr_size+1)*2, value); - } if (op[i].id == MEM_SIB) { sprintf(scale[i], "%u*", op[i].scale+1); } else if (op[i].id == MEM_IMM) { @@ -321,6 +317,10 @@ static void disasm_ortho(struct sux *cpu, WINDOW *w, uint8_t opcode, uint8_t pre case MEM_SIB : case MEM_RIND : is_rind = 1; break; } + if (addr_size != 0xFF) { + uint64_t value = (is_rind) ? get_offset(op[i].value, addr_size+1, &sign[i]) : op[i].value; + sprintf(address[i], "$%0*"PRIX64, (addr_size+1)*2, value); + } if (is_rind) { for (int j = 0; j < 2 && op[i].rind[j] != 0xFF; j++) { switch (op[i].rind[j]) { |