2 Skelton for retropc emulator
5 Author : Takeda.Toshiya
11 #if defined(_MSC_VER) && (_MSC_VER >= 1400)
12 #pragma warning( disable : 4996 )
16 //#if defined(HAS_MC6801) || defined(HAS_HD6301)
17 //#include "../fifo.h"
22 #include "mc6800_consts.h"
25 /****************************************************************************/
27 /****************************************************************************/
29 uint32_t MC6800::RM(uint32_t Addr)
31 //#if defined(HAS_MC6801) || defined(HAS_HD6301)
33 // return mc6801_io_r(Addr);
34 // } else if(Addr >= 0x80 && Addr < 0x100 && (ram_ctrl & 0x40)) {
35 // return ram[Addr & 0x7f];
38 return d_mem->read_data8(Addr);
41 void MC6800::WM(uint32_t Addr, uint32_t Value)
43 //#if defined(HAS_MC6801) || defined(HAS_HD6301)
45 // mc6801_io_w(Addr, Value);
46 // } else if(Addr >= 0x80 && Addr < 0x100 && (ram_ctrl & 0x40)) {
47 // ram[Addr & 0x7f] = Value;
50 d_mem->write_data8(Addr, Value);
53 uint32_t MC6800::RM16(uint32_t Addr)
55 uint32_t result = RM(Addr) << 8;
56 return result | RM((Addr + 1) & 0xffff);
59 void MC6800::WM16(uint32_t Addr, pair32_t *p)
62 WM((Addr + 1) & 0xffff, p->b.l);
65 void MC6800::increment_counter(int amount)
67 total_icount += amount;
73 const uint8_t MC6800::flags8i[256] = {
75 0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
76 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
77 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
78 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
79 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
80 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
81 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
82 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
83 0x0a,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
84 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
85 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
86 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
87 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
88 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
89 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
90 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08
93 const uint8_t MC6800::flags8d[256] = {
95 0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
96 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
97 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
98 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
99 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
100 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
101 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
102 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x02,
103 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
104 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
105 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
106 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
107 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
108 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
109 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,
110 0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08
115 void MC6800::initialize()
117 DEVICE::initialize();
118 __USE_DEBUGGER = osd->check_feature(_T("USE_DEBUGGER"));
120 //#ifdef USE_DEBUGGER
121 d_mem_stored = d_mem;
122 d_debugger->set_context_mem(d_mem);
129 //#if defined(HAS_MC6801) || defined(HAS_HD6301)
130 //void MC6800::release()
132 // recv_buffer->release();
133 // delete recv_buffer;
140 SEI; /* IRQ disabled */
151 void MC6800::write_signal(int id, uint32_t data, uint32_t mask)
156 int_state |= INT_REQ_BIT;
158 int_state &= ~INT_REQ_BIT;
163 int_state |= NMI_REQ_BIT;
165 int_state &= ~NMI_REQ_BIT;
171 int MC6800::run(int clock)
175 // run only one opcode
180 /* run cpu while given clocks */
182 int first_icount = icount;
187 return first_icount - icount;
193 void MC6800::run_one_opecode()
195 if(wai_state & (MC6800_WAI | HD6301_SLP)) {
196 increment_counter(1);
199 one_more_insn = false;
201 bool now_debugging = d_debugger->now_debugging;
203 d_debugger->check_break_points(PC);
204 if(d_debugger->now_suspended) {
205 d_debugger->now_waiting = true;
206 emu->start_waiting_in_debugger();
207 while(d_debugger->now_debugging && d_debugger->now_suspended) {
208 emu->process_waiting_in_debugger();
210 emu->finish_waiting_in_debugger();
211 d_debugger->now_waiting = false;
213 if(d_debugger->now_debugging) {
216 now_debugging = false;
219 d_debugger->add_cpu_trace(PC);
220 uint8_t ireg = M_RDOP(PCD);
224 increment_counter(cycles[ireg]);
227 if(!d_debugger->now_going) {
228 d_debugger->now_suspended = true;
230 d_mem = d_mem_stored;
233 if(__USE_DEBUGGER) d_debugger->add_cpu_trace(PC);
234 uint8_t ireg = M_RDOP(PCD);
238 increment_counter(cycles[ireg]);
241 uint8_t ireg = M_RDOP(PCD);
245 increment_counter(cycles[ireg]);
247 } while(one_more_insn);
251 if(int_state & NMI_REQ_BIT) {
252 wai_state &= ~HD6301_SLP;
253 int_state &= ~NMI_REQ_BIT;
254 enter_interrupt(0xfffc);
255 } else if(int_state & INT_REQ_BIT) {
256 wai_state &= ~HD6301_SLP;
258 int_state &= ~INT_REQ_BIT;
259 enter_interrupt(0xfff8);
264 //#ifdef USE_DEBUGGER
265 void MC6800::write_debug_data8(uint32_t addr, uint32_t data)
268 if(d_mem_stored == NULL) return;
269 d_mem_stored->write_data8w(addr, data, &wait);
272 uint32_t MC6800::read_debug_data8(uint32_t addr)
275 if(d_mem_stored == NULL) return 0xff;
276 return d_mem_stored->read_data8w(addr, &wait);
279 void MC6800::write_debug_data16(uint32_t addr, uint32_t data)
281 if(d_mem_stored == NULL) return;
282 write_debug_data8(addr, (data >> 8) & 0xff);
283 write_debug_data8(addr + 1, data & 0xff);
286 uint32_t MC6800::read_debug_data16(uint32_t addr)
288 if(d_mem_stored == NULL) return 0xffff;
289 uint32_t val = read_debug_data8(addr) << 8;
290 val |= read_debug_data8(addr + 1);
294 void MC6800::write_debug_data32(uint32_t addr, uint32_t data)
296 if(d_mem_stored == NULL) return;
297 write_debug_data16(addr, (data >> 16) & 0xffff);
298 write_debug_data16(addr + 2, data & 0xffff);
301 uint32_t MC6800::read_debug_data32(uint32_t addr)
303 if(d_mem_stored == NULL) return 0xffffffff;
304 uint32_t val = read_debug_data16(addr) << 16;
305 val |= read_debug_data16(addr + 2);
309 bool MC6800::write_debug_reg(const _TCHAR *reg, uint32_t data)
311 if(_tcsicmp(reg, _T("A")) == 0) {
313 } else if(_tcsicmp(reg, _T("B")) == 0) {
315 } else if(_tcsicmp(reg, _T("X")) == 0 || _tcsicmp(reg, _T("IX")) == 0) {
317 } else if(_tcsicmp(reg, _T("PC")) == 0) {
319 } else if(_tcsicmp(reg, _T("SP")) == 0) {
327 bool MC6800::get_debug_regs_info(_TCHAR *buffer, size_t buffer_len)
329 my_stprintf_s(buffer, buffer_len,
330 _T("CCR = [%c%c%c%c%c%c] A = %02X B = %02X IX = %04X PC = %04X SP = %04X\n")
331 _T("Clocks = %llu (%llu) Since Scanline = %d/%d (%d/%d)"),
332 (CC & 0x01) ? _T('C') : _T('-'), (CC & 0x02) ? _T('V') : _T('-'), (CC & 0x04) ? _T('Z') : _T('-'), (CC & 0x08) ? _T('N') : _T('-'),
333 (CC & 0x10) ? _T('I') : _T('-'), (CC & 0x20) ? _T('X') : _T('-'), A, B, X, PC, S,
334 total_icount, total_icount - prev_total_icount,
335 get_passed_clock_since_vline(), get_cur_vline_clocks(), get_cur_vline(), get_lines_per_frame());
337 prev_total_icount = total_icount;
342 * A quick-hack 6803/6808 disassembler
344 * Note: this is not the good and proper way to disassemble anything, but it works
346 * I'm afraid to put my name on it, but I feel obligated:
347 * This code written by Aaron Giles (agiles@sirius.com) for the MAME project
351 * The disassembler knows about valid opcodes for M6800/1/2/3/8 and HD63701.
353 * Changed the string array into a table of opcode names (or tokens) and
354 * argument types. This second try should give somewhat better results.
355 * Named the undocumented HD63701YO opcodes $12 and $13 'asx1' and 'asx2',
356 * since 'add contents of stack to x register' is what they do.
363 imb, /* immediate (byte) */
364 imw, /* immediate (word) */
365 dir, /* direct address */
366 imd, /* HD63701YO: immediate, direct address */
367 ext, /* extended address */
368 idx, /* x + byte offset */
369 imx, /* HD63701YO: immediate, x + byte offset */
370 sx1 /* HD63701YO: undocumented opcodes: byte from (s+1) */
374 aba=0, abx, adca, adcb, adda, addb, addd, aim,
375 anda, andb, asl, asla, aslb, asld, asr, asra,
376 asrb, bcc, bcs, beq, bge, bgt, bhi, bita,
377 bitb, ble, bls, blt, bmi, bne, bpl, bra,
378 brn, bsr, bvc, bvs, cba, clc, cli, clr,
379 clra, clrb, clv, cmpa, cmpb, cmpx, com, coma,
380 comb, daa, dec, deca, decb, des, dex, eim,
381 eora, eorb, ill, inc, inca, incb, ins, inx,
382 jmp, jsr, lda, ldb, ldd, lds, ldx, lsr,
383 lsra, lsrb, lsrd, mul, neg, nega, negb, nop,
384 oim, ora, orb, psha, pshb, pshx, pula, pulb,
385 pulx, rol, rola, rolb, ror, rora, rorb, rti,
386 rts, sba, sbca, sbcb, sec, sev, sta, stb,
387 _std, sei, sts, stx, suba, subb, subd, swi,
388 wai, tab, tap, tba, tim, tpa, tst, tsta,
389 tstb, tsx, txs, asx1, asx2, xgdx, addx, adcx
392 static const char *const op_name_str[] = {
393 "aba", "abx", "adca", "adcb", "adda", "addb", "addd", "aim",
394 "anda", "andb", "asl", "asla", "aslb", "asld", "asr", "asra",
395 "asrb", "bcc", "bcs", "beq", "bge", "bgt", "bhi", "bita",
396 "bitb", "ble", "bls", "blt", "bmi", "bne", "bpl", "bra",
397 "brn", "bsr", "bvc", "bvs", "cba", "clc", "cli", "clr",
398 "clra", "clrb", "clv", "cmpa", "cmpb", "cmpx", "com", "coma",
399 "comb", "daa", "dec", "deca", "decb", "des", "dex", "eim",
400 "eora", "eorb", "illegal","inc", "inca", "incb", "ins", "inx",
401 "jmp", "jsr", "lda", "ldb", "ldd", "lds", "ldx", "lsr",
402 "lsra", "lsrb", "lsrd", "mul", "neg", "nega", "negb", "nop",
403 "oim", "ora", "orb", "psha", "pshb", "pshx", "pula", "pulb",
404 "pulx", "rol", "rola", "rolb", "ror", "rora", "rorb", "rti",
405 "rts", "sba", "sbca", "sbcb", "sec", "sev", "sta", "stb",
406 "std", "sei", "sts", "stx", "suba", "subb", "subd", "swi",
407 "wai", "tab", "tap", "tba", "tim", "tpa", "tst", "tsta",
408 "tstb", "tsx", "txs", "asx1", "asx2", "xgdx", "addx", "adcx"
412 * This table defines the opcodes:
416 * 2 invalid opcode for 1:6800/6802/6808, 2:6801/6803, 4:HD63701
419 static const UINT8 table[0x102][3] = {
420 {ill, inh,7},{nop, inh,0},{ill, inh,7},{ill, inh,7},/* 00 */
421 {lsrd,inh,1},{asld,inh,1},{tap, inh,0},{tpa, inh,0},
422 {inx, inh,0},{dex, inh,0},{clv, inh,0},{sev, inh,0},
423 {clc, inh,0},{sec, inh,0},{cli, inh,0},{sei, inh,0},
424 {sba, inh,0},{cba, inh,0},{asx1,sx1,0},{asx2,sx1,0},/* 10 */
425 {ill, inh,7},{ill, inh,7},{tab, inh,0},{tba, inh,0},
426 {xgdx,inh,3},{daa, inh,0},{ill, inh,7},{aba, inh,0},
427 {ill, inh,7},{ill, inh,7},{ill, inh,7},{ill, inh,7},
428 {bra, rel,0},{brn, rel,0},{bhi, rel,0},{bls, rel,0},/* 20 */
429 {bcc, rel,0},{bcs, rel,0},{bne, rel,0},{beq, rel,0},
430 {bvc, rel,0},{bvs, rel,0},{bpl, rel,0},{bmi, rel,0},
431 {bge, rel,0},{blt, rel,0},{bgt, rel,0},{ble, rel,0},
432 {tsx, inh,0},{ins, inh,0},{pula,inh,0},{pulb,inh,0},/* 30 */
433 {des, inh,0},{txs, inh,0},{psha,inh,0},{pshb,inh,0},
434 {pulx,inh,1},{rts, inh,0},{abx, inh,1},{rti, inh,0},
435 {pshx,inh,1},{mul, inh,1},{wai, inh,0},{swi, inh,0},
436 {nega,inh,0},{ill, inh,7},{ill, inh,7},{coma,inh,0},/* 40 */
437 {lsra,inh,0},{ill, inh,7},{rora,inh,0},{asra,inh,0},
438 {asla,inh,0},{rola,inh,0},{deca,inh,0},{ill, inh,7},
439 {inca,inh,0},{tsta,inh,0},{ill, inh,7},{clra,inh,0},
440 {negb,inh,0},{ill, inh,7},{ill, inh,7},{comb,inh,0},/* 50 */
441 {lsrb,inh,0},{ill, inh,7},{rorb,inh,0},{asrb,inh,0},
442 {aslb,inh,0},{rolb,inh,0},{decb,inh,0},{ill, inh,7},
443 {incb,inh,0},{tstb,inh,0},{ill, inh,7},{clrb,inh,0},
444 {neg, idx,0},{aim, imx,3},{oim, imx,3},{com, idx,0},/* 60 */
445 {lsr, idx,0},{eim, imx,3},{ror, idx,0},{asr, idx,0},
446 {asl, idx,0},{rol, idx,0},{dec, idx,0},{tim, imx,3},
447 {inc, idx,0},{tst, idx,0},{jmp, idx,0},{clr, idx,0},
448 {neg, ext,0},{aim, imd,3},{oim, imd,3},{com, ext,0},/* 70 */
449 {lsr, ext,0},{eim, imd,3},{ror, ext,0},{asr, ext,0},
450 {asl, ext,0},{rol, ext,0},{dec, ext,0},{tim, imd,3},
451 {inc, ext,0},{tst, ext,0},{jmp, ext,0},{clr, ext,0},
452 {suba,imb,0},{cmpa,imb,0},{sbca,imb,0},{subd,imw,1},/* 80 */
453 {anda,imb,0},{bita,imb,0},{lda, imb,0},{sta, imb,0},
454 {eora,imb,0},{adca,imb,0},{ora, imb,0},{adda,imb,0},
455 {cmpx,imw,0},{bsr, rel,0},{lds, imw,0},{sts, imw,0},
456 {suba,dir,0},{cmpa,dir,0},{sbca,dir,0},{subd,dir,1},/* 90 */
457 {anda,dir,0},{bita,dir,0},{lda, dir,0},{sta, dir,0},
458 {eora,dir,0},{adca,dir,0},{ora, dir,0},{adda,dir,0},
459 {cmpx,dir,0},{jsr, dir,0},{lds, dir,0},{sts, dir,0},
460 {suba,idx,0},{cmpa,idx,0},{sbca,idx,0},{subd,idx,1},/* a0 */
461 {anda,idx,0},{bita,idx,0},{lda, idx,0},{sta, idx,0},
462 {eora,idx,0},{adca,idx,0},{ora, idx,0},{adda,idx,0},
463 {cmpx,idx,0},{jsr, idx,0},{lds, idx,0},{sts, idx,0},
464 {suba,ext,0},{cmpa,ext,0},{sbca,ext,0},{subd,ext,1},/* b0 */
465 {anda,ext,0},{bita,ext,0},{lda, ext,0},{sta, ext,0},
466 {eora,ext,0},{adca,ext,0},{ora, ext,0},{adda,ext,0},
467 {cmpx,ext,0},{jsr, ext,0},{lds, ext,0},{sts, ext,0},
468 {subb,imb,0},{cmpb,imb,0},{sbcb,imb,0},{addd,imw,1},/* c0 */
469 {andb,imb,0},{bitb,imb,0},{ldb, imb,0},{stb, imb,0},
470 {eorb,imb,0},{adcb,imb,0},{orb, imb,0},{addb,imb,0},
471 {ldd, imw,1},{_std,imw,1},{ldx, imw,0},{stx, imw,0},
472 {subb,dir,0},{cmpb,dir,0},{sbcb,dir,0},{addd,dir,1},/* d0 */
473 {andb,dir,0},{bitb,dir,0},{ldb, dir,0},{stb, dir,0},
474 {eorb,dir,0},{adcb,dir,0},{orb, dir,0},{addb,dir,0},
475 {ldd, dir,1},{_std,dir,1},{ldx, dir,0},{stx, dir,0},
476 {subb,idx,0},{cmpb,idx,0},{sbcb,idx,0},{addd,idx,1},/* e0 */
477 {andb,idx,0},{bitb,idx,0},{ldb, idx,0},{stb, idx,0},
478 {eorb,idx,0},{adcb,idx,0},{orb, idx,0},{addb,idx,0},
479 {ldd, idx,1},{_std,idx,1},{ldx, idx,0},{stx, idx,0},
480 {subb,ext,0},{cmpb,ext,0},{sbcb,ext,0},{addd,ext,1},/* f0 */
481 {andb,ext,0},{bitb,ext,0},{ldb, ext,0},{stb, ext,0},
482 {eorb,ext,0},{adcb,ext,0},{orb, ext,0},{addb,ext,0},
483 {ldd, ext,1},{_std,ext,1},{ldx, ext,0},{stx, ext,0},
485 /* extra instruction $fc for NSC-8105 */
487 /* extra instruction $ec for NSC-8105 */
491 /* some macros to keep things short */
493 #define ARG1 opram[1]
494 #define ARG2 opram[2]
495 #define ARGW (opram[1]<<8) + opram[2]
497 unsigned MC6800::Dasm680x(int subtype, _TCHAR *buf, unsigned pc, const UINT8 *oprom, const UINT8 *opram, symbol_t *first_symbol)
502 UINT8 opcode, args, invalid;
506 case 6800: case 6802: case 6808: case 8105:
509 case 6801: case 6803:
516 /* NSC-8105 is a special case */
520 code = (code & 0x3c) | ((code & 0x41) << 1) | ((code & 0x82) >> 1);
522 /* and check for extra instruction */
523 if (code == 0xfc) code = 0x0100;
524 if (code == 0xec) code = 0x0101;
527 opcode = table[code][0];
528 args = table[code][1];
529 invalid = table[code][2];
531 // if (opcode == bsr || opcode == jsr) {
532 // flags = DASMFLAG_STEP_OVER;
533 // } else if (opcode == rti || opcode == rts) {
534 // flags = DASMFLAG_STEP_OUT;
537 if ( invalid & invalid_mask ) /* invalid for this cpu type ? */
539 _tcscpy(buf, _T("illegal"));
540 return 1;// | flags | DASMFLAG_SUPPORTED;
543 buf += _stprintf(buf, _T("%-5s"), op_name_str[opcode]);
547 case rel: /* relative */
548 _stprintf (buf, _T("%s"), get_value_or_symbol(first_symbol, _T("$%04X"), pc + (INT8)ARG1 + 2));
549 return 2;// | flags | DASMFLAG_SUPPORTED;
550 case imb: /* immediate (byte) */
551 _stprintf (buf, _T("#$%02X"), ARG1);
552 return 2;// | flags | DASMFLAG_SUPPORTED;
553 case imw: /* immediate (word) */
554 _stprintf (buf, _T("#%s"), get_value_or_symbol(first_symbol, _T("$%04X"), ARGW));
555 return 3;// | flags | DASMFLAG_SUPPORTED;
556 case idx: /* indexed + byte offset */
557 _stprintf (buf, _T("(x+$%02X)"), ARG1 );
558 return 2;// | flags | DASMFLAG_SUPPORTED;
559 case imx: /* immediate, indexed + byte offset */
560 _stprintf (buf, _T("#$%02X,(x+$%02x)"), ARG1, ARG2 );
561 return 3;// | flags | DASMFLAG_SUPPORTED;
562 case dir: /* direct address */
563 _stprintf (buf, _T("$%02X"), ARG1 );
564 return 2;// | flags | DASMFLAG_SUPPORTED;
565 case imd: /* immediate, direct address */
566 _stprintf (buf, _T("#$%02X,$%02X"), ARG1, ARG2);
567 return 3;// | flags | DASMFLAG_SUPPORTED;
568 case ext: /* extended address */
569 _stprintf (buf, _T("%s"), get_value_or_symbol(first_symbol, _T("$%04X"), ARGW));
570 return 3;// | flags | DASMFLAG_SUPPORTED;
571 case sx1: /* byte from address (s + 1) */
572 _stprintf (buf, _T("(s+1)"));
573 return 1;// | flags | DASMFLAG_SUPPORTED;
575 return 1;// | flags | DASMFLAG_SUPPORTED;
579 int MC6800::debug_dasm(uint32_t pc, _TCHAR *buffer, size_t buffer_len)
582 if(d_mem_stored != NULL) {
583 for(int i = 0; i < 4; i++) {
585 ops[i] = d_mem_stored->read_data8w(pc + i, &wait);
588 //#if defined(HAS_MC6800)
589 return Dasm680x(6800, buffer, pc, ops, ops, d_debugger->first_symbol);
590 //#elif defined(HAS_MC6801)
591 // return Dasm680x(6801, buffer, pc, ops, ops, d_debugger->first_symbol);
592 //#elif defined(HAS_HD6301)
593 // return Dasm680x(6301, buffer, pc, ops, ops, d_debugger->first_symbol);
594 //#elif defined(HAS_MB8861)
595 // return Dasm680x(6800, buffer, pc, ops, ops, d_debugger->first_symbol); // FIXME
601 void MC6800::enter_interrupt(uint16_t irq_vector)
603 if(wai_state & MC6800_WAI) {
606 wai_state &= ~MC6800_WAI;
617 PCD = RM16(irq_vector);
622 void MC6800::insn(uint8_t code)
625 case 0x00: illegal(); break;
626 case 0x01: nop(); break;
627 case 0x02: illegal(); break;
628 case 0x03: illegal(); break;
629 //#if defined(HAS_MC6801) || defined(HAS_HD6301)
630 // case 0x04: lsrd(); break;
631 // case 0x05: asld(); break;
633 case 0x04: illegal(); break;
634 case 0x05: illegal(); break;
636 case 0x06: tap(); break;
637 case 0x07: tpa(); break;
638 case 0x08: inx(); break;
639 case 0x09: dex(); break;
640 case 0x0a: clv(); break;
641 case 0x0b: sev(); break;
642 case 0x0c: clc(); break;
643 case 0x0d: sec(); break;
644 case 0x0e: cli(); break;
645 case 0x0f: sei(); break;
646 case 0x10: sba(); break;
647 case 0x11: cba(); break;
648 //#if defined(HAS_HD6301)
649 // case 0x12: undoc1(); break;
650 // case 0x13: undoc2(); break;
652 case 0x12: illegal(); break;
653 case 0x13: illegal(); break;
655 case 0x14: illegal(); break;
656 case 0x15: illegal(); break;
657 case 0x16: tab(); break;
658 case 0x17: tba(); break;
659 //#if defined(HAS_HD6301)
660 // case 0x18: xgdx(); break;
662 case 0x18: illegal(); break;
664 case 0x19: daa(); break;
665 //#if defined(HAS_HD6301)
666 // case 0x1a: slp(); break;
668 case 0x1a: illegal(); break;
670 case 0x1b: aba(); break;
671 case 0x1c: illegal(); break;
672 case 0x1d: illegal(); break;
673 case 0x1e: illegal(); break;
674 case 0x1f: illegal(); break;
675 case 0x20: bra(); break;
676 case 0x21: brn(); break;
677 case 0x22: bhi(); break;
678 case 0x23: bls(); break;
679 case 0x24: bcc(); break;
680 case 0x25: bcs(); break;
681 case 0x26: bne(); break;
682 case 0x27: beq(); break;
683 case 0x28: bvc(); break;
684 case 0x29: bvs(); break;
685 case 0x2a: bpl(); break;
686 case 0x2b: bmi(); break;
687 case 0x2c: bge(); break;
688 case 0x2d: blt(); break;
689 case 0x2e: bgt(); break;
690 case 0x2f: ble(); break;
691 case 0x30: tsx(); break;
692 case 0x31: ins(); break;
693 case 0x32: pula(); break;
694 case 0x33: pulb(); break;
695 case 0x34: des(); break;
696 case 0x35: txs(); break;
697 case 0x36: psha(); break;
698 case 0x37: pshb(); break;
699 //#if defined(HAS_MC6801) || defined(HAS_HD6301)
700 // case 0x38: pulx(); break;
702 case 0x38: illegal(); break;
704 case 0x39: rts(); break;
705 //#if defined(HAS_MC6801) || defined(HAS_HD6301)
706 // case 0x3a: abx(); break;
708 case 0x3a: illegal(); break;
710 case 0x3b: rti(); break;
711 //#if defined(HAS_MC6801) || defined(HAS_HD6301)
712 // case 0x3c: pshx(); break;
713 // case 0x3d: mul(); break;
715 case 0x3c: illegal(); break;
716 case 0x3d: illegal(); break;
718 case 0x3e: wai(); break;
719 case 0x3f: swi(); break;
720 case 0x40: nega(); break;
721 case 0x41: illegal(); break;
722 case 0x42: illegal(); break;
723 case 0x43: coma(); break;
724 case 0x44: lsra(); break;
725 case 0x45: illegal(); break;
726 case 0x46: rora(); break;
727 case 0x47: asra(); break;
728 case 0x48: asla(); break;
729 case 0x49: rola(); break;
730 case 0x4a: deca(); break;
731 case 0x4b: illegal(); break;
732 case 0x4c: inca(); break;
733 case 0x4d: tsta(); break;
734 case 0x4e: illegal(); break;
735 case 0x4f: clra(); break;
736 case 0x50: negb(); break;
737 case 0x51: illegal(); break;
738 case 0x52: illegal(); break;
739 case 0x53: comb(); break;
740 case 0x54: lsrb(); break;
741 case 0x55: illegal(); break;
742 case 0x56: rorb(); break;
743 case 0x57: asrb(); break;
744 case 0x58: aslb(); break;
745 case 0x59: rolb(); break;
746 case 0x5a: decb(); break;
747 case 0x5b: illegal(); break;
748 case 0x5c: incb(); break;
749 case 0x5d: tstb(); break;
750 case 0x5e: illegal(); break;
751 case 0x5f: clrb(); break;
752 case 0x60: neg_ix(); break;
753 //#if defined(HAS_HD6301)
754 // case 0x61: aim_ix(); break;
755 // case 0x62: oim_ix(); break;
757 case 0x61: illegal(); break;
758 case 0x62: illegal(); break;
760 case 0x63: com_ix(); break;
761 case 0x64: lsr_ix(); break;
762 //#if defined(HAS_HD6301)
763 // case 0x65: eim_ix(); break;
765 case 0x65: illegal(); break;
767 case 0x66: ror_ix(); break;
768 case 0x67: asr_ix(); break;
769 case 0x68: asl_ix(); break;
770 case 0x69: rol_ix(); break;
771 case 0x6a: dec_ix(); break;
772 //#if defined(HAS_HD6301)
773 // case 0x6b: tim_ix(); break;
775 case 0x6b: illegal(); break;
777 case 0x6c: inc_ix(); break;
778 case 0x6d: tst_ix(); break;
779 case 0x6e: jmp_ix(); break;
780 case 0x6f: clr_ix(); break;
781 case 0x70: neg_ex(); break;
782 //#if defined(HAS_HD6301)
783 // case 0x71: aim_di(); break;
784 // case 0x72: oim_di(); break;
785 //#elif defined(HAS_MB8861)
786 // case 0x71: nim_ix(); break;
787 // case 0x72: oim_ix_mb8861(); break;
789 case 0x71: illegal(); break;
790 case 0x72: illegal(); break;
792 case 0x73: com_ex(); break;
793 case 0x74: lsr_ex(); break;
794 //#if defined(HAS_HD6301)
795 // case 0x75: eim_di(); break;
796 //#elif defined(HAS_MB8861)
797 // case 0x75: xim_ix(); break;
799 case 0x75: illegal(); break;
801 case 0x76: ror_ex(); break;
802 case 0x77: asr_ex(); break;
803 case 0x78: asl_ex(); break;
804 case 0x79: rol_ex(); break;
805 case 0x7a: dec_ex(); break;
806 //#if defined(HAS_HD6301)
807 // case 0x7b: tim_di(); break;
808 //#elif defined(HAS_MB8861)
809 // case 0x7b: tmm_ix(); break;
811 case 0x7b: illegal(); break;
813 case 0x7c: inc_ex(); break;
814 case 0x7d: tst_ex(); break;
815 case 0x7e: jmp_ex(); break;
816 case 0x7f: clr_ex(); break;
817 case 0x80: suba_im(); break;
818 case 0x81: cmpa_im(); break;
819 case 0x82: sbca_im(); break;
820 //#if defined(HAS_MC6801) || defined(HAS_HD6301)
821 // case 0x83: subd_im(); break;
823 case 0x83: illegal(); break;
825 case 0x84: anda_im(); break;
826 case 0x85: bita_im(); break;
827 case 0x86: lda_im(); break;
828 case 0x87: sta_im(); break;
829 case 0x88: eora_im(); break;
830 case 0x89: adca_im(); break;
831 case 0x8a: ora_im(); break;
832 case 0x8b: adda_im(); break;
833 //#if defined(HAS_MC6801) || defined(HAS_HD6301)
834 // case 0x8c: cpx_im (); break;
836 case 0x8c: cmpx_im(); break;
838 case 0x8d: bsr(); break;
839 case 0x8e: lds_im(); break;
840 case 0x8f: sts_im(); break;
841 case 0x90: suba_di(); break;
842 case 0x91: cmpa_di(); break;
843 case 0x92: sbca_di(); break;
844 //#if defined(HAS_MC6801) || defined(HAS_HD6301)
845 // case 0x93: subd_di(); break;
847 case 0x93: illegal(); break;
849 case 0x94: anda_di(); break;
850 case 0x95: bita_di(); break;
851 case 0x96: lda_di(); break;
852 case 0x97: sta_di(); break;
853 case 0x98: eora_di(); break;
854 case 0x99: adca_di(); break;
855 case 0x9a: ora_di(); break;
856 case 0x9b: adda_di(); break;
857 //#if defined(HAS_MC6801) || defined(HAS_HD6301)
858 // case 0x9c: cpx_di (); break;
860 case 0x9c: cmpx_di(); break;
862 case 0x9d: jsr_di(); break;
863 case 0x9e: lds_di(); break;
864 case 0x9f: sts_di(); break;
865 case 0xa0: suba_ix(); break;
866 case 0xa1: cmpa_ix(); break;
867 case 0xa2: sbca_ix(); break;
868 //#if defined(HAS_MC6801) || defined(HAS_HD6301)
869 // case 0xa3: subd_ix(); break;
871 case 0xa3: illegal(); break;
873 case 0xa4: anda_ix(); break;
874 case 0xa5: bita_ix(); break;
875 case 0xa6: lda_ix(); break;
876 case 0xa7: sta_ix(); break;
877 case 0xa8: eora_ix(); break;
878 case 0xa9: adca_ix(); break;
879 case 0xaa: ora_ix(); break;
880 case 0xab: adda_ix(); break;
881 //#if defined(HAS_MC6801) || defined(HAS_HD6301)
882 // case 0xac: cpx_ix (); break;
884 case 0xac: cmpx_ix(); break;
886 case 0xad: jsr_ix(); break;
887 case 0xae: lds_ix(); break;
888 case 0xaf: sts_ix(); break;
889 case 0xb0: suba_ex(); break;
890 case 0xb1: cmpa_ex(); break;
891 case 0xb2: sbca_ex(); break;
892 //#if defined(HAS_MC6801) || defined(HAS_HD6301)
893 // case 0xb3: subd_ex(); break;
895 case 0xb3: illegal(); break;
897 case 0xb4: anda_ex(); break;
898 case 0xb5: bita_ex(); break;
899 case 0xb6: lda_ex(); break;
900 case 0xb7: sta_ex(); break;
901 case 0xb8: eora_ex(); break;
902 case 0xb9: adca_ex(); break;
903 case 0xba: ora_ex(); break;
904 case 0xbb: adda_ex(); break;
905 //#if defined(HAS_MC6801) || defined(HAS_HD6301)
906 // case 0xbc: cpx_ex (); break;
908 case 0xbc: cmpx_ex(); break;
910 case 0xbd: jsr_ex(); break;
911 case 0xbe: lds_ex(); break;
912 case 0xbf: sts_ex(); break;
913 case 0xc0: subb_im(); break;
914 case 0xc1: cmpb_im(); break;
915 case 0xc2: sbcb_im(); break;
916 //#if defined(HAS_MC6801) || defined(HAS_HD6301)
917 // case 0xc3: addd_im(); break;
919 case 0xc3: illegal(); break;
921 case 0xc4: andb_im(); break;
922 case 0xc5: bitb_im(); break;
923 case 0xc6: ldb_im(); break;
924 case 0xc7: stb_im(); break;
925 case 0xc8: eorb_im(); break;
926 case 0xc9: adcb_im(); break;
927 case 0xca: orb_im(); break;
928 case 0xcb: addb_im(); break;
929 //#if defined(HAS_MC6801) || defined(HAS_HD6301)
930 // case 0xcc: ldd_im(); break;
931 // case 0xcd: std_im(); break;
933 case 0xcc: illegal(); break;
934 case 0xcd: illegal(); break;
936 case 0xce: ldx_im(); break;
937 case 0xcf: stx_im(); break;
938 case 0xd0: subb_di(); break;
939 case 0xd1: cmpb_di(); break;
940 case 0xd2: sbcb_di(); break;
941 //#if defined(HAS_MC6801) || defined(HAS_HD6301)
942 // case 0xd3: addd_di(); break;
944 case 0xd3: illegal(); break;
946 case 0xd4: andb_di(); break;
947 case 0xd5: bitb_di(); break;
948 case 0xd6: ldb_di(); break;
949 case 0xd7: stb_di(); break;
950 case 0xd8: eorb_di(); break;
951 case 0xd9: adcb_di(); break;
952 case 0xda: orb_di(); break;
953 case 0xdb: addb_di(); break;
954 //#if defined(HAS_MC6801) || defined(HAS_HD6301)
955 // case 0xdc: ldd_di(); break;
956 // case 0xdd: std_di(); break;
958 case 0xdc: illegal(); break;
959 case 0xdd: illegal(); break;
961 case 0xde: ldx_di(); break;
962 case 0xdf: stx_di(); break;
963 case 0xe0: subb_ix(); break;
964 case 0xe1: cmpb_ix(); break;
965 case 0xe2: sbcb_ix(); break;
966 //#if defined(HAS_MC6801) || defined(HAS_HD6301)
967 // case 0xe3: addd_ix(); break;
969 case 0xe3: illegal(); break;
971 case 0xe4: andb_ix(); break;
972 case 0xe5: bitb_ix(); break;
973 case 0xe6: ldb_ix(); break;
974 case 0xe7: stb_ix(); break;
975 case 0xe8: eorb_ix(); break;
976 case 0xe9: adcb_ix(); break;
977 case 0xea: orb_ix(); break;
978 case 0xeb: addb_ix(); break;
979 //#if defined(HAS_MC6801) || defined(HAS_HD6301)
980 // case 0xec: ldd_ix(); break;
981 // case 0xed: std_ix(); break;
982 //#elif defined(HAS_MB8861)
983 // case 0xec: adx_im(); break;
984 // case 0xed: illegal(); break;
986 case 0xec: illegal(); break;
987 case 0xed: illegal(); break;
989 case 0xee: ldx_ix(); break;
990 case 0xef: stx_ix(); break;
991 case 0xf0: subb_ex(); break;
992 case 0xf1: cmpb_ex(); break;
993 case 0xf2: sbcb_ex(); break;
994 //#if defined(HAS_MC6801) || defined(HAS_HD6301)
995 // case 0xf3: addd_ex(); break;
997 case 0xf3: illegal(); break;
999 case 0xf4: andb_ex(); break;
1000 case 0xf5: bitb_ex(); break;
1001 case 0xf6: ldb_ex(); break;
1002 case 0xf7: stb_ex(); break;
1003 case 0xf8: eorb_ex(); break;
1004 case 0xf9: adcb_ex(); break;
1005 case 0xfa: orb_ex(); break;
1006 case 0xfb: addb_ex(); break;
1007 //#if defined(HAS_MC6801) || defined(HAS_HD6301)
1008 // case 0xfc: ldd_ex(); break;
1009 // case 0xfd: std_ex(); break;
1010 //#elif defined(HAS_MB8861)
1011 // case 0xfc: adx_ex(); break;
1012 // case 0xfd: illegal(); break;
1014 case 0xfc: illegal(); break;
1015 case 0xfd: illegal(); break;
1017 case 0xfe: ldx_ex(); break;
1018 case 0xff: stx_ex(); break;
1019 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
1020 default: __assume(0);
1025 /* operate one instruction for */
1026 #define ONE_MORE_INSN() { \
1027 uint8_t ireg = M_RDOP(PCD); \
1031 increment_counter(cycles[ireg]); \
1035 void MC6800::illegal()
1053 /* $06 TAP inherent ##### */
1058 one_more_insn = true;
1061 /* $07 TPA inherent ----- */
1067 /* $08 INX inherent --*-- */
1075 /* $09 DEX inherent --*-- */
1112 one_more_insn = true;
1120 one_more_insn = true;
1123 /* $10 SBA inherent -**** */
1129 SET_FLAGS8(A, B, t);
1133 /* $11 CBA inherent -**** */
1139 SET_FLAGS8(A, B, t);
1146 /* $16 TAB inherent -**0- */
1154 /* $17 TBA inherent -**0- */
1163 /* $19 DAA inherent (A) -**0* */
1170 if(lsn > 0x09 || CC & 0x20) {
1173 if(msn > 0x80 && lsn > 0x09) {
1176 if(msn > 0x90 || (CC & 0x01)) {
1180 CLR_NZV; /* keep carry from previous operation */
1181 SET_NZ8((uint8_t)t);
1189 /* $1b ABA inherent ***** */
1195 SET_FLAGS8(A, B, t);
1208 /* $20 BRA relative ----- */
1216 /* $21 BRN relative ----- */
1223 /* $22 BHI relative ----- */
1227 BRANCH(!(CC & 0x05));
1230 /* $23 BLS relative ----- */
1237 /* $24 BCC relative ----- */
1241 BRANCH(!(CC & 0x01));
1244 /* $25 BCS relative ----- */
1251 /* $26 BNE relative ----- */
1255 BRANCH(!(CC & 0x04));
1258 /* $27 BEQ relative ----- */
1265 /* $28 BVC relative ----- */
1269 BRANCH(!(CC & 0x02));
1272 /* $29 BVS relative ----- */
1279 /* $2a BPL relative ----- */
1283 BRANCH(!(CC & 0x08));
1286 /* $2b BMI relative ----- */
1293 /* $2c BGE relative ----- */
1300 /* $2d BLT relative ----- */
1307 /* $2e BGT relative ----- */
1311 BRANCH(!(NXORV||CC & 0x04));
1314 /* $2f BLE relative ----- */
1318 BRANCH(NXORV||CC & 0x04);
1321 /* $30 TSX inherent ----- */
1327 /* $31 INS inherent ----- */
1333 /* $32 PULA inherent ----- */
1339 /* $33 PULB inherent ----- */
1345 /* $34 DES inherent ----- */
1351 /* $35 TXS inherent ----- */
1357 /* $36 PSHA inherent ----- */
1363 /* $37 PSHB inherent ----- */
1370 /* $39 RTS inherent ----- */
1377 /* $3b RTI inherent ##### */
1388 /* $3e WAI inherent ----- */
1392 * WAI stacks the entire machine state on the
1393 * hardware stack, then waits for an interrupt.
1395 wai_state |= MC6800_WAI;
1403 /* $3f SWI absolute indirect ----- */
1415 /* $40 NEGA inherent ?**** */
1421 SET_FLAGS8(0, A, r);
1429 /* $43 COMA inherent -**01 */
1438 /* $44 LSRA inherent -0*-* */
1449 /* $46 RORA inherent -**-* */
1453 r = (CC & 0x01) << 7;
1461 /* $47 ASRA inherent ?**-* */
1467 A |= ((A & 0x40) << 1);
1471 /* $48 ASLA inherent ?**** */
1477 SET_FLAGS8(A, A, r);
1481 /* $49 ROLA inherent -**** */
1489 SET_FLAGS8(t, t, r);
1493 /* $4a DECA inherent -***- */
1503 /* $4c INCA inherent -***- */
1511 /* $4d TSTA inherent -**0- */
1520 /* $4f CLRA inherent -0100 */
1528 /* $50 NEGB inherent ?**** */
1534 SET_FLAGS8(0, B, r);
1542 /* $53 COMB inherent -**01 */
1551 /* $54 LSRB inherent -0*-* */
1562 /* $56 RORB inherent -**-* */
1566 r = (CC & 0x01) << 7;
1574 /* $57 ASRB inherent ?**-* */
1580 B |= ((B & 0x40) << 1);
1584 /* $58 ASLB inherent ?**** */
1590 SET_FLAGS8(B, B, r);
1594 /* $59 ROLB inherent -**** */
1602 SET_FLAGS8(t, t, r);
1606 /* $5a DECB inherent -***- */
1616 /* $5c INCB inherent -***- */
1624 /* $5d TSTB inherent -**0- */
1633 /* $5f CLRB inherent -0100 */
1641 /* $60 NEG indexed ?**** */
1642 void MC6800::neg_ix()
1648 SET_FLAGS8(0, t, r);
1653 /* $63 COM indexed -**01 */
1654 void MC6800::com_ix()
1665 /* $64 LSR indexed -0*-* */
1666 void MC6800::lsr_ix()
1678 /* $66 ROR indexed -**-* */
1679 void MC6800::ror_ix()
1683 r = (CC & 0x01) << 7;
1691 /* $67 ASR indexed ?**-* */
1692 void MC6800::asr_ix()
1699 t |= ((t & 0x40) << 1);
1704 /* $68 ASL indexed ?**** */
1705 void MC6800::asl_ix()
1711 SET_FLAGS8(t, t, r);
1715 /* $69 ROL indexed -**** */
1716 void MC6800::rol_ix()
1723 SET_FLAGS8(t, t, r);
1727 /* $6a DEC indexed -***- */
1728 void MC6800::dec_ix()
1739 /* $6c INC indexed -***- */
1740 void MC6800::inc_ix()
1750 /* $6d TST indexed -**0- */
1751 void MC6800::tst_ix()
1759 /* $6e JMP indexed ----- */
1760 void MC6800::jmp_ix()
1766 /* $6f CLR indexed -0100 */
1767 void MC6800::clr_ix()
1775 /* $70 NEG extended ?**** */
1776 void MC6800::neg_ex()
1782 SET_FLAGS8(0, t, r);
1788 /* $73 COM extended -**01 */
1789 void MC6800::com_ex()
1800 /* $74 LSR extended -0*-* */
1801 void MC6800::lsr_ex()
1814 /* $76 ROR extended -**-* */
1815 void MC6800::ror_ex()
1819 r = (CC & 0x01) << 7;
1827 /* $77 ASR extended ?**-* */
1828 void MC6800::asr_ex()
1835 t |= ((t & 0x40) << 1);
1840 /* $78 ASL extended ?**** */
1841 void MC6800::asl_ex()
1847 SET_FLAGS8(t, t, r);
1851 /* $79 ROL extended -**** */
1852 void MC6800::rol_ex()
1859 SET_FLAGS8(t, t, r);
1863 /* $7a DEC extended -***- */
1864 void MC6800::dec_ex()
1876 /* $7c INC extended -***- */
1877 void MC6800::inc_ex()
1887 /* $7d TST extended -**0- */
1888 void MC6800::tst_ex()
1896 /* $7e JMP extended ----- */
1897 void MC6800::jmp_ex()
1903 /* $7f CLR extended -0100 */
1904 void MC6800::clr_ex()
1912 /* $80 SUBA immediate ?**** */
1913 void MC6800::suba_im()
1919 SET_FLAGS8(A, t, r);
1923 /* $81 CMPA immediate ?**** */
1924 void MC6800::cmpa_im()
1930 SET_FLAGS8(A, t, r);
1933 /* $82 SBCA immediate ?**** */
1934 void MC6800::sbca_im()
1938 r = A - t - (CC & 0x01);
1940 SET_FLAGS8(A, t, r);
1944 /* $84 ANDA immediate -**0- */
1945 void MC6800::anda_im()
1954 /* $85 BITA immediate -**0- */
1955 void MC6800::bita_im()
1964 /* $86 LDA immediate -**0- */
1965 void MC6800::lda_im()
1972 /* is this a legal instruction? */
1973 /* $87 STA immediate -**0- */
1974 void MC6800::sta_im()
1982 /* $88 EORA immediate -**0- */
1983 void MC6800::eora_im()
1992 /* $89 ADCA immediate ***** */
1993 void MC6800::adca_im()
1997 r = A + t + (CC & 0x01);
1999 SET_FLAGS8(A, t, r);
2004 /* $8a ORA immediate -**0- */
2005 void MC6800::ora_im()
2014 /* $8b ADDA immediate ***** */
2015 void MC6800::adda_im()
2021 SET_FLAGS8(A, t, r);
2026 /* $8c CMPX immediate -***- */
2027 void MC6800::cmpx_im()
2049 /* $8e LDS immediate -**0- */
2050 void MC6800::lds_im()
2057 /* $8f STS immediate -**0- */
2058 void MC6800::sts_im()
2066 /* $90 SUBA direct ?**** */
2067 void MC6800::suba_di()
2073 SET_FLAGS8(A, t, r);
2077 /* $91 CMPA direct ?**** */
2078 void MC6800::cmpa_di()
2084 SET_FLAGS8(A, t, r);
2087 /* $92 SBCA direct ?**** */
2088 void MC6800::sbca_di()
2092 r = A - t - (CC & 0x01);
2094 SET_FLAGS8(A, t, r);
2098 /* $94 ANDA direct -**0- */
2099 void MC6800::anda_di()
2108 /* $95 BITA direct -**0- */
2109 void MC6800::bita_di()
2118 /* $96 LDA direct -**0- */
2119 void MC6800::lda_di()
2126 /* $97 STA direct -**0- */
2127 void MC6800::sta_di()
2135 /* $98 EORA direct -**0- */
2136 void MC6800::eora_di()
2145 /* $99 ADCA direct ***** */
2146 void MC6800::adca_di()
2150 r = A + t + (CC & 0x01);
2152 SET_FLAGS8(A, t, r);
2157 /* $9a ORA direct -**0- */
2158 void MC6800::ora_di()
2167 /* $9b ADDA direct ***** */
2168 void MC6800::adda_di()
2174 SET_FLAGS8(A, t, r);
2179 /* $9c CMPX direct -***- */
2180 void MC6800::cmpx_di()
2193 /* $9d JSR direct ----- */
2194 void MC6800::jsr_di()
2201 /* $9e LDS direct -**0- */
2202 void MC6800::lds_di()
2209 /* $9f STS direct -**0- */
2210 void MC6800::sts_di()
2218 /* $a0 SUBA indexed ?**** */
2219 void MC6800::suba_ix()
2225 SET_FLAGS8(A, t, r);
2229 /* $a1 CMPA indexed ?**** */
2230 void MC6800::cmpa_ix()
2236 SET_FLAGS8(A, t, r);
2239 /* $a2 SBCA indexed ?**** */
2240 void MC6800::sbca_ix()
2244 r = A - t - (CC & 0x01);
2246 SET_FLAGS8(A, t, r);
2251 /* $a4 ANDA indexed -**0- */
2252 void MC6800::anda_ix()
2261 /* $a5 BITA indexed -**0- */
2262 void MC6800::bita_ix()
2271 /* $a6 LDA indexed -**0- */
2272 void MC6800::lda_ix()
2279 /* $a7 STA indexed -**0- */
2280 void MC6800::sta_ix()
2288 /* $a8 EORA indexed -**0- */
2289 void MC6800::eora_ix()
2298 /* $a9 ADCA indexed ***** */
2299 void MC6800::adca_ix()
2303 r = A + t + (CC & 0x01);
2305 SET_FLAGS8(A, t, r);
2310 /* $aa ORA indexed -**0- */
2311 void MC6800::ora_ix()
2320 /* $ab ADDA indexed ***** */
2321 void MC6800::adda_ix()
2327 SET_FLAGS8(A, t, r);
2332 /* $ac CMPX indexed -***- */
2333 void MC6800::cmpx_ix()
2346 /* $ad JSR indexed ----- */
2347 void MC6800::jsr_ix()
2354 /* $ae LDS indexed -**0- */
2355 void MC6800::lds_ix()
2362 /* $af STS indexed -**0- */
2363 void MC6800::sts_ix()
2371 /* $b0 SUBA extended ?**** */
2372 void MC6800::suba_ex()
2378 SET_FLAGS8(A, t, r);
2382 /* $b1 CMPA extended ?**** */
2383 void MC6800::cmpa_ex()
2389 SET_FLAGS8(A, t, r);
2392 /* $b2 SBCA extended ?**** */
2393 void MC6800::sbca_ex()
2397 r = A - t - (CC & 0x01);
2399 SET_FLAGS8(A, t, r);
2404 /* $b4 ANDA extended -**0- */
2405 void MC6800::anda_ex()
2414 /* $b5 BITA extended -**0- */
2415 void MC6800::bita_ex()
2424 /* $b6 LDA extended -**0- */
2425 void MC6800::lda_ex()
2432 /* $b7 STA extended -**0- */
2433 void MC6800::sta_ex()
2441 /* $b8 EORA extended -**0- */
2442 void MC6800::eora_ex()
2451 /* $b9 ADCA extended ***** */
2452 void MC6800::adca_ex()
2456 r = A + t + (CC & 0x01);
2458 SET_FLAGS8(A, t, r);
2463 /* $ba ORA extended -**0- */
2464 void MC6800::ora_ex()
2473 /* $bb ADDA extended ***** */
2474 void MC6800::adda_ex()
2480 SET_FLAGS8(A, t, r);
2485 /* $bc CMPX extended -***- */
2486 void MC6800::cmpx_ex()
2498 /* $bd JSR extended ----- */
2499 void MC6800::jsr_ex()
2506 /* $be LDS extended -**0- */
2507 void MC6800::lds_ex()
2514 /* $bf STS extended -**0- */
2515 void MC6800::sts_ex()
2523 /* $c0 SUBB immediate ?**** */
2524 void MC6800::subb_im()
2530 SET_FLAGS8(B, t, r);
2534 /* $c1 CMPB immediate ?**** */
2535 void MC6800::cmpb_im()
2541 SET_FLAGS8(B, t, r);
2544 /* $c2 SBCB immediate ?**** */
2545 void MC6800::sbcb_im()
2549 r = B - t - (CC & 0x01);
2551 SET_FLAGS8(B, t, r);
2556 /* $c4 ANDB immediate -**0- */
2557 void MC6800::andb_im()
2566 /* $c5 BITB immediate -**0- */
2567 void MC6800::bitb_im()
2576 /* $c6 LDB immediate -**0- */
2577 void MC6800::ldb_im()
2584 /* is this a legal instruction? */
2585 /* $c7 STB immediate -**0- */
2586 void MC6800::stb_im()
2594 /* $c8 EORB immediate -**0- */
2595 void MC6800::eorb_im()
2604 /* $c9 ADCB immediate ***** */
2605 void MC6800::adcb_im()
2609 r = B + t + (CC & 0x01);
2611 SET_FLAGS8(B, t, r);
2616 /* $ca ORB immediate -**0- */
2617 void MC6800::orb_im()
2626 /* $cb ADDB immediate ***** */
2627 void MC6800::addb_im()
2633 SET_FLAGS8(B, t, r);
2638 /* $ce LDX immediate -**0- */
2639 void MC6800::ldx_im()
2646 /* $cf STX immediate -**0- */
2647 void MC6800::stx_im()
2655 /* $d0 SUBB direct ?**** */
2656 void MC6800::subb_di()
2662 SET_FLAGS8(B, t, r);
2666 /* $d1 CMPB direct ?**** */
2667 void MC6800::cmpb_di()
2673 SET_FLAGS8(B, t, r);
2676 /* $d2 SBCB direct ?**** */
2677 void MC6800::sbcb_di()
2681 r = B - t - (CC & 0x01);
2683 SET_FLAGS8(B, t, r);
2688 /* $d4 ANDB direct -**0- */
2689 void MC6800::andb_di()
2698 /* $d5 BITB direct -**0- */
2699 void MC6800::bitb_di()
2708 /* $d6 LDB direct -**0- */
2709 void MC6800::ldb_di()
2716 /* $d7 STB direct -**0- */
2717 void MC6800::stb_di()
2725 /* $d8 EORB direct -**0- */
2726 void MC6800::eorb_di()
2735 /* $d9 ADCB direct ***** */
2736 void MC6800::adcb_di()
2740 r = B + t + (CC & 0x01);
2742 SET_FLAGS8(B, t, r);
2747 /* $da ORB direct -**0- */
2748 void MC6800::orb_di()
2757 /* $db ADDB direct ***** */
2758 void MC6800::addb_di()
2764 SET_FLAGS8(B, t, r);
2769 /* $de LDX direct -**0- */
2770 void MC6800::ldx_di()
2777 /* $dF STX direct -**0- */
2778 void MC6800::stx_di()
2786 /* $e0 SUBB indexed ?**** */
2787 void MC6800::subb_ix()
2793 SET_FLAGS8(B, t, r);
2797 /* $e1 CMPB indexed ?**** */
2798 void MC6800::cmpb_ix()
2804 SET_FLAGS8(B, t, r);
2807 /* $e2 SBCB indexed ?**** */
2808 void MC6800::sbcb_ix()
2812 r = B - t - (CC & 0x01);
2814 SET_FLAGS8(B, t, r);
2819 /* $e4 ANDB indexed -**0- */
2820 void MC6800::andb_ix()
2829 /* $e5 BITB indexed -**0- */
2830 void MC6800::bitb_ix()
2839 /* $e6 LDB indexed -**0- */
2840 void MC6800::ldb_ix()
2847 /* $e7 STB indexed -**0- */
2848 void MC6800::stb_ix()
2856 /* $e8 EORB indexed -**0- */
2857 void MC6800::eorb_ix()
2866 /* $e9 ADCB indexed ***** */
2867 void MC6800::adcb_ix()
2871 r = B + t + (CC & 0x01);
2873 SET_FLAGS8(B, t, r);
2878 /* $ea ORB indexed -**0- */
2879 void MC6800::orb_ix()
2888 /* $eb ADDB indexed ***** */
2889 void MC6800::addb_ix()
2895 SET_FLAGS8(B, t, r);
2903 /* $ee LDX indexed -**0- */
2904 void MC6800::ldx_ix()
2911 /* $ef STX indexed -**0- */
2912 void MC6800::stx_ix()
2920 /* $f0 SUBB extended ?**** */
2921 void MC6800::subb_ex()
2927 SET_FLAGS8(B, t, r);
2931 /* $f1 CMPB extended ?**** */
2932 void MC6800::cmpb_ex()
2938 SET_FLAGS8(B, t, r);
2941 /* $f2 SBCB extended ?**** */
2942 void MC6800::sbcb_ex()
2946 r = B - t - (CC & 0x01);
2948 SET_FLAGS8(B, t, r);
2953 /* $f4 ANDB extended -**0- */
2954 void MC6800::andb_ex()
2963 /* $f5 BITB extended -**0- */
2964 void MC6800::bitb_ex()
2973 /* $f6 LDB extended -**0- */
2974 void MC6800::ldb_ex()
2981 /* $f7 STB extended -**0- */
2982 void MC6800::stb_ex()
2990 /* $f8 EORB extended -**0- */
2991 void MC6800::eorb_ex()
3000 /* $f9 ADCB extended ***** */
3001 void MC6800::adcb_ex()
3005 r = B + t + (CC & 0x01);
3007 SET_FLAGS8(B, t, r);
3012 /* $fa ORB extended -**0- */
3013 void MC6800::orb_ex()
3022 /* $fb ADDB extended ***** */
3023 void MC6800::addb_ex()
3029 SET_FLAGS8(B, t, r);
3036 /* $fe LDX extended -**0- */
3037 void MC6800::ldx_ex()
3044 /* $ff STX extended -**0- */
3045 void MC6800::stx_ex()
3053 #define STATE_VERSION 2
3055 bool MC6800::process_state(FILEIO* state_fio, bool loading)
3057 if(!state_fio->StateCheckUint32(STATE_VERSION)) {
3060 if(!state_fio->StateCheckInt32(this_device_id)) {
3063 state_fio->StateValue(pc.d);
3064 state_fio->StateValue(prevpc);
3065 state_fio->StateValue(sp.d);
3066 state_fio->StateValue(ix.d);
3067 state_fio->StateValue(acc_d.d);
3068 state_fio->StateValue(ea.d);
3069 state_fio->StateValue(cc);
3070 state_fio->StateValue(wai_state);
3071 state_fio->StateValue(int_state);
3072 if(__USE_DEBUGGER) {
3073 state_fio->StateValue(total_icount);
3075 state_fio->StateValue(icount);
3078 if(__USE_DEBUGGER) {
3080 prev_total_icount = total_icount;