diff options
author | Michael Pavone <pavone@retrodev.com> | 2021-03-07 22:43:51 -0800 |
---|---|---|
committer | Michael Pavone <pavone@retrodev.com> | 2021-03-07 22:43:51 -0800 |
commit | 87c1d42cb389b91e2f41f1b5e0a11c859876101d (patch) | |
tree | e88fee1881ebac50381504528bb920e86a6b36c6 /backend_x86.c | |
parent | a452bfabb59b0d4efd6510f4cb46b877f0a2a27b (diff) |
Fix bug in handling of MMAP_CODE regions smaller than 16KB
Diffstat (limited to 'backend_x86.c')
-rw-r--r-- | backend_x86.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/backend_x86.c b/backend_x86.c index 9458499..20cb9d3 100644 --- a/backend_x86.c +++ b/backend_x86.c @@ -299,10 +299,16 @@ code_ptr gen_mem_fun(cpu_options * opts, memmap_chunk const * memmap, uint32_t n retn(code); } if (memmap[chunk].flags & MMAP_CODE) { + uint32_t added_offset; if (memmap[chunk].mask == opts->address_mask) { - ram_flags_off += (memmap[chunk].end - memmap[chunk].start) / (1 << opts->ram_flags_shift) / 8; ; + added_offset = (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;; + added_offset = (memmap[chunk].mask + 1) / (1 << opts->ram_flags_shift) / 8; + } + if (added_offset) { + ram_flags_off += added_offset; + } else { + ram_flags_off += 1; } } if (lb_jcc) { |