Mercurial > repos > blastem
changeset 1297:71b1a080b30c
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
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Wed, 22 Mar 2017 22:16:39 -0700 |
parents | 4e2007c1d8ab |
children | d5a47597b61f |
files | m68k_core_x86.c |
diffstat | 1 files changed, 9 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- 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);