diff m68k_core.c @ 987:1f09994e92c5

Initial stab at implementing address error exceptions. Need to fill in the value of IR, undefined bits of last stack frame word and properly deal with address errors that occur during exception processing.
author Michael Pavone <pavone@retrodev.com>
date Tue, 26 Apr 2016 23:13:37 -0700
parents f680fe746a7d
children ce9df7a5fdf2
line wrap: on
line diff
--- a/m68k_core.c	Tue Apr 26 00:07:15 2016 -0700
+++ b/m68k_core.c	Tue Apr 26 23:13:37 2016 -0700
@@ -553,9 +553,7 @@
 {
 	native_map_slot * native_code_map = opts->gen.native_code_map;
 	address &= opts->gen.address_mask;
-	if (address & 1) {
-		return opts->odd_address;
-	}
+	
 	//TODO: Refactor part of this loop into some kind of get_ram_chunk function
 	for (int i = 0; i < opts->gen.memmap_chunks; i++) {
 		if (address >= opts->gen.memmap[i].start && address < opts->gen.memmap[i].end) {
@@ -563,7 +561,7 @@
 			address = opts->gen.memmap[i].start + ((address - opts->gen.memmap[i].start) & opts->gen.memmap[i].mask);
 		}
 	}
-	address /= 2;
+	
 	uint32_t chunk = address / NATIVE_CHUNK_SIZE;
 	if (!native_code_map[chunk].base) {
 		return NULL;
@@ -591,7 +589,6 @@
 		}
 	}
 	
-	address /= 2;
 	uint32_t chunk = address / NATIVE_CHUNK_SIZE;
 	if (!native_code_map[chunk].base) {
 		return 0;
@@ -643,7 +640,7 @@
 			meta_off += size;
 		}
 	}
-	address/= 2;
+	
 	uint32_t chunk = address / NATIVE_CHUNK_SIZE;
 	if (!native_code_map[chunk].base) {
 		native_code_map[chunk].base = native_addr;
@@ -819,6 +816,10 @@
 
 void translate_m68k(m68k_options * opts, m68kinst * inst)
 {
+	if (inst->address & 1) {
+		translate_m68k_odd(opts, inst);
+		return;
+	}
 	check_cycles_int(&opts->gen, inst->address);
 	//log_address(&opts->gen, inst->address, "M68K: %X @ %d\n");
 	if (
@@ -872,9 +873,6 @@
 			fflush(opts->address_log);
 		}
 		do {
-			if (address & 1) {
-				break;
-			}
 			encoded = get_native_pointer(address, (void **)context->mem_pointers, &opts->gen);
 			if (!encoded) {
 				map_native_address(context, address, code->cur, 2, 1);
@@ -902,7 +900,7 @@
 			translate_m68k(opts, &instbuf);
 			code_ptr after = code->cur;
 			map_native_address(context, instbuf.address, start, m68k_size, after-start);
-		} while(!m68k_is_terminal(&instbuf));
+		} while(!m68k_is_terminal(&instbuf) && !(address & 1));
 		process_deferred(&opts->gen.deferred, context, (native_addr_func)get_native_from_context);
 		if (opts->gen.deferred) {
 			address = opts->gen.deferred->address;