summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Pavone <pavone@retrodev.com>2017-01-03 21:18:42 -0800
committerMichael Pavone <pavone@retrodev.com>2017-01-03 21:18:42 -0800
commit8218a344ce9209af4868bea4441daf2b2f30c975 (patch)
tree1e0b2e8410082a13acfc4afaf2f97e8e235122ce
parent5a9c697cd66203fa6160f2dfed02a5dad2351eec (diff)
Fix RAM flag offset calculation to take into account the existence of non-writeable MMAP_CODE chunks
-rw-r--r--backend_x86.c12
1 files changed, 7 insertions, 5 deletions
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;