Mercurial > repos > blastem
changeset 611:744b305965f7
Fix divide by zero exception return address when div instruction is bigger than 1 word
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Sat, 27 Dec 2014 15:49:15 -0800 |
parents | 314373222b1a |
children | 5a6ff0d76032 |
files | m68k_core_x86.c |
diffstat | 1 files changed, 15 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/m68k_core_x86.c Sat Dec 27 14:51:50 2014 -0800 +++ b/m68k_core_x86.c Sat Dec 27 15:49:15 2014 -0800 @@ -1604,6 +1604,20 @@ movzx_rdispr(code, src_op->base, src_op->disp, opts->gen.scratch2, SZ_W, SZ_D); } } + uint32_t isize = 2; + switch(inst->src.addr_mode) + { + case MODE_AREG_DISPLACE: + case MODE_AREG_INDEX_DISP8: + case MODE_ABSOLUTE_SHORT: + case MODE_PC_INDEX_DISP8: + case MODE_IMMEDIATE: + isize = 4; + break; + case MODE_ABSOLUTE: + isize = 6; + break; + } cmp_ir(code, 0, opts->gen.scratch2, SZ_D); check_alloc_code(code, 6*MAX_INST_LEN); code_ptr not_zero = code->cur + 1; @@ -1611,7 +1625,7 @@ pop_r(code, RAX); pop_r(code, RDX); mov_ir(code, VECTOR_INT_DIV_ZERO, opts->gen.scratch2, SZ_D); - mov_ir(code, inst->address+2, opts->gen.scratch1, SZ_D); + mov_ir(code, inst->address+isize, opts->gen.scratch1, SZ_D); jmp(code, opts->trap); *not_zero = code->cur - (not_zero+1); if (inst->op == M68K_DIVS) {