diff options
author | mrb0nk500 <b0nk@b0nk.xyz> | 2021-02-25 12:43:11 -0500 |
---|---|---|
committer | mrb0nk500 <b0nk@b0nk.xyz> | 2021-02-25 12:43:11 -0500 |
commit | 35a18609864470b3dc49f3a9a6cb6ec93e57300d (patch) | |
tree | c52364211b25723b2cf4595ed6c4bc2d45195062 /disasm.c | |
parent | 8d7f27d9a0b61d3694a62f3e54be885d8073f02b (diff) |
- Implemented the multiply expression into the assembler.
- Implemented support for the SIB addressing mode into
the assembler.
SIB is short for "Scale Index, and Base", and works
much like x86's version of SIB (scale*index+base),
although my version supports any scale value between
1, and 256.
- Redid the line shifting routine in SuBEditor.
It now uses memcpy, and memset to do that, and also
supports shifting the line left, or right by any
number of characters.
Diffstat (limited to 'disasm.c')
-rw-r--r-- | disasm.c | 16 |
1 files changed, 15 insertions, 1 deletions
@@ -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]; |