diff options
author | Mike Pavone <pavone@retrodev.com> | 2013-01-26 01:33:32 -0800 |
---|---|---|
committer | Mike Pavone <pavone@retrodev.com> | 2013-01-26 01:33:32 -0800 |
commit | f441792c084b79a77f677243342ed0cb6336e92d (patch) | |
tree | 121516a0064a8ae0537a9628bfa49dc9790b71a6 | |
parent | 85164f4483132a3db4890defa59f6851a0f765fe (diff) |
Tweaks to make blastem compatible with m68k-tester
-rw-r--r-- | 68kinst.c | 4 | ||||
-rw-r--r-- | 68kinst.h | 2 | ||||
-rw-r--r-- | Makefile | 3 | ||||
-rw-r--r-- | m68k_to_x86.c | 8 | ||||
-rw-r--r-- | m68k_to_x86.h | 6 | ||||
-rw-r--r-- | runtime.S | 16 |
6 files changed, 34 insertions, 5 deletions
@@ -854,6 +854,10 @@ uint16_t * m68k_decode(uint16_t * istream, m68kinst * decoded, uint32_t address) decoded->src.params.immed = immed; break; case MOVEQ: + if (*istream & 0x100) { + decoded->op = M68K_INVALID; + return start+1; + } decoded->op = M68K_MOVE; decoded->variant = VAR_QUICK; decoded->extra.size = OPSIZE_LONG; @@ -170,7 +170,7 @@ typedef struct { } params; } m68k_op_info; -typedef struct { +typedef struct m68kinst { uint8_t op; uint8_t variant; union { @@ -11,6 +11,9 @@ dis : dis.o 68kinst.o zdis : zdis.o z80inst.o $(CC) -o zdis zdis.o z80inst.o +libemu68k.a : 68kinst.o gen_x86.o m68k_to_x86.o runtime.o mem.o + ar rcs libemu68k.a 68kinst.o gen_x86.o m68k_to_x86.o runtime.o mem.o + trans : trans.o 68kinst.o gen_x86.o m68k_to_x86.o runtime.o mem.o $(CC) -o trans trans.o 68kinst.o gen_x86.o m68k_to_x86.o runtime.o mem.o diff --git a/m68k_to_x86.c b/m68k_to_x86.c index d700ac7..b6b634d 100644 --- a/m68k_to_x86.c +++ b/m68k_to_x86.c @@ -1,5 +1,6 @@ #include "gen_x86.h" #include "m68k_to_x86.h" +#include "68kinst.h" #include "mem.h" #include <stdio.h> #include <stddef.h> @@ -2804,6 +2805,9 @@ uint8_t * translate_m68k(uint8_t * dst, m68kinst * inst, x86_68k_options * opts) } else if(inst->op == M68K_MOVEP) { return translate_m68k_movep(dst, inst, opts); } else if(inst->op == M68K_INVALID) { + if (inst->src.params.immed == 0x7100) { + return retn(dst); + } dst = mov_ir(dst, inst->address, SCRATCH1, SZ_D); return call(dst, (uint8_t *)m68k_invalid); } else if(inst->op == M68K_CMP) { @@ -2962,7 +2966,6 @@ uint8_t * translate_m68k(uint8_t * dst, m68kinst * inst, x86_68k_options * opts) break; case M68K_ASL: case M68K_LSL: - //TODO: Check overflow flag behavior dst = translate_shift(dst, inst, &src_op, &dst_op, opts, shl_ir, shl_irdisp8, shl_clr, shl_clrdisp8, shr_ir, shr_irdisp8); break; case M68K_ASR: @@ -3864,6 +3867,9 @@ uint8_t * translate_m68k_stream(uint32_t address, m68k_context * context) break; } next = m68k_decode(encoded, &instbuf, address); + if (instbuf.op == M68K_INVALID) { + instbuf.src.params.immed = *encoded; + } uint16_t m68k_size = (next-encoded)*2; address += m68k_size; encoded = next; diff --git a/m68k_to_x86.h b/m68k_to_x86.h index ab0c979..c2711db 100644 --- a/m68k_to_x86.h +++ b/m68k_to_x86.h @@ -2,7 +2,8 @@ #define M68K_TO_X86_H_ #include <stdint.h> #include <stdio.h> -#include "68kinst.h" +//#include "68kinst.h" +struct m68kinst; #define NUM_MEM_AREAS 4 #define NATIVE_MAP_CHUNKS (64*1024) @@ -56,7 +57,7 @@ typedef struct { uint8_t ram_code_flags[32/8]; } m68k_context; -uint8_t * translate_m68k(uint8_t * dst, m68kinst * inst, x86_68k_options * opts); +uint8_t * translate_m68k(uint8_t * dst, struct m68kinst * inst, x86_68k_options * opts); uint8_t * translate_m68k_stream(uint32_t address, m68k_context * context); void start_68k_context(m68k_context * context, uint32_t address); void init_x86_68k_opts(x86_68k_options * opts); @@ -64,6 +65,7 @@ void init_68k_context(m68k_context * context, native_map_slot * native_code_map, void m68k_reset(m68k_context * context); void insert_breakpoint(m68k_context * context, uint32_t address, uint8_t * bp_handler); void remove_breakpoint(m68k_context * context, uint32_t address); +m68k_context * m68k_handle_code_write(uint32_t address, m68k_context * context); #endif //M68K_TO_X86_H_ @@ -630,5 +630,19 @@ m68k_load_context: .global m68k_start_context m68k_start_context: + push %rbp + push %r12 + push %r13 + push %r14 + push %r15 + call m68k_load_context - jmp *%rdi + call *%rdi + + pop %r15 + pop %r14 + pop %r13 + pop %r12 + pop %rbp + + ret |