# HG changeset patch # User Mike Pavone # Date 1357062017 28800 # Node ID 3e68e517cc01611aa09c3aa4125d58f7f582f692 # Parent 139e5dcd6aa3a17a9e3250f5f6f228d4793d4e9f Do a sync when interrupt mask changes so we can recompute the next interrupt cycle. Also fix a bug in which the SR part of ORI to SR was not being performed. diff -r 139e5dcd6aa3 -r 3e68e517cc01 m68k_to_x86.c --- a/m68k_to_x86.c Tue Jan 01 07:06:57 2013 -0800 +++ b/m68k_to_x86.c Tue Jan 01 09:40:17 2013 -0800 @@ -42,6 +42,7 @@ void set_sr(); void set_ccr(); void get_sr(); +void do_sync(); void m68k_start_context(uint8_t * addr, m68k_context * context); uint8_t * cycles(uint8_t * dst, uint32_t num) @@ -2247,6 +2248,9 @@ dst = mov_rdisp8r(dst, CONTEXT, offsetof(m68k_context, aregs) + sizeof(uint32_t) * 8, opts->aregs[7], SZ_B); dst = mov_rrdisp8(dst, SCRATCH1, CONTEXT, offsetof(m68k_context, aregs) + sizeof(uint32_t) * 8, SZ_B); } + if (inst->src.params.immed & 0x700) { + dst = call(dst, (uint8_t *)do_sync); + } } break; case M68K_ASL: @@ -2447,6 +2451,7 @@ dst = mov_rdisp8r(dst, CONTEXT, offsetof(m68k_context, aregs) + sizeof(uint32_t) * 8, opts->aregs[7], SZ_D); dst = mov_rrdisp8(dst, SCRATCH1, CONTEXT, offsetof(m68k_context, aregs) + sizeof(uint32_t) * 8, SZ_D); } + dst = call(dst, (uint8_t *)do_sync); } dst = cycles(dst, 12); } else { @@ -2557,8 +2562,11 @@ if (inst->src.params.immed & 0x10) { dst = mov_irind(dst, 1, CONTEXT, SZ_B); } - if (inst->op == M68K_ANDI_SR) { + if (inst->op == M68K_ORI_SR) { dst = or_irdisp8(dst, inst->src.params.immed >> 8, CONTEXT, offsetof(m68k_context, status), SZ_B); + if (inst->src.params.immed & 0x700) { + dst = call(dst, (uint8_t *)do_sync); + } } break; /*case M68K_RESET:*/ @@ -2921,8 +2929,8 @@ next = m68k_decode(encoded, &instbuf, address); address += (next-encoded)*2; encoded = next; - m68k_disasm(&instbuf, disbuf); - printf("%X: %s\n", instbuf.address, disbuf); + //m68k_disasm(&instbuf, disbuf); + //printf("%X: %s\n", instbuf.address, disbuf); dst = translate_m68k(dst, &instbuf, opts); } while(instbuf.op != M68K_ILLEGAL && instbuf.op != M68K_RTS && instbuf.op != M68K_RTE && !(instbuf.op == M68K_BCC && instbuf.extra.cond == COND_TRUE) && instbuf.op != M68K_JMP); process_deferred(opts); diff -r 139e5dcd6aa3 -r 3e68e517cc01 runtime.S --- a/runtime.S Tue Jan 01 07:06:57 2013 -0800 +++ b/runtime.S Tue Jan 01 09:40:17 2013 -0800 @@ -1,8 +1,10 @@ .global handle_cycle_limit + .global do_sync handle_cycle_limit: cmp 84(%rsi), %eax jb skip_sync +do_sync: call m68k_save_context mov %rsi, %rdi call sync_components @@ -49,9 +51,14 @@ /* discard function return address */ pop %rdi jmp *%rcx + ret skip_int: + cmp 84(%rsi), %eax + jnb do_sync ret + .global do_sync + int_dbg_msg: .asciz "Executing Interrupt!" print_int_dbg: