main
m68k_internal.h
1/*
2 Copyright 2014 Michael Pavone
3 This file is part of BlastEm.
4 BlastEm is free software distributed under the terms of the GNU General Public License version 3 or greater. See COPYING for full license text.
5*/
6#ifndef M68K_INTERNAL_H_
7#define M68K_INTERNAL_H_
8
9#include "68kinst.h"
10
11//functions implemented in host CPU specfic file
12void translate_out_of_bounds(m68k_options *opts, uint32_t address);
13void areg_to_native(m68k_options *opts, uint8_t reg, uint8_t native_reg);
14void dreg_to_native(m68k_options *opts, uint8_t reg, uint8_t native_reg);
15void areg_to_native_sx(m68k_options *opts, uint8_t reg, uint8_t native_reg);
16void dreg_to_native_sx(m68k_options *opts, uint8_t reg, uint8_t native_reg);
17void native_to_areg(m68k_options *opts, uint8_t native_reg, uint8_t reg);
18void native_to_dreg(m68k_options *opts, uint8_t native_reg, uint8_t reg);
19void ldi_areg(m68k_options *opts, int32_t value, uint8_t reg);
20void ldi_native(m68k_options *opts, int32_t value, uint8_t reg);
21void addi_native(m68k_options *opts, int32_t value, uint8_t reg);
22void subi_native(m68k_options *opts, int32_t value, uint8_t reg);
23void push_native(m68k_options *opts, uint8_t reg);
24void pop_native(m68k_options *opts, uint8_t reg);
25void sign_extend16_native(m68k_options *opts, uint8_t reg);
26void addi_areg(m68k_options *opts, int32_t val, uint8_t reg);
27void subi_areg(m68k_options *opts, int32_t val, uint8_t reg);
28void add_areg_native(m68k_options *opts, uint8_t reg, uint8_t native_reg);
29void add_dreg_native(m68k_options *opts, uint8_t reg, uint8_t native_reg);
30void calc_areg_displace(m68k_options *opts, m68k_op_info *op, uint8_t native_reg);
31void calc_index_disp8(m68k_options *opts, m68k_op_info *op, uint8_t native_reg);
32void calc_areg_index_disp8(m68k_options *opts, m68k_op_info *op, uint8_t native_reg);
33void nop_fill_or_jmp_next(code_info *code, code_ptr old_end, code_ptr next_inst);
34void check_user_mode_swap_ssp_usp(m68k_options *opts);
35void m68k_set_last_prefetch(m68k_options *opts, uint32_t address);
36void translate_m68k_odd(m68k_options *opts, m68kinst *inst);
37void m68k_trap_if_not_supervisor(m68k_options *opts, m68kinst *inst);
38void m68k_breakpoint_patch(m68k_context *context, uint32_t address, m68k_debug_handler bp_handler, code_ptr native_addr);
39void m68k_check_cycles_int_latch(m68k_options *opts);
40uint8_t translate_m68k_op(m68kinst * inst, host_ea * ea, m68k_options * opts, uint8_t dst);
41
42//functions implemented in m68k_core.c
43int8_t native_reg(m68k_op_info * op, m68k_options * opts);
44size_t dreg_offset(uint8_t reg);
45size_t areg_offset(uint8_t reg);
46size_t reg_offset(m68k_op_info *op);
47void m68k_read_size(m68k_options *opts, uint8_t size);
48void m68k_write_size(m68k_options *opts, uint8_t size, uint8_t lowfirst);
49void m68k_save_result(m68kinst * inst, m68k_options * opts);
50void jump_m68k_abs(m68k_options * opts, uint32_t address);
51void swap_ssp_usp(m68k_options * opts);
52code_ptr get_native_address(m68k_options *opts, uint32_t address);
53uint8_t m68k_is_terminal(m68kinst * inst);
54code_ptr get_native_address_trans(m68k_context * context, uint32_t address);
55void * m68k_retranslate_inst(uint32_t address, m68k_context * context);
56m68k_context *m68k_bp_dispatcher(m68k_context *context, uint32_t address);
57
58//individual instructions
59void translate_m68k_bcc(m68k_options * opts, m68kinst * inst);
60void translate_m68k_scc(m68k_options * opts, m68kinst * inst);
61void translate_m68k_dbcc(m68k_options * opts, m68kinst * inst);
62void translate_m68k_trapv(m68k_options *opts, m68kinst *inst);
63void translate_m68k_move(m68k_options * opts, m68kinst * inst);
64void translate_m68k_movep(m68k_options * opts, m68kinst * inst);
65void translate_m68k_arith(m68k_options *opts, m68kinst * inst, uint32_t flag_mask, host_ea *src_op, host_ea *dst_op);
66void translate_m68k_unary(m68k_options *opts, m68kinst *inst, uint32_t flag_mask, host_ea *dst_op);
67void translate_m68k_cmp(m68k_options * opts, m68kinst * inst);
68void translate_m68k_tas(m68k_options * opts, m68kinst * inst);
69void translate_m68k_ext(m68k_options * opts, m68kinst * inst);
70void translate_m68k_abcd_sbcd(m68k_options *opts, m68kinst *inst, host_ea *src_op, host_ea *dst_op);
71void translate_m68k_sl(m68k_options *opts, m68kinst *inst, host_ea *src_op, host_ea *dst_op);
72void translate_m68k_asr(m68k_options *opts, m68kinst *inst, host_ea *src_op, host_ea *dst_op);
73void translate_m68k_lsr(m68k_options *opts, m68kinst *inst, host_ea *src_op, host_ea *dst_op);
74void translate_m68k_bit(m68k_options *opts, m68kinst *inst, host_ea *src_op, host_ea *dst_op);
75void translate_m68k_chk(m68k_options *opts, m68kinst *inst, host_ea *src_op, host_ea *dst_op);
76void translate_m68k_div(m68k_options *opts, m68kinst *inst, host_ea *src_op, host_ea *dst_op);
77void translate_m68k_exg(m68k_options *opts, m68kinst *inst, host_ea *src_op, host_ea *dst_op);
78void translate_m68k_mul(m68k_options *opts, m68kinst *inst, host_ea *src_op, host_ea *dst_op);
79void translate_m68k_negx(m68k_options *opts, m68kinst *inst, host_ea *src_op, host_ea *dst_op);
80void translate_m68k_rot(m68k_options *opts, m68kinst *inst, host_ea *src_op, host_ea *dst_op);
81void translate_m68k_andi_ori_ccr_sr(m68k_options *opts, m68kinst *inst);
82void translate_m68k_eori_ccr_sr(m68k_options *opts, m68kinst *inst);
83void translate_m68k_move_ccr_sr(m68k_options *opts, m68kinst *inst, host_ea *src_op, host_ea *dst_op);
84void translate_m68k_stop(m68k_options *opts, m68kinst *inst);
85void translate_m68k_move_from_sr(m68k_options *opts, m68kinst *inst, host_ea *src_op, host_ea *dst_op);
86void translate_m68k_reset(m68k_options *opts, m68kinst *inst);
87
88//flag update bits
89#define X0 0x0001
90#define X1 0x0002
91#define X 0x0004
92#define N0 0x0008
93#define N1 0x0010
94#define N 0x0020
95#define Z0 0x0040
96#define Z1 0x0080
97#define Z 0x0100
98#define V0 0x0200
99#define V1 0x0400
100#define V 0x0800
101#define C0 0x1000
102#define C1 0x2000
103#define C 0x4000
104
105#define BUS 4
106#define PREDEC_PENALTY 2
107extern char disasm_buf[1024];
108
109m68k_context * sync_components(m68k_context * context, uint32_t address);
110
111void m68k_invalid();
112void bcd_add();
113void bcd_sub();
114
115#endif //M68K_INTERNAL_H_