From d53d8f8d28c067bd80c5a66607973f5b125a0034 Mon Sep 17 00:00:00 2001 From: Michael Pavone Date: Fri, 26 Dec 2014 12:36:54 -0800 Subject: Add a couple of missing checks for the byte_swap and address_size parameters in gen_mem_fun --- backend_x86.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'backend_x86.c') diff --git a/backend_x86.c b/backend_x86.c index 6ba1a7a..482e9c3 100644 --- a/backend_x86.c +++ b/backend_x86.c @@ -154,7 +154,7 @@ code_ptr gen_mem_fun(cpu_options * opts, memmap_chunk const * memmap, uint32_t n retn(code); *good_addr = code->cur - (good_addr + 1); shr_ir(code, 1, adr_reg, opts->address_size); - } else { + } else if (opts->byte_swap) { xor_ir(code, 1, adr_reg, opts->address_size); } } else if ((memmap[chunk].flags & MMAP_ONLY_ODD) || (memmap[chunk].flags & MMAP_ONLY_EVEN)) { @@ -164,6 +164,9 @@ code_ptr gen_mem_fun(cpu_options * opts, memmap_chunk const * memmap, uint32_t n shr_ir(code, 8, opts->scratch1, SZ_W); } } + if (opts->address_size != SZ_D) { + movzx_rr(code, adr_reg, adr_reg, opts->address_size, SZ_D); + } if ((intptr_t)memmap[chunk].buffer <= 0x7FFFFFFF && (intptr_t)memmap[chunk].buffer >= -2147483648) { if (is_write) { mov_rrdisp(code, opts->scratch1, opts->scratch2, (intptr_t)memmap[chunk].buffer, tmp_size); -- cgit v1.2.3