summaryrefslogtreecommitdiff
path: root/m68k_core.c
diff options
context:
space:
mode:
authorMichael Pavone <pavone@retrodev.com>2016-04-26 23:13:37 -0700
committerMichael Pavone <pavone@retrodev.com>2016-04-26 23:13:37 -0700
commit8b7027061d5d79712f2bdd859f55923d571efb4f (patch)
treeb7d0e553d1fa1f450e21f64e561a2b74bc849530 /m68k_core.c
parent042768acd31ac2a59049db55e31b647c2eb51818 (diff)
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.
Diffstat (limited to 'm68k_core.c')
-rw-r--r--m68k_core.c18
1 files changed, 8 insertions, 10 deletions
diff --git a/m68k_core.c b/m68k_core.c
index b687045..5a302ab 100644
--- a/m68k_core.c
+++ b/m68k_core.c
@@ -553,9 +553,7 @@ code_ptr get_native_address(m68k_options *opts, uint32_t address)
{
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 @@ code_ptr get_native_address(m68k_options *opts, uint32_t address)
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 @@ uint32_t get_instruction_start(m68k_options *opts, native_map_slot * native_code
}
}
- address /= 2;
uint32_t chunk = address / NATIVE_CHUNK_SIZE;
if (!native_code_map[chunk].base) {
return 0;
@@ -643,7 +640,7 @@ void map_native_address(m68k_context * context, uint32_t address, code_ptr nativ
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 @@ impl_info m68k_impls[] = {
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 @@ void translate_m68k_stream(uint32_t address, m68k_context * context)
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 @@ void translate_m68k_stream(uint32_t address, m68k_context * context)
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;