# HG changeset patch # User Michael Pavone # Date 1394001301 28800 # Node ID 0031cd308a31d2df26f0aac50452d256ef30f3b6 # Parent ec1365fb2954ab7c770682273914a669d3016b51 Combine the implementation of ABCD and SBCD in the 68K core diff -r ec1365fb2954 -r 0031cd308a31 m68k_core_x86.c --- a/m68k_core_x86.c Tue Mar 04 22:24:08 2014 -0800 +++ b/m68k_core_x86.c Tue Mar 04 22:35:01 2014 -0800 @@ -1546,6 +1546,7 @@ switch(inst->op) { case M68K_ABCD: + case M68K_SBCD: if (src_op.base != opts->gen.scratch2) { if (src_op.mode == MODE_REG_DIRECT) { mov_rr(code, src_op.base, opts->gen.scratch2, SZ_B); @@ -1562,8 +1563,12 @@ } flag_to_carry(opts, FLAG_X); jcc(code, CC_NC, code->cur + 5); - add_ir(code, 1, opts->gen.scratch1, SZ_B); - call(code, (code_ptr)bcd_add); + if (inst->op == M68K_ABCD) { + add_ir(code, 1, opts->gen.scratch1, SZ_B); + } else { + sub_ir(code, 1, opts->gen.scratch1, SZ_B); + } + call(code, (code_ptr) (inst->op == M68K_ABCD ? bcd_add : bcd_sub)); reg_to_flag(opts, CH, FLAG_C); reg_to_flag(opts, CH, FLAG_X); cmp_ir(code, 0, opts->gen.scratch1, SZ_B); @@ -2258,42 +2263,6 @@ case M68K_RTR: translate_m68k_rtr(opts, inst); break; - case M68K_SBCD: { - if (src_op.base != opts->gen.scratch2) { - if (src_op.mode == MODE_REG_DIRECT) { - mov_rr(code, src_op.base, opts->gen.scratch2, SZ_B); - } else { - mov_rdispr(code, src_op.base, src_op.disp, opts->gen.scratch2, SZ_B); - } - } - if (dst_op.base != opts->gen.scratch1) { - if (dst_op.mode == MODE_REG_DIRECT) { - mov_rr(code, dst_op.base, opts->gen.scratch1, SZ_B); - } else { - mov_rdispr(code, dst_op.base, dst_op.disp, opts->gen.scratch1, SZ_B); - } - } - flag_to_carry(opts, FLAG_X); - jcc(code, CC_NC, code->cur + 5); - sub_ir(code, 1, opts->gen.scratch1, SZ_B); - call(code, (code_ptr)bcd_sub); - reg_to_flag(opts, CH, FLAG_C); - reg_to_flag(opts, CH, FLAG_X); - cmp_ir(code, 0, opts->gen.scratch1, SZ_B); - code_ptr after_flag_set = code->cur+1; - jcc(code, CC_Z, code->cur + 2); - set_flag(opts, 0, FLAG_Z); - *after_flag_set = code->cur - (after_flag_set+1); - if (dst_op.base != opts->gen.scratch1) { - if (dst_op.mode == MODE_REG_DIRECT) { - mov_rr(code, opts->gen.scratch1, dst_op.base, SZ_B); - } else { - mov_rrdisp(code, opts->gen.scratch1, dst_op.base, dst_op.disp, SZ_B); - } - } - m68k_save_result(inst, opts); - break; - } case M68K_STOP: { //TODO: Trap if not in system mode //manual says 4 cycles, but it has to be at least 8 since it's a 2-word instruction