2 Skelton for retropc emulator
5 Author : Takeda.Toshiya
18 #define SIG_I86_TEST 0
24 class I86 : public DEVICE
27 /* ---------------------------------------------------------------------------
29 --------------------------------------------------------------------------- */
31 DEVICE *d_mem, *d_io, *d_pic, *d_bios;
32 #ifdef SINGLE_MODE_DMA
37 DEVICE *d_mem_stored, *d_io_stored;
40 /* ---------------------------------------------------------------------------
42 --------------------------------------------------------------------------- */
45 uint16_t w[8]; /* viewed as 16 bits registers */
46 uint8_t b[16]; /* or as 8 bit registers */
53 int32_t AuxVal, OverVal, SignVal, ZeroVal, CarryVal, DirVal;
64 bool seg_prefix; /* prefix segment indicator */
65 uint8_t prefix_seg; /* The prefixed segment */
67 uint16_t eo; /* effective offset of the address (before segment is added) */
68 uint8_t ea_seg; /* effective segment of the address */
70 /* ---------------------------------------------------------------------------
72 --------------------------------------------------------------------------- */
75 void interrupt(int num);
77 unsigned GetEA(unsigned ModRM);
78 void rotate_shift_byte(unsigned ModRM, unsigned cnt);
79 void rotate_shift_word(unsigned ModRM, unsigned cnt);
82 void run_one_opecode();
84 void run_one_opecode_debugger();
86 void instruction(uint8_t code);
87 inline void _add_br8();
88 inline void _add_wr16();
89 inline void _add_r8b();
90 inline void _add_r16w();
91 inline void _add_ald8();
92 inline void _add_axd16();
93 inline void _push_es();
94 inline void _pop_es();
95 inline void _or_br8();
96 inline void _or_wr16();
97 inline void _or_r8b();
98 inline void _or_r16w();
99 inline void _or_ald8();
100 inline void _or_axd16();
101 inline void _push_cs();
103 inline void _0fpre();
105 inline void _adc_br8();
106 inline void _adc_wr16();
107 inline void _adc_r8b();
108 inline void _adc_r16w();
109 inline void _adc_ald8();
110 inline void _adc_axd16();
111 inline void _push_ss();
112 inline void _pop_ss();
113 inline void _sbb_br8();
114 inline void _sbb_wr16();
115 inline void _sbb_r8b();
116 inline void _sbb_r16w();
117 inline void _sbb_ald8();
118 inline void _sbb_axd16();
119 inline void _push_ds();
120 inline void _pop_ds();
121 inline void _and_br8();
122 inline void _and_wr16();
123 inline void _and_r8b();
124 inline void _and_r16w();
125 inline void _and_ald8();
126 inline void _and_axd16();
129 inline void _sub_br8();
130 inline void _sub_wr16();
131 inline void _sub_r8b();
132 inline void _sub_r16w();
133 inline void _sub_ald8();
134 inline void _sub_axd16();
137 inline void _xor_br8();
138 inline void _xor_wr16();
139 inline void _xor_r8b();
140 inline void _xor_r16w();
141 inline void _xor_ald8();
142 inline void _xor_axd16();
145 inline void _cmp_br8();
146 inline void _cmp_wr16();
147 inline void _cmp_r8b();
148 inline void _cmp_r16w();
149 inline void _cmp_ald8();
150 inline void _cmp_axd16();
153 inline void _inc_ax();
154 inline void _inc_cx();
155 inline void _inc_dx();
156 inline void _inc_bx();
157 inline void _inc_sp();
158 inline void _inc_bp();
159 inline void _inc_si();
160 inline void _inc_di();
161 inline void _dec_ax();
162 inline void _dec_cx();
163 inline void _dec_dx();
164 inline void _dec_bx();
165 inline void _dec_sp();
166 inline void _dec_bp();
167 inline void _dec_si();
168 inline void _dec_di();
169 inline void _push_ax();
170 inline void _push_cx();
171 inline void _push_dx();
172 inline void _push_bx();
173 inline void _push_sp();
174 inline void _push_bp();
175 inline void _push_si();
176 inline void _push_di();
177 inline void _pop_ax();
178 inline void _pop_cx();
179 inline void _pop_dx();
180 inline void _pop_bx();
181 inline void _pop_sp();
182 inline void _pop_bp();
183 inline void _pop_si();
184 inline void _pop_di();
185 inline void _pusha();
187 inline void _bound();
188 inline void _repc(int flagval);
189 inline void _push_d16();
190 inline void _imul_d16();
191 inline void _push_d8();
192 inline void _imul_d8();
195 inline void _outsb();
196 inline void _outsw();
213 inline void _80pre();
214 inline void _81pre();
215 inline void _82pre();
216 inline void _83pre();
217 inline void _test_br8();
218 inline void _test_wr16();
219 inline void _xchg_br8();
220 inline void _xchg_wr16();
221 inline void _mov_br8();
222 inline void _mov_wr16();
223 inline void _mov_r8b();
224 inline void _mov_r16w();
225 inline void _mov_wsreg();
227 inline void _mov_sregw();
230 inline void _xchg_axcx();
231 inline void _xchg_axdx();
232 inline void _xchg_axbx();
233 inline void _xchg_axsp();
234 inline void _xchg_axbp();
235 inline void _xchg_axsi();
236 inline void _xchg_axdi();
239 inline void _call_far();
241 inline void _pushf();
245 inline void _mov_aldisp();
246 inline void _mov_axdisp();
247 inline void _mov_dispal();
248 inline void _mov_dispax();
249 inline void _movsb();
250 inline void _movsw();
251 inline void _cmpsb();
252 inline void _cmpsw();
253 inline void _test_ald8();
254 inline void _test_axd16();
255 inline void _stosb();
256 inline void _stosw();
257 inline void _lodsb();
258 inline void _lodsw();
259 inline void _scasb();
260 inline void _scasw();
261 inline void _mov_ald8();
262 inline void _mov_cld8();
263 inline void _mov_dld8();
264 inline void _mov_bld8();
265 inline void _mov_ahd8();
266 inline void _mov_chd8();
267 inline void _mov_dhd8();
268 inline void _mov_bhd8();
269 inline void _mov_axd16();
270 inline void _mov_cxd16();
271 inline void _mov_dxd16();
272 inline void _mov_bxd16();
273 inline void _mov_spd16();
274 inline void _mov_bpd16();
275 inline void _mov_sid16();
276 inline void _mov_did16();
277 inline void _rotshft_bd8();
278 inline void _rotshft_wd8();
279 inline void _ret_d16();
281 inline void _les_dw();
282 inline void _lds_dw();
283 inline void _mov_bd8();
284 inline void _mov_wd16();
285 inline void _enter();
286 inline void _leav(); // _leave()
287 inline void _retf_d16();
293 inline void _rotshft_b();
294 inline void _rotshft_w();
295 inline void _rotshft_bcl();
296 inline void _rotshft_wcl();
299 inline void _setalc();
301 inline void _escape();
302 inline void _loopne();
303 inline void _loope();
308 inline void _outal();
309 inline void _outax();
310 inline void _call_d16();
311 inline void _jmp_d16();
312 inline void _jmp_far();
313 inline void _jmp_d8();
314 inline void _inaldx();
315 inline void _inaxdx();
316 inline void _outdxal();
317 inline void _outdxax();
319 inline void _rep(int flagval);
320 inline void _repne();
324 inline void _f6pre();
325 inline void _f7pre();
332 inline void _fepre();
333 inline void _ffpre();
334 inline void _invalid();
337 I86(VM* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu)
340 #ifdef SINGLE_MODE_DMA
345 set_device_name(_T("i8086 CPU"));
347 set_device_name(_T("i80186 CPU"));
356 void write_signal(int id, uint32_t data, uint32_t mask);
357 void set_intr_line(bool line, bool pending, uint32_t bit);
358 void set_extra_clock(int clock)
360 extra_icount += clock;
362 int get_extra_clock()
370 uint32_t get_next_pc()
379 uint32_t get_debug_prog_addr_mask()
383 uint32_t get_debug_data_addr_mask()
387 void write_debug_data8(uint32_t addr, uint32_t data);
388 uint32_t read_debug_data8(uint32_t addr);
389 void write_debug_data16(uint32_t addr, uint32_t data);
390 uint32_t read_debug_data16(uint32_t addr);
391 void write_debug_io8(uint32_t addr, uint32_t data);
392 uint32_t read_debug_io8(uint32_t addr);
393 void write_debug_io16(uint32_t addr, uint32_t data);
394 uint32_t read_debug_io16(uint32_t addr);
395 bool write_debug_reg(const _TCHAR *reg, uint32_t data);
396 void get_debug_regs_info(_TCHAR *buffer, size_t buffer_len);
397 int debug_dasm(uint32_t pc, _TCHAR *buffer, size_t buffer_len);
399 void save_state(FILEIO* state_fio);
400 bool load_state(FILEIO* state_fio);
403 void set_context_mem(DEVICE* device)
407 void set_context_io(DEVICE* device)
411 void set_context_intr(DEVICE* device)
415 void set_context_bios(DEVICE* device)
419 #ifdef SINGLE_MODE_DMA
420 void set_context_dma(DEVICE* device)
426 void set_context_debugger(DEBUGGER* device)