# HG changeset patch # User Michael Pavone # Date 1490246199 25200 # Node ID 71b1a080b30c4a6f65cb20b427be5c75c292828d # Parent 4e2007c1d8ab1fd7a9e856d429ff385759dd5ce3 Fix SBCD edge cases to pass Flamewing's test ROM. Could use some cleanup to produce better code for the SBCD case, but produces correct results now diff -r 4e2007c1d8ab -r 71b1a080b30c m68k_core_x86.c --- a/m68k_core_x86.c Tue Mar 21 21:59:05 2017 -0700 +++ b/m68k_core_x86.c Wed Mar 22 22:16:39 2017 -0700 @@ -1472,7 +1472,7 @@ } else { sbb_rr(code, other_reg + (AH-RAX), opts->gen.scratch1 + (AH-RAX), SZ_B); } - cmp_ir(code, 0xA, opts->gen.scratch1 + (AH-RAX), SZ_B); + cmp_ir(code, inst->op == M68K_SBCD ? 0x10 : 0xA, opts->gen.scratch1 + (AH-RAX), SZ_B); mov_ir(code, 0xA0, other_reg + (AH-RAX), SZ_B); code_ptr no_adjust = code->cur+1; //add correction factor if necessary @@ -1497,9 +1497,14 @@ //determine if we need a correction on the upper nibble code_ptr def_adjust = code->cur+1; jcc(code, CC_C, def_adjust); - cmp_rr(code, other_reg + (AH-RAX), opts->gen.scratch1, SZ_B); - no_adjust = code->cur+1; - jcc(code, CC_B, no_adjust); + if (inst->op == M68K_SBCD) { + no_adjust = code->cur+1; + jmp(code, no_adjust); + } else { + cmp_rr(code, other_reg + (AH-RAX), opts->gen.scratch1, SZ_B); + no_adjust = code->cur+1; + jcc(code, CC_B, no_adjust); + } *def_adjust = code->cur - (def_adjust + 1); set_flag(opts, 1, FLAG_C); or_ir(code, 0x60, opts->gen.scratch1 + (AH-RAX), SZ_B);