Mercurial > repos > blastem
diff runtime.S @ 193:c66e4636f991
Implement support for self-modifying code
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Tue, 15 Jan 2013 00:14:36 -0800 |
parents | e2918b5208eb |
children | 811163790e6c |
line wrap: on
line diff
--- a/runtime.S Mon Jan 14 21:56:54 2013 -0800 +++ b/runtime.S Tue Jan 15 00:14:36 2013 -0800 @@ -240,8 +240,17 @@ not_io_w: ret workram_w: - and $0xFFFF, %rdi + and $0xFFFF, %edi mov %cx, (%r9, %rdi) + mov %edi, %ecx + shr $10, %ecx + bt %ecx, 160(%rsi) + jnc not_code + call m68k_save_context + call m68k_handle_code_write + mov %rax, %rsi + call m68k_load_context +not_code: ret cart_w: mov %cx, (%r8, %rdi) @@ -322,6 +331,16 @@ xor $1, %edi and $0xFFFF, %rdi mov %cl, (%r9, %rdi) + mov %edi, %ecx + shr $10, %ecx + bt %ecx, 160(%rsi) + jnc not_code_b + xor $1, %edi + call m68k_save_context + call m68k_handle_code_write + mov %rax, %rsi + call m68k_load_context +not_code_b: ret cart_wb: /* deal with byte swapping */ @@ -498,6 +517,16 @@ pop %rsi call m68k_load_context ret + + .global m68k_retrans_stub +m68k_retrans_stub: + call m68k_save_context + push %rsi + call m68k_retranslate_inst + pop %rsi + mov %rax, %rcx + call m68k_load_context + jmp *%rcx .global m68k_save_context m68k_save_context: