2 #ifndef __LIB_I386_REAL_H__
3 #define __LIB_I386_REAL_H__
5 #include "./i386_opdef.h"
8 class I386_OPS: public I386_OPS_BASE
11 I386_OPS(int cputypes = I386_OPS_CPUTYPE_I386) : I386_OPS_BASE(cputypes)
17 int cpu_translate_i386(void *cpudevice, address_spacenum space, int intention, offs_t *address);
18 int cpu_execute_i386(int cycles);
19 void i386_trap(int irq, int irq_gate, int trap_level);
20 void i386_trap_with_error(int irq, int irq_gate, int trap_level, UINT32 error);
21 void i386_call_abs16(); // Opcode 0x9a
22 void i386_call_rel16(); // Opcode 0xe8
23 void i386_groupFF_16(); // Opcode 0xff
24 void i386_decode_opcode();
25 //void build_opcode_table(UINT32 features);
26 i386_state *i386_common_init(int tlbsize);
28 void set_context_io_stored(DEVICE *dev) {
30 cpustate->io_stored = dev;
34 void set_context_emu(EMU *p_emu) {
36 cpustate->emu = p_emu;
40 void set_context_debugger(DEBUGGER *debugger) {
42 cpustate->debugger = debugger;
45 void set_context_progmem_stored(DEVICE *dev) {
47 cpustate->program_stored = dev;
50 void set_context_pseudo_bios(DEVICE *dev) {
51 #ifdef I386_PSEUDO_BIOS
56 void set_context_dma(DEVICE *dev) {
57 #ifdef SINGLE_MODE_DMA
62 bool write_debug_reg(const _TCHAR *reg, uint32_t data);
63 int debug_dasm(uint32_t pc, _TCHAR *buffer, size_t buffer_len);
66 const UINT8 *opcode_ptr;
67 const UINT8 *opcode_ptr_base;
77 _TCHAR modrm_string[256];
78 UINT8 rex, regex, sibex, rmex;
82 INLINE UINT8 _FETCH(void);
84 INLINE UINT16 _FETCH16(void);
86 INLINE UINT32 _FETCH32(void);
87 INLINE UINT8 _FETCHD(void);
88 INLINE UINT16 _FETCHD16(void);
89 INLINE UINT32 _FETCHD32(void);
90 _TCHAR *hexstring(UINT32 value, int digits);
91 _TCHAR *hexstring64(UINT32 lo, UINT32 hi);
92 _TCHAR *hexstringpc(UINT64 pc);
93 _TCHAR *shexstring(UINT32 value, int digits, int always);
94 _TCHAR* handle_sib_byte( _TCHAR* s, UINT8 mod );
95 void handle_modrm(_TCHAR* s);
96 _TCHAR* handle_param(_TCHAR* s, UINT32 param);
97 void handle_fpu(_TCHAR *s, UINT8 op1, UINT8 op2);
98 void decode_opcode(_TCHAR *s, const I386_OPCODE *op, UINT8 op1);
100 int i386_dasm_one_ex(_TCHAR *buffer, UINT64 eip, const UINT8 *oprom, int mode);
101 int i386_dasm_one(_TCHAR *buffer, offs_t eip, const UINT8 *oprom, int mode);
102 int cpu_disassemble_x86_16(_TCHAR *buffer, UINT64 eip, const UINT8 *oprom);
103 int cpu_disassemble_x86_32(_TCHAR *buffer, UINT64 eip, const UINT8 *oprom);
104 int cpu_disassemble_x86_64(_TCHAR *buffer, UINT64 eip, const UINT8 *oprom);
107 INLINE UINT8 I386_OPS::_FETCH(void)
109 if ((opcode_ptr - opcode_ptr_base) + 1 > max_length)
112 return *opcode_ptr++;
116 INLINE UINT16 I386_OPS::_FETCH16(void)
119 if ((opcode_ptr - opcode_ptr_base) + 2 > max_length)
121 d = opcode_ptr[0] | (opcode_ptr[1] << 8);
128 INLINE UINT32 I386_OPS::_FETCH32(void)
131 if ((opcode_ptr - opcode_ptr_base) + 4 > max_length)
133 d = opcode_ptr[0] | (opcode_ptr[1] << 8) | (opcode_ptr[2] << 16) | (opcode_ptr[3] << 24);
139 INLINE UINT8 I386_OPS::_FETCHD(void)
141 if ((opcode_ptr - opcode_ptr_base) + 1 > max_length)
144 return *opcode_ptr++;
147 INLINE UINT16 I386_OPS::_FETCHD16(void)
150 if ((opcode_ptr - opcode_ptr_base) + 2 > max_length)
152 d = opcode_ptr[0] | (opcode_ptr[1] << 8);
158 INLINE UINT32 I386_OPS::_FETCHD32(void)
161 if ((opcode_ptr - opcode_ptr_base) + 4 > max_length)
163 d = opcode_ptr[0] | (opcode_ptr[1] << 8) | (opcode_ptr[2] << 16) | (opcode_ptr[3] << 24);