changeset 750:59b499f6b24f

Fix handling of address mask in gen_mem_fun
author Michael Pavone <pavone@retrodev.com>
date Mon, 22 Jun 2015 09:22:18 -0700
parents 6f439a197f61
children cf09b189a0ca
files backend_x86.c
diffstat 1 files changed, 4 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/backend_x86.c	Mon Jun 22 09:22:05 2015 -0700
+++ b/backend_x86.c	Mon Jun 22 09:22:18 2015 -0700
@@ -55,12 +55,12 @@
 	if (after_inc) {
 		*after_inc = code->cur;
 	}
-	if (opts->address_size == SZ_D && opts->address_mask < 0xFFFFFFFF) {
-		and_ir(code, opts->address_mask, opts->scratch1, SZ_D);
+	uint8_t is_write = fun_type == WRITE_16 || fun_type == WRITE_8;
+	uint8_t adr_reg = is_write ? opts->scratch2 : opts->scratch1;
+	if (opts->address_size == SZ_D && opts->address_mask != 0xFFFFFFFF) {
+		and_ir(code, opts->address_mask, adr_reg, SZ_D);
 	}
 	code_ptr lb_jcc = NULL, ub_jcc = NULL;
-	uint8_t is_write = fun_type == WRITE_16 || fun_type == WRITE_8;
-	uint8_t adr_reg = is_write ? opts->scratch2 : opts->scratch1;
 	uint16_t access_flag = is_write ? MMAP_WRITE : MMAP_READ;
 	uint8_t size =  (fun_type == READ_16 || fun_type == WRITE_16) ? SZ_W : SZ_B;
 	uint32_t ram_flags_off = opts->ram_flags_off;