# HG changeset patch # User Michael Pavone # Date 1461482558 25200 # Node ID 771875b5f519db776b9476e893d73aecaf4b7300 # Parent 34b811ea1e7cb2479a2c6df63dbb36c3b01fbbc1 Fix order of writes for move.l with a predec destination diff -r 34b811ea1e7c -r 771875b5f519 m68k_core.c --- a/m68k_core.c Sat Apr 23 18:14:01 2016 -0700 +++ b/m68k_core.c Sun Apr 24 00:22:38 2016 -0700 @@ -71,7 +71,7 @@ } } -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 @@ 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 -r 34b811ea1e7c -r 771875b5f519 m68k_core_x86.c --- a/m68k_core_x86.c Sat Apr 23 18:14:01 2016 -0700 +++ b/m68k_core_x86.c Sun Apr 24 00:22:38 2016 -0700 @@ -692,7 +692,7 @@ 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 -r 34b811ea1e7c -r 771875b5f519 m68k_internal.h --- a/m68k_internal.h Sat Apr 23 18:14:01 2016 -0700 +++ b/m68k_internal.h Sun Apr 24 00:22:38 2016 -0700 @@ -41,7 +41,7 @@ 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);