From 8218a344ce9209af4868bea4441daf2b2f30c975 Mon Sep 17 00:00:00 2001 From: Michael Pavone Date: Tue, 3 Jan 2017 21:18:42 -0800 Subject: Fix RAM flag offset calculation to take into account the existence of non-writeable MMAP_CODE chunks --- backend_x86.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'backend_x86.c') diff --git a/backend_x86.c b/backend_x86.c index 9001d71..4eca2a5 100644 --- a/backend_x86.c +++ b/backend_x86.c @@ -231,11 +231,6 @@ code_ptr gen_mem_fun(cpu_options * opts, memmap_chunk const * memmap, uint32_t n mov_rr(code, opts->scratch2, opts->scratch1, opts->address_size); shr_ir(code, opts->ram_flags_shift, opts->scratch1, opts->address_size); bt_rrdisp(code, opts->scratch1, opts->context_reg, ram_flags_off, opts->address_size); - if (memmap[chunk].mask == opts->address_mask) { - ram_flags_off += (memmap[chunk].end - memmap[chunk].start) / (1 << opts->ram_flags_shift) / 8; ; - } else { - ram_flags_off += (memmap[chunk].mask + 1) / (1 << opts->ram_flags_shift) / 8;; - } code_ptr not_code = code->cur + 1; jcc(code, CC_NC, code->cur + 2); if (memmap[chunk].mask != opts->address_mask) { @@ -267,6 +262,13 @@ code_ptr gen_mem_fun(cpu_options * opts, memmap_chunk const * memmap, uint32_t n } retn(code); } + if (memmap[chunk].flags & MMAP_CODE) { + if (memmap[chunk].mask == opts->address_mask) { + ram_flags_off += (memmap[chunk].end - memmap[chunk].start) / (1 << opts->ram_flags_shift) / 8; ; + } else { + ram_flags_off += (memmap[chunk].mask + 1) / (1 << opts->ram_flags_shift) / 8;; + } + } if (lb_jcc) { *lb_jcc = code->cur - (lb_jcc+1); lb_jcc = NULL; -- cgit v1.2.3