comparison trans.c @ 1082:2ec5e6eaf81d

Add support for specifying a reset handler in the M68K core. Adjust memory map initialization to handle extra field. Improved handling of out of bounds execution.
author Michael Pavone <pavone@retrodev.com>
date Thu, 06 Oct 2016 09:34:31 -0700
parents 124a58fdcf3a
children 208803173ebc
comparison
equal deleted inserted replaced
1081:89cc20cf1ad3 1082:2ec5e6eaf81d
22 m68k_context * sync_components(m68k_context * context, uint32_t address) 22 m68k_context * sync_components(m68k_context * context, uint32_t address)
23 { 23 {
24 if (context->current_cycle > 0x80000000) { 24 if (context->current_cycle > 0x80000000) {
25 context->current_cycle -= 0x80000000; 25 context->current_cycle -= 0x80000000;
26 } 26 }
27 return context;
28 }
29
30 m68k_context *reset_handler(m68k_context *context)
31 {
32 m68k_print_regs(context);
33 exit(0);
34 //unreachable
27 return context; 35 return context;
28 } 36 }
29 37
30 int main(int argc, char ** argv) 38 int main(int argc, char ** argv)
31 { 39 {
58 memmap[1].mask = 0xFFFF; 66 memmap[1].mask = 0xFFFF;
59 memmap[1].flags = MMAP_READ | MMAP_WRITE | MMAP_CODE; 67 memmap[1].flags = MMAP_READ | MMAP_WRITE | MMAP_CODE;
60 memmap[1].buffer = malloc(64 * 1024); 68 memmap[1].buffer = malloc(64 * 1024);
61 memset(memmap[1].buffer, 0, 64 * 1024); 69 memset(memmap[1].buffer, 0, 64 * 1024);
62 init_m68k_opts(&opts, memmap, 2, 1); 70 init_m68k_opts(&opts, memmap, 2, 1);
63 m68k_context * context = init_68k_context(&opts); 71 m68k_context * context = init_68k_context(&opts, reset_handler);
64 context->mem_pointers[0] = memmap[0].buffer; 72 context->mem_pointers[0] = memmap[0].buffer;
65 context->mem_pointers[1] = memmap[1].buffer; 73 context->mem_pointers[1] = memmap[1].buffer;
66 context->target_cycle = context->sync_cycle = 0x80000000; 74 context->target_cycle = context->sync_cycle = 0x80000000;
67 uint32_t address; 75 uint32_t address;
68 address = filebuf[2] << 16 | filebuf[3]; 76 address = filebuf[2] << 16 | filebuf[3];