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 void get_debug_regs_info(_TCHAR *buffer, size_t buffer_len);
64 int debug_dasm(uint32_t pc, _TCHAR *buffer, size_t buffer_len);
67 const UINT8 *opcode_ptr;
68 const UINT8 *opcode_ptr_base;
78 _TCHAR modrm_string[256];
79 UINT8 rex, regex, sibex, rmex;
83 INLINE UINT8 _FETCH(void);
85 INLINE UINT16 _FETCH16(void);
87 INLINE UINT32 _FETCH32(void);
88 INLINE UINT8 _FETCHD(void);
89 INLINE UINT16 _FETCHD16(void);
90 INLINE UINT32 _FETCHD32(void);
91 _TCHAR *hexstring(UINT32 value, int digits);
92 _TCHAR *hexstring64(UINT32 lo, UINT32 hi);
93 _TCHAR *hexstringpc(UINT64 pc);
94 _TCHAR *shexstring(UINT32 value, int digits, int always);
95 _TCHAR* handle_sib_byte( _TCHAR* s, UINT8 mod );
96 void handle_modrm(_TCHAR* s);
97 _TCHAR* handle_param(_TCHAR* s, UINT32 param);
98 void handle_fpu(_TCHAR *s, UINT8 op1, UINT8 op2);
99 void decode_opcode(_TCHAR *s, const I386_OPCODE *op, UINT8 op1);
101 int i386_dasm_one_ex(_TCHAR *buffer, UINT64 eip, const UINT8 *oprom, int mode);
102 int i386_dasm_one(_TCHAR *buffer, offs_t eip, const UINT8 *oprom, int mode);
103 int cpu_disassemble_x86_16(_TCHAR *buffer, UINT64 eip, const UINT8 *oprom);
104 int cpu_disassemble_x86_32(_TCHAR *buffer, UINT64 eip, const UINT8 *oprom);
105 int cpu_disassemble_x86_64(_TCHAR *buffer, UINT64 eip, const UINT8 *oprom);
108 INLINE UINT8 I386_OPS::_FETCH(void)
110 if ((opcode_ptr - opcode_ptr_base) + 1 > max_length)
113 return *opcode_ptr++;
117 INLINE UINT16 I386_OPS::_FETCH16(void)
120 if ((opcode_ptr - opcode_ptr_base) + 2 > max_length)
122 d = opcode_ptr[0] | (opcode_ptr[1] << 8);
129 INLINE UINT32 I386_OPS::_FETCH32(void)
132 if ((opcode_ptr - opcode_ptr_base) + 4 > max_length)
134 d = opcode_ptr[0] | (opcode_ptr[1] << 8) | (opcode_ptr[2] << 16) | (opcode_ptr[3] << 24);
140 INLINE UINT8 I386_OPS::_FETCHD(void)
142 if ((opcode_ptr - opcode_ptr_base) + 1 > max_length)
145 return *opcode_ptr++;
148 INLINE UINT16 I386_OPS::_FETCHD16(void)
151 if ((opcode_ptr - opcode_ptr_base) + 2 > max_length)
153 d = opcode_ptr[0] | (opcode_ptr[1] << 8);
159 INLINE UINT32 I386_OPS::_FETCHD32(void)
162 if ((opcode_ptr - opcode_ptr_base) + 4 > max_length)
164 d = opcode_ptr[0] | (opcode_ptr[1] << 8) | (opcode_ptr[2] << 16) | (opcode_ptr[3] << 24);