diff options
author | Michael Pavone <pavone@retrodev.com> | 2016-04-24 00:22:38 -0700 |
---|---|---|
committer | Michael Pavone <pavone@retrodev.com> | 2016-04-24 00:22:38 -0700 |
commit | fd345a8336933105ea98c9d2d1cc5602ad611d70 (patch) | |
tree | 679cc25b39ce9c403e02acb62d0f945e02f76f6f | |
parent | ee6de9d8b4b6edc805259b807065099cfd8d1822 (diff) |
Fix order of writes for move.l with a predec destination
-rw-r--r-- | m68k_core.c | 22 | ||||
-rw-r--r-- | m68k_core_x86.c | 2 | ||||
-rw-r--r-- | m68k_internal.h | 2 |
3 files changed, 9 insertions, 17 deletions
diff --git a/m68k_core.c b/m68k_core.c index 0d989d9..a39830b 100644 --- a/m68k_core.c +++ b/m68k_core.c @@ -71,7 +71,7 @@ void m68k_read_size(m68k_options *opts, uint8_t size) } } -void m68k_write_size(m68k_options *opts, uint8_t size) +void m68k_write_size(m68k_options *opts, uint8_t size, uint8_t lowfirst) { switch (size) { @@ -82,30 +82,22 @@ void m68k_write_size(m68k_options *opts, uint8_t size) call(&opts->gen.code, opts->write_16); break; case OPSIZE_LONG: - call(&opts->gen.code, opts->write_32_highfirst); + if (lowfirst) { + call(&opts->gen.code, opts->write_32_lowfirst); + } else { + call(&opts->gen.code, opts->write_32_highfirst); + } break; } } void m68k_save_result(m68kinst * inst, m68k_options * opts) { - code_info *code = &opts->gen.code; if (inst->dst.addr_mode != MODE_REG && inst->dst.addr_mode != MODE_AREG && inst->dst.addr_mode != MODE_UNUSED) { if (inst->dst.addr_mode == MODE_AREG_PREDEC && inst->src.addr_mode == MODE_AREG_PREDEC && inst->op != M68K_MOVE) { areg_to_native(opts, inst->dst.params.regs.pri, opts->gen.scratch2); } - switch (inst->extra.size) - { - case OPSIZE_BYTE: - call(code, opts->write_8); - break; - case OPSIZE_WORD: - call(code, opts->write_16); - break; - case OPSIZE_LONG: - call(code, opts->write_32_lowfirst); - break; - } + m68k_write_size(opts, inst->extra.size, 1); } } diff --git a/m68k_core_x86.c b/m68k_core_x86.c index ee2d6e2..9882b35 100644 --- a/m68k_core_x86.c +++ b/m68k_core_x86.c @@ -692,7 +692,7 @@ void translate_m68k_move(m68k_options * opts, m68kinst * inst) update_flags(opts, N|Z|V0|C0); } if (inst->dst.addr_mode != MODE_REG && inst->dst.addr_mode != MODE_AREG) { - m68k_write_size(opts, inst->extra.size); + m68k_write_size(opts, inst->extra.size, inst->dst.addr_mode == MODE_AREG_PREDEC); if (inst->dst.addr_mode == MODE_AREG_POSTINC) { inc_amount = inst->extra.size == OPSIZE_WORD ? 2 : (inst->extra.size == OPSIZE_LONG ? 4 : (inst->dst.params.regs.pri == 7 ? 2 : 1)); addi_areg(opts, inc_amount, inst->dst.params.regs.pri); diff --git a/m68k_internal.h b/m68k_internal.h index a70da23..b74f06b 100644 --- a/m68k_internal.h +++ b/m68k_internal.h @@ -41,7 +41,7 @@ size_t reg_offset(m68k_op_info *op); void translate_m68k_op(m68kinst * inst, host_ea * ea, m68k_options * opts, uint8_t dst); void print_regs_exit(m68k_context * context); void m68k_read_size(m68k_options *opts, uint8_t size); -void m68k_write_size(m68k_options *opts, uint8_t size); +void m68k_write_size(m68k_options *opts, uint8_t size, uint8_t lowfirst); void m68k_save_result(m68kinst * inst, m68k_options * opts); void push_const(m68k_options *opts, int32_t value); void jump_m68k_abs(m68k_options * opts, uint32_t address); |