diff options
Diffstat (limited to 'sux.h')
-rw-r--r-- | sux.h | 15 |
1 files changed, 8 insertions, 7 deletions
@@ -19,7 +19,7 @@ #define STEP_ADDR 0x110 #define CURSES_BACKSPACE 0x7F -#define copy64 1 +#define copy64 extern uint8_t kbd_rdy; extern uint8_t dbg_print_per_inst; @@ -338,7 +338,7 @@ static int is_ind(uint8_t type) { } static void *memcopy(void *restrict dst, const void *restrict src, unsigned int n) { - #if copy64 + #ifdef copy64 uint64_t *d = dst; const uint64_t *s = src; unsigned int r = n % 8; @@ -348,7 +348,7 @@ static void *memcopy(void *restrict dst, const void *restrict src, unsigned int const uint8_t *s = src; #endif for (; n; *d++ = *s++, n--); - #if copy64 + #ifdef copy64 if (r) { uint64_t mask = (-(uint64_t)1 >> ((8 - r) * 8)); *d = (*d & ~mask) | (*s & mask); @@ -609,6 +609,7 @@ static /*inline*/ uint64_t get_ortho_addr(struct sux *cpu, uint8_t opcode, uint8 uint64_t tmp_val = 0; if (is_rind) { for (int j = 0; j < 2 && op[i].rind[j] != 0xFF; j++) { + int is_index = ((!j && op[i].rind[1] == 0xFF) || j); uint64_t reg; switch (op[i].rind[j]) { case REG_A : reg = cpu->a; break; @@ -628,11 +629,11 @@ static /*inline*/ uint64_t get_ortho_addr(struct sux *cpu, uint8_t opcode, uint8 case REG_R14: reg = cpu->r14; break; case REG_R15: reg = cpu->r15; break; } + + reg *= (is_index && op[i].id == MEM_SIB) ? op[i].scale+1 : 1; tmp_val += reg; } - if (op[i].id == MEM_SIB) { - tmp_val *= op[i].scale+1; - } else if (addr_size != 0xFF) { + if (addr_size != 0xFF) { switch (addr_size) { case 0: value[i] = (int8_t )value[i]; break; case 1: value[i] = (int16_t)value[i]; break; @@ -1361,7 +1362,7 @@ static /*inline*/ void exec_ext_inst(struct sux *cpu, uint8_t opcode, uint8_t pr bit_test(cpu, cpu->a, value, thread); break; case MMV_IMP: /* Memory MoVe. */ - cpu->b = mem_move(cpu, cpu->b, cpu->x, cpu->y, 0, size, thread); + cpu->b = mem_move(cpu, cpu->b, cpu->x, cpu->y, 1, size, thread); break; case SWP_A : /* SWaP lower half, with upper half. */ cpu->a = swap(cpu, cpu->a, size, thread); |