Mercurial > repos > blastem
comparison m68k_core.c @ 792:724bbec47f86
Use a new fatal_error function instead of calling fprintf and exit for fatal errors. This new function more gracefully handles the case in which BlastEm was not started from a terminal or disconnected from ther terminal (Windows).
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Sat, 25 Jul 2015 18:22:07 -0700 |
parents | 7367b14ac01c |
children | 0b692b5d154b |
comparison
equal
deleted
inserted
replaced
791:60686f8d5e48 | 792:724bbec47f86 |
---|---|
6 #include "m68k_core.h" | 6 #include "m68k_core.h" |
7 #include "m68k_internal.h" | 7 #include "m68k_internal.h" |
8 #include "68kinst.h" | 8 #include "68kinst.h" |
9 #include "backend.h" | 9 #include "backend.h" |
10 #include "gen.h" | 10 #include "gen.h" |
11 #include "util.h" | |
11 #include <stdio.h> | 12 #include <stdio.h> |
12 #include <stddef.h> | 13 #include <stddef.h> |
13 #include <stdlib.h> | 14 #include <stdlib.h> |
14 #include <string.h> | 15 #include <string.h> |
15 | 16 |
172 ldi_areg(opts, inst->src.params.immed, inst->dst.params.regs.pri); | 173 ldi_areg(opts, inst->src.params.immed, inst->dst.params.regs.pri); |
173 } | 174 } |
174 break; | 175 break; |
175 default: | 176 default: |
176 m68k_disasm(inst, disasm_buf); | 177 m68k_disasm(inst, disasm_buf); |
177 printf("%X: %s\naddress mode %d not implemented (lea src)\n", inst->address, disasm_buf, inst->src.addr_mode); | 178 fatal_error("%X: %s\naddress mode %d not implemented (lea src)\n", inst->address, disasm_buf, inst->src.addr_mode); |
178 exit(1); | |
179 } | 179 } |
180 if (inst->op == M68K_PEA) { | 180 if (inst->op == M68K_PEA) { |
181 subi_areg(opts, 4, 7); | 181 subi_areg(opts, 4, 7); |
182 areg_to_native(opts, 7, opts->gen.scratch2); | 182 areg_to_native(opts, 7, opts->gen.scratch2); |
183 call(code, opts->write_32_lowfirst); | 183 call(code, opts->write_32_lowfirst); |
281 } | 281 } |
282 jump_m68k_abs(opts, inst->src.params.immed); | 282 jump_m68k_abs(opts, inst->src.params.immed); |
283 break; | 283 break; |
284 default: | 284 default: |
285 m68k_disasm(inst, disasm_buf); | 285 m68k_disasm(inst, disasm_buf); |
286 printf("%s\naddress mode %d not yet supported (%s)\n", disasm_buf, inst->src.addr_mode, is_jsr ? "jsr" : "jmp"); | 286 fatal_error("%s\naddress mode %d not yet supported (%s)\n", disasm_buf, inst->src.addr_mode, is_jsr ? "jsr" : "jmp"); |
287 exit(1); | |
288 } | 287 } |
289 } | 288 } |
290 | 289 |
291 void translate_m68k_unlk(m68k_options * opts, m68kinst * inst) | 290 void translate_m68k_unlk(m68k_options * opts, m68kinst * inst) |
292 { | 291 { |
408 early_cycles += 4; | 407 early_cycles += 4; |
409 ldi_native(opts, inst->dst.params.immed, opts->gen.scratch2); | 408 ldi_native(opts, inst->dst.params.immed, opts->gen.scratch2); |
410 break; | 409 break; |
411 default: | 410 default: |
412 m68k_disasm(inst, disasm_buf); | 411 m68k_disasm(inst, disasm_buf); |
413 printf("%X: %s\naddress mode %d not implemented (movem dst)\n", inst->address, disasm_buf, inst->dst.addr_mode); | 412 fatal_error("%X: %s\naddress mode %d not implemented (movem dst)\n", inst->address, disasm_buf, inst->dst.addr_mode); |
414 exit(1); | |
415 } | 413 } |
416 if (inst->dst.addr_mode == MODE_AREG_PREDEC) { | 414 if (inst->dst.addr_mode == MODE_AREG_PREDEC) { |
417 reg = 15; | 415 reg = 15; |
418 dir = -1; | 416 dir = -1; |
419 } else { | 417 } else { |
479 early_cycles += 4; | 477 early_cycles += 4; |
480 ldi_native(opts, inst->src.params.immed, opts->gen.scratch1); | 478 ldi_native(opts, inst->src.params.immed, opts->gen.scratch1); |
481 break; | 479 break; |
482 default: | 480 default: |
483 m68k_disasm(inst, disasm_buf); | 481 m68k_disasm(inst, disasm_buf); |
484 printf("%X: %s\naddress mode %d not implemented (movem src)\n", inst->address, disasm_buf, inst->src.addr_mode); | 482 fatal_error("%X: %s\naddress mode %d not implemented (movem src)\n", inst->address, disasm_buf, inst->src.addr_mode); |
485 exit(1); | |
486 } | 483 } |
487 cycles(&opts->gen, early_cycles); | 484 cycles(&opts->gen, early_cycles); |
488 for(reg = 0; reg < 16; reg ++) { | 485 for(reg = 0; reg < 16; reg ++) { |
489 if (inst->dst.params.immed & (1 << reg)) { | 486 if (inst->dst.params.immed & (1 << reg)) { |
490 push_native(opts, opts->gen.scratch1); | 487 push_native(opts, opts->gen.scratch1); |
828 translate_m68k_arith(opts, inst, info->impl.flag_mask, &src_op, &dst_op); | 825 translate_m68k_arith(opts, inst, info->impl.flag_mask, &src_op, &dst_op); |
829 } else if (info->itype == UNARY_ARITH) { | 826 } else if (info->itype == UNARY_ARITH) { |
830 translate_m68k_unary(opts, inst, info->impl.flag_mask, inst->dst.addr_mode != MODE_UNUSED ? &dst_op : &src_op); | 827 translate_m68k_unary(opts, inst, info->impl.flag_mask, inst->dst.addr_mode != MODE_UNUSED ? &dst_op : &src_op); |
831 } else { | 828 } else { |
832 m68k_disasm(inst, disasm_buf); | 829 m68k_disasm(inst, disasm_buf); |
833 printf("%X: %s\ninstruction %d not yet implemented\n", inst->address, disasm_buf, inst->op); | 830 fatal_error("%X: %s\ninstruction %d not yet implemented\n", inst->address, disasm_buf, inst->op); |
834 exit(1); | |
835 } | 831 } |
836 } | 832 } |
837 | 833 |
838 void translate_m68k_stream(uint32_t address, m68k_context * context) | 834 void translate_m68k_stream(uint32_t address, m68k_context * context) |
839 { | 835 { |