changeset 892:381a3b2f6065

Fix a bug in generating memory access functions when more than one MMAP_CODE region exists
author Michael Pavone <pavone@retrodev.com>
date Sun, 22 Nov 2015 14:42:36 -0800
parents 90d54ccf9557
children 4f46b4cd5035
files backend_x86.c
diffstat 1 files changed, 2 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/backend_x86.c	Tue Nov 17 19:55:59 2015 -0800
+++ b/backend_x86.c	Sun Nov 22 14:42:36 2015 -0800
@@ -194,11 +194,10 @@
 				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);
-				//FIXME: These adjustments to ram_flags_off need to take into account bits vs bytes and ram_flags_shift
 				if (memmap[chunk].mask == opts->address_mask) {
-					ram_flags_off += memmap[chunk].end - memmap[chunk].start;
+					ram_flags_off += (memmap[chunk].end - memmap[chunk].start) / (1 << opts->ram_flags_shift) / 8; ;
 				} else {
-					ram_flags_off += memmap[chunk].mask + 1;
+					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);