summaryrefslogtreecommitdiff
path: root/backend_x86.c
diff options
context:
space:
mode:
authorMichael Pavone <pavone@retrodev.com>2016-10-06 09:25:43 -0700
committerMichael Pavone <pavone@retrodev.com>2016-10-06 09:25:43 -0700
commit9b16317e1842af9b71837a43ffba04ca45689dcc (patch)
tree46c4ba876f1bf1e9db362ee92abd28d964e6581e /backend_x86.c
parentce305a4705829579e52900d6626e5d02457c2e14 (diff)
Fix handling of MMAP_CODE chunks that also have MMAP_PTR_IDX set
Diffstat (limited to 'backend_x86.c')
-rw-r--r--backend_x86.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/backend_x86.c b/backend_x86.c
index 2c9f083..addc34e 100644
--- a/backend_x86.c
+++ b/backend_x86.c
@@ -141,10 +141,15 @@ code_ptr gen_mem_fun(cpu_options * opts, memmap_chunk const * memmap, uint32_t n
if (opts->address_size != SZ_D) {
movzx_rr(code, adr_reg, adr_reg, opts->address_size, SZ_D);
}
+ if (is_write && (memmap[chunk].flags & MMAP_CODE)) {
+ push_r(code, adr_reg);
+ }
add_rdispr(code, opts->context_reg, opts->mem_ptr_off + sizeof(void*) * memmap[chunk].ptr_index, adr_reg, SZ_PTR);
if (is_write) {
mov_rrind(code, opts->scratch1, opts->scratch2, size);
-
+ if (memmap[chunk].flags & MMAP_CODE) {
+ pop_r(code, adr_reg);
+ }
} else {
mov_rindr(code, opts->scratch1, opts->scratch1, size);
}