Mercurial > repos > blastem
comparison m68k_core_x86.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 | 7267bc1ab547 |
children | 193db42e702b |
comparison
equal
deleted
inserted
replaced
1081:89cc20cf1ad3 | 1082:2ec5e6eaf81d |
---|---|
1152 set_flag(opts, 0, FLAG_V); | 1152 set_flag(opts, 0, FLAG_V); |
1153 } | 1153 } |
1154 if (inst->src.addr_mode == MODE_UNUSED) { | 1154 if (inst->src.addr_mode == MODE_UNUSED) { |
1155 m68k_save_result(inst, opts); | 1155 m68k_save_result(inst, opts); |
1156 } | 1156 } |
1157 } | |
1158 | |
1159 void translate_m68k_reset(m68k_options *opts, m68kinst *inst) | |
1160 { | |
1161 code_info *code = &opts->gen.code; | |
1162 cycles(&opts->gen, BUS); | |
1163 mov_rdispr(code, opts->gen.context_reg, offsetof(m68k_context, reset_handler), opts->gen.scratch1, SZ_PTR); | |
1164 cmp_ir(code, 0, opts->gen.scratch1, SZ_PTR); | |
1165 code_ptr no_reset_handler = code->cur + 1; | |
1166 jcc(code, CC_Z, code->cur+2); | |
1167 call(code, opts->gen.save_context); | |
1168 call_args_r(code, opts->gen.scratch1, 1, opts->gen.context_reg); | |
1169 mov_rr(code, RAX, opts->gen.context_reg, SZ_PTR); | |
1170 call(code, opts->gen.load_context); | |
1171 *no_reset_handler = code->cur - (no_reset_handler + 1); | |
1157 } | 1172 } |
1158 | 1173 |
1159 void op_ir(code_info *code, m68kinst *inst, int32_t val, uint8_t dst, uint8_t size) | 1174 void op_ir(code_info *code, m68kinst *inst, int32_t val, uint8_t dst, uint8_t size) |
1160 { | 1175 { |
1161 switch (inst->op) | 1176 switch (inst->op) |
2218 mov_rrdisp(code, opts->gen.scratch1, dst_op->base, dst_op->disp, SZ_W); | 2233 mov_rrdisp(code, opts->gen.scratch1, dst_op->base, dst_op->disp, SZ_W); |
2219 } | 2234 } |
2220 m68k_save_result(inst, opts); | 2235 m68k_save_result(inst, opts); |
2221 } | 2236 } |
2222 | 2237 |
2223 void translate_out_of_bounds(code_info *code) | 2238 void m68k_out_of_bounds_execution(uint32_t address) |
2224 { | 2239 { |
2225 xor_rr(code, RDI, RDI, SZ_D); | 2240 fatal_error("M68K attempted to execute code at unmapped or I/O address %X\n", address); |
2226 call_args(code, (code_ptr)exit, 1, RDI); | 2241 } |
2242 | |
2243 void translate_out_of_bounds(m68k_options *opts, uint32_t address) | |
2244 { | |
2245 code_info *code = &opts->gen.code; | |
2246 mov_ir(code, address, opts->gen.scratch1, SZ_D); | |
2247 call_args(code, (code_ptr)m68k_out_of_bounds_execution, 1, opts->gen.scratch1); | |
2227 } | 2248 } |
2228 | 2249 |
2229 void m68k_set_last_prefetch(m68k_options *opts, uint32_t address) | 2250 void m68k_set_last_prefetch(m68k_options *opts, uint32_t address) |
2230 { | 2251 { |
2231 mov_irdisp(&opts->gen.code, address, opts->gen.context_reg, offsetof(m68k_context, last_prefetch_address), SZ_D); | 2252 mov_irdisp(&opts->gen.code, address, opts->gen.context_reg, offsetof(m68k_context, last_prefetch_address), SZ_D); |