switch (cpu_6800_fetch_byte(self)) {
case 0x00:
- cpu_6800_ill(self);
+ cpu_6800_illegal_opcode(self);
break;
case 0x01:
cpu_6800_nop(self);
break;
case 0x02:
- cpu_6800_ill(self);
+ cpu_6800_illegal_opcode(self);
break;
case 0x03:
- cpu_6800_ill(self);
+ cpu_6800_illegal_opcode(self);
break;
case 0x04:
- cpu_6800_ill(self);
+ cpu_6800_illegal_opcode(self);
break;
case 0x05:
- cpu_6800_ill(self);
+ cpu_6800_illegal_opcode(self);
break;
case 0x06:
cpu_6800_tap(self);
cpu_6800_tpa(self);
break;
case 0x08:
- cpu_6800_inx(self);
+ cpu_6800_inc_word_zf(self, CPU_6800_EA_X);
break;
case 0x09:
- cpu_6800_dex(self);
+ cpu_6800_dec_word_zf(self, CPU_6800_EA_X);
break;
case 0x0a:
cpu_6800_cl(self, CPU_6800_REG_P_BIT_V);
cpu_6800_sub(self, CPU_6800_EA_A, self->regs.byte.b);
break;
case 0x11:
- cpu_6800_cmp(self, self->regs.byte.a, self->regs.byte.b);
+ cpu_6800_cmp_byte(self, self->regs.byte.a, self->regs.byte.b);
break;
case 0x12:
- cpu_6800_ill(self);
+ cpu_6800_illegal_opcode(self);
break;
case 0x13:
- cpu_6800_ill(self);
+ cpu_6800_illegal_opcode(self);
break;
case 0x14:
- cpu_6800_ill(self);
+ cpu_6800_illegal_opcode(self);
break;
case 0x15:
- cpu_6800_ill(self);
+ cpu_6800_illegal_opcode(self);
break;
case 0x16:
- cpu_6800_lda(self, CPU_6800_EA_B, self->regs.byte.a);
+ cpu_6800_ld_byte(self, CPU_6800_EA_B, self->regs.byte.a);
break;
case 0x17:
- cpu_6800_lda(self, CPU_6800_EA_A, self->regs.byte.b);
+ cpu_6800_ld_byte(self, CPU_6800_EA_A, self->regs.byte.b);
break;
case 0x18:
- cpu_6800_ill(self);
+ cpu_6800_illegal_opcode(self);
break;
case 0x19:
cpu_6800_daa(self);
break;
case 0x1a:
- cpu_6800_ill(self);
+ cpu_6800_illegal_opcode(self);
break;
case 0x1b:
cpu_6800_add(self, CPU_6800_EA_A, self->regs.byte.b);
break;
case 0x1c:
- cpu_6800_ill(self);
+ cpu_6800_illegal_opcode(self);
break;
case 0x1d:
- cpu_6800_ill(self);
+ cpu_6800_illegal_opcode(self);
break;
case 0x1e:
- cpu_6800_ill(self);
+ cpu_6800_illegal_opcode(self);
break;
case 0x1f:
- cpu_6800_ill(self);
+ cpu_6800_illegal_opcode(self);
break;
case 0x20:
cpu_6800_bra(self, true, cpu_6800_ea_relative(self));
break;
case 0x21:
- cpu_6800_ill(self);
+ cpu_6800_illegal_opcode(self);
break;
case 0x22:
cpu_6800_bra(self, !self->regs.bit.cf && !self->regs.bit.zf, cpu_6800_ea_relative(self));
cpu_6800_tsx(self);
break;
case 0x31:
- cpu_6800_ins(self);
+ cpu_6800_inc_word(self, CPU_6800_EA_S);
break;
case 0x32:
cpu_6800_pul(self, CPU_6800_EA_A);
cpu_6800_pul(self, CPU_6800_EA_B);
break;
case 0x34:
- cpu_6800_des(self);
+ cpu_6800_dec_word(self, CPU_6800_EA_S);
break;
case 0x35:
cpu_6800_txs(self);
cpu_6800_psh(self, self->regs.byte.b);
break;
case 0x38:
- cpu_6800_ill(self);
+ cpu_6800_illegal_opcode(self);
break;
case 0x39:
cpu_6800_rts(self);
break;
case 0x3a:
- cpu_6800_ill(self);
+ cpu_6800_illegal_opcode(self);
break;
case 0x3b:
cpu_6800_rti(self);
break;
case 0x3c:
- cpu_6800_ill(self);
+ cpu_6800_illegal_opcode(self);
break;
case 0x3d:
- cpu_6800_ill(self);
+ cpu_6800_illegal_opcode(self);
break;
case 0x3e:
cpu_6800_wai(self);
cpu_6800_neg(self, CPU_6800_EA_A);
break;
case 0x41:
- cpu_6800_ill(self);
+ cpu_6800_illegal_opcode(self);
break;
case 0x42:
- cpu_6800_ill(self);
+ cpu_6800_illegal_opcode(self);
break;
case 0x43:
cpu_6800_com(self, CPU_6800_EA_A);
cpu_6800_lsr(self, CPU_6800_EA_A);
break;
case 0x45:
- cpu_6800_ill(self);
+ cpu_6800_illegal_opcode(self);
break;
case 0x46:
cpu_6800_ror(self, CPU_6800_EA_A);
cpu_6800_rol(self, CPU_6800_EA_A);
break;
case 0x4a:
- cpu_6800_dec(self, CPU_6800_EA_A);
+ cpu_6800_dec_byte(self, CPU_6800_EA_A);
break;
case 0x4b:
- cpu_6800_ill(self);
+ cpu_6800_illegal_opcode(self);
break;
case 0x4c:
- cpu_6800_inc(self, CPU_6800_EA_A);
+ cpu_6800_inc_byte(self, CPU_6800_EA_A);
break;
case 0x4d:
- cpu_6800_cmp(self, self->regs.byte.a, 0);
+ cpu_6800_cmp_byte(self, self->regs.byte.a, 0);
break;
case 0x4e:
- cpu_6800_ill(self);
+ cpu_6800_illegal_opcode(self);
break;
case 0x4f:
cpu_6800_clr(self, CPU_6800_EA_A);
cpu_6800_neg(self, CPU_6800_EA_B);
break;
case 0x51:
- cpu_6800_ill(self);
+ cpu_6800_illegal_opcode(self);
break;
case 0x52:
- cpu_6800_ill(self);
+ cpu_6800_illegal_opcode(self);
break;
case 0x53:
cpu_6800_com(self, CPU_6800_EA_B);
cpu_6800_lsr(self, CPU_6800_EA_B);
break;
case 0x55:
- cpu_6800_ill(self);
+ cpu_6800_illegal_opcode(self);
break;
case 0x56:
cpu_6800_ror(self, CPU_6800_EA_B);
cpu_6800_rol(self, CPU_6800_EA_B);
break;
case 0x5a:
- cpu_6800_dec(self, CPU_6800_EA_B);
+ cpu_6800_dec_byte(self, CPU_6800_EA_B);
break;
case 0x5b:
- cpu_6800_ill(self);
+ cpu_6800_illegal_opcode(self);
break;
case 0x5c:
- cpu_6800_inc(self, CPU_6800_EA_B);
+ cpu_6800_inc_byte(self, CPU_6800_EA_B);
break;
case 0x5d:
- cpu_6800_cmp(self, self->regs.byte.b, 0);
+ cpu_6800_cmp_byte(self, self->regs.byte.b, 0);
break;
case 0x5e:
- cpu_6800_ill(self);
+ cpu_6800_illegal_opcode(self);
break;
case 0x5f:
cpu_6800_clr(self, CPU_6800_EA_B);
cpu_6800_neg(self, cpu_6800_ea_direct_indexed(self, self->regs.word.x));
break;
case 0x61:
- cpu_6800_ill(self);
+ cpu_6800_illegal_opcode(self);
break;
case 0x62:
- cpu_6800_ill(self);
+ cpu_6800_illegal_opcode(self);
break;
case 0x63:
cpu_6800_com(self, cpu_6800_ea_direct_indexed(self, self->regs.word.x));
cpu_6800_lsr(self, cpu_6800_ea_direct_indexed(self, self->regs.word.x));
break;
case 0x65:
- cpu_6800_ill(self);
+ cpu_6800_illegal_opcode(self);
break;
case 0x66:
cpu_6800_ror(self, cpu_6800_ea_direct_indexed(self, self->regs.word.x));
cpu_6800_rol(self, cpu_6800_ea_direct_indexed(self, self->regs.word.x));
break;
case 0x6a:
- cpu_6800_dec(self, cpu_6800_ea_direct_indexed(self, self->regs.word.x));
+ cpu_6800_dec_byte(self, cpu_6800_ea_direct_indexed(self, self->regs.word.x));
break;
case 0x6b:
- cpu_6800_ill(self);
+ cpu_6800_illegal_opcode(self);
break;
case 0x6c:
- cpu_6800_inc(self, cpu_6800_ea_direct_indexed(self, self->regs.word.x));
+ cpu_6800_inc_byte(self, cpu_6800_ea_direct_indexed(self, self->regs.word.x));
break;
case 0x6d:
- cpu_6800_cmp(self, cpu_6800_read_byte(self, cpu_6800_ea_direct_indexed(self, self->regs.word.x)), 0);
+ cpu_6800_cmp_byte(self, cpu_6800_read_byte(self, cpu_6800_ea_direct_indexed(self, self->regs.word.x)), 0);
break;
case 0x6e:
cpu_6800_jmp(self, cpu_6800_ea_direct_indexed(self, self->regs.word.x));
cpu_6800_neg(self, cpu_6800_ea_extended(self));
break;
case 0x71:
- cpu_6800_ill(self);
+ cpu_6800_illegal_opcode(self);
break;
case 0x72:
- cpu_6800_ill(self);
+ cpu_6800_illegal_opcode(self);
break;
case 0x73:
cpu_6800_com(self, cpu_6800_ea_extended(self));
cpu_6800_lsr(self, cpu_6800_ea_extended(self));
break;
case 0x75:
- cpu_6800_ill(self);
+ cpu_6800_illegal_opcode(self);
break;
case 0x76:
cpu_6800_ror(self, cpu_6800_ea_extended(self));
cpu_6800_rol(self, cpu_6800_ea_extended(self));
break;
case 0x7a:
- cpu_6800_dec(self, cpu_6800_ea_extended(self));
+ cpu_6800_dec_byte(self, cpu_6800_ea_extended(self));
break;
case 0x7b:
- cpu_6800_ill(self);
+ cpu_6800_illegal_opcode(self);
break;
case 0x7c:
- cpu_6800_inc(self, cpu_6800_ea_extended(self));
+ cpu_6800_inc_byte(self, cpu_6800_ea_extended(self));
break;
case 0x7d:
- cpu_6800_cmp(self, cpu_6800_read_byte(self, cpu_6800_ea_extended(self)), 0);
+ cpu_6800_cmp_byte(self, cpu_6800_read_byte(self, cpu_6800_ea_extended(self)), 0);
break;
case 0x7e:
cpu_6800_jmp(self, cpu_6800_ea_extended(self));
cpu_6800_sub(self, CPU_6800_EA_A, cpu_6800_fetch_byte(self));
break;
case 0x81:
- cpu_6800_cmp(self, self->regs.byte.a, cpu_6800_fetch_byte(self));
+ cpu_6800_cmp_byte(self, self->regs.byte.a, cpu_6800_fetch_byte(self));
break;
case 0x82:
cpu_6800_sbc(self, CPU_6800_EA_A, cpu_6800_fetch_byte(self));
break;
case 0x83:
- cpu_6800_ill(self);
+ cpu_6800_illegal_opcode(self);
break;
case 0x84:
cpu_6800_and(self, CPU_6800_EA_A, cpu_6800_fetch_byte(self));
cpu_6800_bit(self, CPU_6800_EA_A, cpu_6800_fetch_byte(self));
break;
case 0x86:
- cpu_6800_lda(self, CPU_6800_EA_A, cpu_6800_fetch_byte(self));
+ cpu_6800_ld_byte(self, CPU_6800_EA_A, cpu_6800_fetch_byte(self));
break;
case 0x87:
- cpu_6800_ill(self);
+ cpu_6800_illegal_opcode(self);
break;
case 0x88:
cpu_6800_eor(self, CPU_6800_EA_A, cpu_6800_fetch_byte(self));
cpu_6800_add(self, CPU_6800_EA_A, cpu_6800_fetch_byte(self));
break;
case 0x8c:
- cpu_6800_cp(self, self->regs.word.x, cpu_6800_fetch_word(self));
+ cpu_6800_cmp_word(self, self->regs.word.x, cpu_6800_fetch_word(self));
break;
case 0x8d:
cpu_6800_bsr(self, cpu_6800_ea_relative(self));
break;
case 0x8e:
- cpu_6800_ld(self, CPU_6800_EA_S, cpu_6800_fetch_word(self));
+ cpu_6800_ld_word(self, CPU_6800_EA_S, cpu_6800_fetch_word(self));
break;
case 0x8f:
- cpu_6800_ill(self);
+ cpu_6800_illegal_opcode(self);
break;
case 0x90:
cpu_6800_sub(self, CPU_6800_EA_A, cpu_6800_read_byte(self, cpu_6800_ea_direct(self)));
break;
case 0x91:
- cpu_6800_cmp(self, self->regs.byte.a, cpu_6800_read_byte(self, cpu_6800_ea_direct(self)));
+ cpu_6800_cmp_byte(self, self->regs.byte.a, cpu_6800_read_byte(self, cpu_6800_ea_direct(self)));
break;
case 0x92:
cpu_6800_sbc(self, CPU_6800_EA_A, cpu_6800_read_byte(self, cpu_6800_ea_direct(self)));
break;
case 0x93:
- cpu_6800_ill(self);
+ cpu_6800_illegal_opcode(self);
break;
case 0x94:
cpu_6800_and(self, CPU_6800_EA_A, cpu_6800_read_byte(self, cpu_6800_ea_direct(self)));
cpu_6800_bit(self, CPU_6800_EA_A, cpu_6800_read_byte(self, cpu_6800_ea_direct(self)));
break;
case 0x96:
- cpu_6800_lda(self, CPU_6800_EA_A, cpu_6800_read_byte(self, cpu_6800_ea_direct(self)));
+ cpu_6800_ld_byte(self, CPU_6800_EA_A, cpu_6800_read_byte(self, cpu_6800_ea_direct(self)));
break;
case 0x97:
- cpu_6800_sta(self, self->regs.byte.a, cpu_6800_ea_direct(self));
+ cpu_6800_st_byte(self, self->regs.byte.a, cpu_6800_ea_direct(self));
break;
case 0x98:
cpu_6800_eor(self, CPU_6800_EA_A, cpu_6800_read_byte(self, cpu_6800_ea_direct(self)));
cpu_6800_add(self, CPU_6800_EA_A, cpu_6800_read_byte(self, cpu_6800_ea_direct(self)));
break;
case 0x9c:
- cpu_6800_cp(self, self->regs.word.x, cpu_6800_read_word(self, cpu_6800_ea_direct(self)));
+ cpu_6800_cmp_word(self, self->regs.word.x, cpu_6800_read_word(self, cpu_6800_ea_direct(self)));
break;
case 0x9d:
- cpu_6800_ill(self);
+ cpu_6800_illegal_opcode(self);
break;
case 0x9e:
- cpu_6800_ld(self, CPU_6800_EA_S, cpu_6800_read_word(self, cpu_6800_ea_direct(self)));
+ cpu_6800_ld_word(self, CPU_6800_EA_S, cpu_6800_read_word(self, cpu_6800_ea_direct(self)));
break;
case 0x9f:
- cpu_6800_st(self, self->regs.word.s, cpu_6800_ea_direct(self));
+ cpu_6800_st_word(self, self->regs.word.s, cpu_6800_ea_direct(self));
break;
case 0xa0:
cpu_6800_sub(self, CPU_6800_EA_A, cpu_6800_read_byte(self, cpu_6800_ea_direct_indexed(self, self->regs.word.x)));
break;
case 0xa1:
- cpu_6800_cmp(self, self->regs.byte.a, cpu_6800_read_byte(self, cpu_6800_ea_direct_indexed(self, self->regs.word.x)));
+ cpu_6800_cmp_byte(self, self->regs.byte.a, cpu_6800_read_byte(self, cpu_6800_ea_direct_indexed(self, self->regs.word.x)));
break;
case 0xa2:
cpu_6800_sbc(self, CPU_6800_EA_A, cpu_6800_read_byte(self, cpu_6800_ea_direct_indexed(self, self->regs.word.x)));
break;
case 0xa3:
- cpu_6800_ill(self);
+ cpu_6800_illegal_opcode(self);
break;
case 0xa4:
cpu_6800_and(self, CPU_6800_EA_A, cpu_6800_read_byte(self, cpu_6800_ea_direct_indexed(self, self->regs.word.x)));
cpu_6800_bit(self, CPU_6800_EA_A, cpu_6800_read_byte(self, cpu_6800_ea_direct_indexed(self, self->regs.word.x)));
break;
case 0xa6:
- cpu_6800_lda(self, CPU_6800_EA_A, cpu_6800_read_byte(self, cpu_6800_ea_direct_indexed(self, self->regs.word.x)));
+ cpu_6800_ld_byte(self, CPU_6800_EA_A, cpu_6800_read_byte(self, cpu_6800_ea_direct_indexed(self, self->regs.word.x)));
break;
case 0xa7:
- cpu_6800_sta(self, self->regs.byte.a, cpu_6800_ea_direct_indexed(self, self->regs.word.x));
+ cpu_6800_st_byte(self, self->regs.byte.a, cpu_6800_ea_direct_indexed(self, self->regs.word.x));
break;
case 0xa8:
cpu_6800_eor(self, CPU_6800_EA_A, cpu_6800_read_byte(self, cpu_6800_ea_direct_indexed(self, self->regs.word.x)));
cpu_6800_add(self, CPU_6800_EA_A, cpu_6800_read_byte(self, cpu_6800_ea_direct_indexed(self, self->regs.word.x)));
break;
case 0xac:
- cpu_6800_cp(self, self->regs.word.x, cpu_6800_read_word(self, cpu_6800_ea_direct_indexed(self, self->regs.word.x)));
+ cpu_6800_cmp_word(self, self->regs.word.x, cpu_6800_read_word(self, cpu_6800_ea_direct_indexed(self, self->regs.word.x)));
break;
case 0xad:
cpu_6800_jsr(self, cpu_6800_ea_direct_indexed(self, self->regs.word.x));
break;
case 0xae:
- cpu_6800_ld(self, CPU_6800_EA_S, cpu_6800_read_word(self, cpu_6800_ea_direct_indexed(self, self->regs.word.x)));
+ cpu_6800_ld_word(self, CPU_6800_EA_S, cpu_6800_read_word(self, cpu_6800_ea_direct_indexed(self, self->regs.word.x)));
break;
case 0xaf:
- cpu_6800_st(self, self->regs.word.s, cpu_6800_ea_direct_indexed(self, self->regs.word.x));
+ cpu_6800_st_word(self, self->regs.word.s, cpu_6800_ea_direct_indexed(self, self->regs.word.x));
break;
case 0xb0:
cpu_6800_sub(self, CPU_6800_EA_A, cpu_6800_read_byte(self, cpu_6800_ea_extended(self)));
break;
case 0xb1:
- cpu_6800_cmp(self, self->regs.byte.a, cpu_6800_read_byte(self, cpu_6800_ea_extended(self)));
+ cpu_6800_cmp_byte(self, self->regs.byte.a, cpu_6800_read_byte(self, cpu_6800_ea_extended(self)));
break;
case 0xb2:
cpu_6800_sbc(self, CPU_6800_EA_A, cpu_6800_read_byte(self, cpu_6800_ea_extended(self)));
break;
case 0xb3:
- cpu_6800_ill(self);
+ cpu_6800_illegal_opcode(self);
break;
case 0xb4:
cpu_6800_and(self, CPU_6800_EA_A, cpu_6800_read_byte(self, cpu_6800_ea_extended(self)));
cpu_6800_bit(self, CPU_6800_EA_A, cpu_6800_read_byte(self, cpu_6800_ea_extended(self)));
break;
case 0xb6:
- cpu_6800_lda(self, CPU_6800_EA_A, cpu_6800_read_byte(self, cpu_6800_ea_extended(self)));
+ cpu_6800_ld_byte(self, CPU_6800_EA_A, cpu_6800_read_byte(self, cpu_6800_ea_extended(self)));
break;
case 0xb7:
- cpu_6800_sta(self, self->regs.byte.a, cpu_6800_ea_extended(self));
+ cpu_6800_st_byte(self, self->regs.byte.a, cpu_6800_ea_extended(self));
break;
case 0xb8:
cpu_6800_eor(self, CPU_6800_EA_A, cpu_6800_read_byte(self, cpu_6800_ea_extended(self)));
cpu_6800_add(self, CPU_6800_EA_A, cpu_6800_read_byte(self, cpu_6800_ea_extended(self)));
break;
case 0xbc:
- cpu_6800_cp(self, self->regs.word.x, cpu_6800_read_word(self, cpu_6800_ea_extended(self)));
+ cpu_6800_cmp_word(self, self->regs.word.x, cpu_6800_read_word(self, cpu_6800_ea_extended(self)));
break;
case 0xbd:
cpu_6800_jsr(self, cpu_6800_ea_extended(self));
break;
case 0xbe:
- cpu_6800_ld(self, CPU_6800_EA_S, cpu_6800_read_word(self, cpu_6800_ea_extended(self)));
+ cpu_6800_ld_word(self, CPU_6800_EA_S, cpu_6800_read_word(self, cpu_6800_ea_extended(self)));
break;
case 0xbf:
- cpu_6800_st(self, self->regs.word.s, cpu_6800_ea_extended(self));
+ cpu_6800_st_word(self, self->regs.word.s, cpu_6800_ea_extended(self));
break;
case 0xc0:
cpu_6800_sub(self, CPU_6800_EA_B, cpu_6800_fetch_byte(self));
break;
case 0xc1:
- cpu_6800_cmp(self, self->regs.byte.b, cpu_6800_fetch_byte(self));
+ cpu_6800_cmp_byte(self, self->regs.byte.b, cpu_6800_fetch_byte(self));
break;
case 0xc2:
cpu_6800_sbc(self, CPU_6800_EA_B, cpu_6800_fetch_byte(self));
break;
case 0xc3:
- cpu_6800_ill(self);
+ cpu_6800_illegal_opcode(self);
break;
case 0xc4:
cpu_6800_and(self, CPU_6800_EA_B, cpu_6800_fetch_byte(self));
cpu_6800_bit(self, CPU_6800_EA_B, cpu_6800_fetch_byte(self));
break;
case 0xc6:
- cpu_6800_lda(self, CPU_6800_EA_B, cpu_6800_fetch_byte(self));
+ cpu_6800_ld_byte(self, CPU_6800_EA_B, cpu_6800_fetch_byte(self));
break;
case 0xc7:
- cpu_6800_ill(self);
+ cpu_6800_illegal_opcode(self);
break;
case 0xc8:
cpu_6800_eor(self, CPU_6800_EA_B, cpu_6800_fetch_byte(self));
cpu_6800_add(self, CPU_6800_EA_B, cpu_6800_fetch_byte(self));
break;
case 0xcc:
- cpu_6800_ill(self);
+ cpu_6800_illegal_opcode(self);
break;
case 0xcd:
- cpu_6800_ill(self);
+ cpu_6800_illegal_opcode(self);
break;
case 0xce:
- cpu_6800_ld(self, CPU_6800_EA_X, cpu_6800_fetch_word(self));
+ cpu_6800_ld_word(self, CPU_6800_EA_X, cpu_6800_fetch_word(self));
break;
case 0xcf:
- cpu_6800_ill(self);
+ cpu_6800_illegal_opcode(self);
break;
case 0xd0:
cpu_6800_sub(self, CPU_6800_EA_B, cpu_6800_read_byte(self, cpu_6800_ea_direct(self)));
break;
case 0xd1:
- cpu_6800_cmp(self, self->regs.byte.b, cpu_6800_read_byte(self, cpu_6800_ea_direct(self)));
+ cpu_6800_cmp_byte(self, self->regs.byte.b, cpu_6800_read_byte(self, cpu_6800_ea_direct(self)));
break;
case 0xd2:
cpu_6800_sbc(self, CPU_6800_EA_B, cpu_6800_read_byte(self, cpu_6800_ea_direct(self)));
break;
case 0xd3:
- cpu_6800_ill(self);
+ cpu_6800_illegal_opcode(self);
break;
case 0xd4:
cpu_6800_and(self, CPU_6800_EA_B, cpu_6800_read_byte(self, cpu_6800_ea_direct(self)));
cpu_6800_bit(self, CPU_6800_EA_B, cpu_6800_read_byte(self, cpu_6800_ea_direct(self)));
break;
case 0xd6:
- cpu_6800_lda(self, CPU_6800_EA_B, cpu_6800_read_byte(self, cpu_6800_ea_direct(self)));
+ cpu_6800_ld_byte(self, CPU_6800_EA_B, cpu_6800_read_byte(self, cpu_6800_ea_direct(self)));
break;
case 0xd7:
- cpu_6800_sta(self, self->regs.byte.b, cpu_6800_ea_direct(self));
+ cpu_6800_st_byte(self, self->regs.byte.b, cpu_6800_ea_direct(self));
break;
case 0xd8:
cpu_6800_eor(self, CPU_6800_EA_B, cpu_6800_read_byte(self, cpu_6800_ea_direct(self)));
cpu_6800_add(self, CPU_6800_EA_B, cpu_6800_read_byte(self, cpu_6800_ea_direct(self)));
break;
case 0xdc:
- cpu_6800_ill(self);
+ cpu_6800_illegal_opcode(self);
break;
case 0xdd:
- cpu_6800_ill(self);
+ cpu_6800_illegal_opcode(self);
break;
case 0xde:
- cpu_6800_ld(self, CPU_6800_EA_X, cpu_6800_read_word(self, cpu_6800_ea_direct(self)));
+ cpu_6800_ld_word(self, CPU_6800_EA_X, cpu_6800_read_word(self, cpu_6800_ea_direct(self)));
break;
case 0xdf:
- cpu_6800_st(self, self->regs.word.x, cpu_6800_ea_direct(self));
+ cpu_6800_st_word(self, self->regs.word.x, cpu_6800_ea_direct(self));
break;
case 0xe0:
cpu_6800_sub(self, CPU_6800_EA_B, cpu_6800_read_byte(self, cpu_6800_ea_direct_indexed(self, self->regs.word.x)));
break;
case 0xe1:
- cpu_6800_cmp(self, self->regs.byte.b, cpu_6800_read_byte(self, cpu_6800_ea_direct_indexed(self, self->regs.word.x)));
+ cpu_6800_cmp_byte(self, self->regs.byte.b, cpu_6800_read_byte(self, cpu_6800_ea_direct_indexed(self, self->regs.word.x)));
break;
case 0xe2:
cpu_6800_sbc(self, CPU_6800_EA_B, cpu_6800_read_byte(self, cpu_6800_ea_direct_indexed(self, self->regs.word.x)));
break;
case 0xe3:
- cpu_6800_ill(self);
+ cpu_6800_illegal_opcode(self);
break;
case 0xe4:
cpu_6800_and(self, CPU_6800_EA_B, cpu_6800_read_byte(self, cpu_6800_ea_direct_indexed(self, self->regs.word.x)));
cpu_6800_bit(self, CPU_6800_EA_B, cpu_6800_read_byte(self, cpu_6800_ea_direct_indexed(self, self->regs.word.x)));
break;
case 0xe6:
- cpu_6800_lda(self, CPU_6800_EA_B, cpu_6800_read_byte(self, cpu_6800_ea_direct_indexed(self, self->regs.word.x)));
+ cpu_6800_ld_byte(self, CPU_6800_EA_B, cpu_6800_read_byte(self, cpu_6800_ea_direct_indexed(self, self->regs.word.x)));
break;
case 0xe7:
- cpu_6800_sta(self, self->regs.byte.b, cpu_6800_ea_direct_indexed(self, self->regs.word.x));
+ cpu_6800_st_byte(self, self->regs.byte.b, cpu_6800_ea_direct_indexed(self, self->regs.word.x));
break;
case 0xe8:
cpu_6800_eor(self, CPU_6800_EA_B, cpu_6800_read_byte(self, cpu_6800_ea_direct_indexed(self, self->regs.word.x)));
cpu_6800_add(self, CPU_6800_EA_B, cpu_6800_read_byte(self, cpu_6800_ea_direct_indexed(self, self->regs.word.x)));
break;
case 0xec:
- cpu_6800_ill(self);
+ cpu_6800_illegal_opcode(self);
break;
case 0xed:
- cpu_6800_ill(self);
+ cpu_6800_illegal_opcode(self);
break;
case 0xee:
- cpu_6800_ld(self, CPU_6800_EA_X, cpu_6800_read_word(self, cpu_6800_ea_direct_indexed(self, self->regs.word.x)));
+ cpu_6800_ld_word(self, CPU_6800_EA_X, cpu_6800_read_word(self, cpu_6800_ea_direct_indexed(self, self->regs.word.x)));
break;
case 0xef:
- cpu_6800_st(self, self->regs.word.x, cpu_6800_ea_direct_indexed(self, self->regs.word.x));
+ cpu_6800_st_word(self, self->regs.word.x, cpu_6800_ea_direct_indexed(self, self->regs.word.x));
break;
case 0xf0:
cpu_6800_sub(self, CPU_6800_EA_B, cpu_6800_read_byte(self, cpu_6800_ea_extended(self)));
break;
case 0xf1:
- cpu_6800_cmp(self, self->regs.byte.b, cpu_6800_read_byte(self, cpu_6800_ea_extended(self)));
+ cpu_6800_cmp_byte(self, self->regs.byte.b, cpu_6800_read_byte(self, cpu_6800_ea_extended(self)));
break;
case 0xf2:
cpu_6800_sbc(self, CPU_6800_EA_B, cpu_6800_read_byte(self, cpu_6800_ea_extended(self)));
break;
case 0xf3:
- cpu_6800_ill(self);
+ cpu_6800_illegal_opcode(self);
break;
case 0xf4:
cpu_6800_and(self, CPU_6800_EA_B, cpu_6800_read_byte(self, cpu_6800_ea_extended(self)));
cpu_6800_bit(self, CPU_6800_EA_B, cpu_6800_read_byte(self, cpu_6800_ea_extended(self)));
break;
case 0xf6:
- cpu_6800_lda(self, CPU_6800_EA_B, cpu_6800_read_byte(self, cpu_6800_ea_extended(self)));
+ cpu_6800_ld_byte(self, CPU_6800_EA_B, cpu_6800_read_byte(self, cpu_6800_ea_extended(self)));
break;
case 0xf7:
- cpu_6800_sta(self, self->regs.byte.b, cpu_6800_ea_extended(self));
+ cpu_6800_st_byte(self, self->regs.byte.b, cpu_6800_ea_extended(self));
break;
case 0xf8:
cpu_6800_eor(self, CPU_6800_EA_B, cpu_6800_read_byte(self, cpu_6800_ea_extended(self)));
cpu_6800_add(self, CPU_6800_EA_B, cpu_6800_read_byte(self, cpu_6800_ea_extended(self)));
break;
case 0xfc:
- cpu_6800_ill(self);
+ cpu_6800_illegal_opcode(self);
break;
case 0xfd:
- cpu_6800_ill(self);
+ cpu_6800_illegal_opcode(self);
break;
case 0xfe:
- cpu_6800_ld(self, CPU_6800_EA_X, cpu_6800_read_word(self, cpu_6800_ea_extended(self)));
+ cpu_6800_ld_word(self, CPU_6800_EA_X, cpu_6800_read_word(self, cpu_6800_ea_extended(self)));
break;
case 0xff:
- cpu_6800_st(self, self->regs.word.x, cpu_6800_ea_extended(self));
+ cpu_6800_st_word(self, self->regs.word.x, cpu_6800_ea_extended(self));
break;
}
}
import sys
-# if first argument is embedded in opcode, it is rvalue for these
-acc_rvalue_opcodes = {
- 'cmp',
- 'psh',
- 'sta',
- 'tst',
+# end-relative range of operands that are rvalues
+rvalue_opcodes = {
+ 'add': (-1, 0),
+ 'adc': (-1, 0),
+ 'and': (-1, 0),
+ 'bit': (-1, 0),
+ 'cmp': (-2, 0),
+ 'cmp_byte': (-2, 0),
+ 'eor': (-1, 0),
+ 'ld': (-1, 0),
+ 'ora': (-1, 0),
+ 'psh': (-1, 0),
+ 'sub': (-1, 0),
+ 'sbc': (-1, 0),
+ 'st': (-2, -1),
}
-rvalue_opcodes = {
+# if it is in byte_opcodes it is treated as byte and has no suffix
+byte_opcodes = {
'add',
'adc',
'and',
+ 'asl',
+ 'asr',
'bit',
- 'cmp',
- 'cpx',
+ 'cl',
+ 'clr',
+ 'cmp_byte',
+ 'com',
+ 'dec_byte',
'eor',
- 'lda',
- 'ldx',
- 'lds',
+ 'inc_byte',
+ 'lsr',
+ 'neg',
'ora',
+ 'pul',
+ 'psh',
+ 'rol',
+ 'ror',
'sub',
'sbc',
- 'tst',
+ 'se',
}
-rvalue_modes = {
+# if any operand is in byte_operands it is treated as byte and has suffix
+# in this case it is mandatory that no operand also be in word_operands
+byte_operands = {
+ '#12',
+ 'a',
+ 'b',
+}
+byte_rvalue_modes = {
'#12': 'cpu_6800_fetch_byte(self)',
- '#1234': 'cpu_6800_fetch_word(self)',
- '12': 'cpu_6800_read_byte(self, cpu_6800_ea_direct(self))',
- '12,x': 'cpu_6800_read_byte(self, cpu_6800_ea_direct_indexed(self, self->regs.word.x))',
- '1234': 'cpu_6800_read_byte(self, cpu_6800_ea_extended(self))',
- '1234,x': 'cpu_6800_read_byte(self, cpu_6800_ea_extended_indexed(self, self->regs.word.x))',
'a': 'self->regs.byte.a',
'b': 'self->regs.byte.b',
}
-lvalue_modes = {
- '0014': 'cpu_6800_ea_relative(self)',
+byte_lvalue_modes = {
'12': 'cpu_6800_ea_direct(self)',
'12,x': 'cpu_6800_ea_direct_indexed(self, self->regs.word.x)',
'1234': 'cpu_6800_ea_extended(self)',
'1234,x': 'cpu_6800_ea_extended_indexed(self, self->regs.word.x)',
'a': 'CPU_6800_EA_A',
'b': 'CPU_6800_EA_B',
+ 'c': 'CPU_6800_REG_P_BIT_C',
+ 'i': 'CPU_6800_REG_P_BIT_I',
+ 'v': 'CPU_6800_REG_P_BIT_V',
}
+# if it is in word_opcodes it is treated as word and has no suffix
+# in this case the operands "c" and "(hl)" do not imply a byte opcode
+word_opcodes = {
+ 'bra',
+ 'bsr',
+ 'dec_word_zf',
+ 'inc_word_zf',
+ 'jmp',
+ 'jsr',
+}
+# if any operand is in word_operands it is treated as word and has suffix
+# in this case it is mandatory that no operand also be in byte_operands
+word_operands = {
+ '#1234',
+ 's',
+ 'x',
+}
+word_rvalue_modes = {
+ '#1234': 'cpu_6800_fetch_word(self)',
+ 's': 'self->regs.word.s',
+ 'x': 'self->regs.word.x',
+}
+word_lvalue_modes = {
+ 'ne': '!self->regs.bit.zf',
+ 'eq': 'self->regs.bit.zf',
+ 'cc': '!self->regs.bit.cf',
+ 'cs': 'self->regs.bit.cf',
+ 'vc': '!self->regs.bit.vf',
+ 'vs': 'self->regs.bit.vf',
+ 'pl': '!self->regs.bit.nf',
+ 'mi': 'self->regs.bit.nf',
+ 'ge': '!self->regs.bit.nf && !self->regs.bit.vf',
+ 'gt': '!self->regs.bit.nf && !self->regs.bit.vf && !self->regs.bit.zf',
+ 'hi': '!self->regs.bit.cf && !self->regs.bit.zf',
+ 'le': 'self->regs.bit.nf || self->regs.bit.vf || self->regs.bit.zf',
+ 'ls': 'self->regs.bit.cf || self->regs.bit.zf',
+ 'lt': 'self->regs.bit.nf || self->regs.bit.vf',
+ '0014': 'cpu_6800_ea_relative(self)',
+ '12': 'cpu_6800_ea_direct(self)',
+ '12,x': 'cpu_6800_ea_direct_indexed(self, self->regs.word.x)',
+ '1234': 'cpu_6800_ea_extended(self)',
+ '1234,x': 'cpu_6800_ea_extended_indexed(self, self->regs.word.x)',
+ 's': 'CPU_6800_EA_S',
+ 'x': 'CPU_6800_EA_X',
+}
+
+line = sys.stdin.readline().strip()
+assert line == 'opcodes'
+
print('void cpu_6800_execute(struct cpu_6800 *self) {')
print(' switch (cpu_6800_fetch_byte(self)) {')
+
for i in range(0x100):
+ line = sys.stdin.readline().strip()
+
print(f' case 0x{i:02x}:')
- instr = sys.stdin.readline().strip().split('\t')[-1].split()
- if instr[0] == '---':
- instr[0] = 'ill' # illegal opcode
- #print('xxx', instr)
- if len(instr) >= 2:
- if instr[0][:3] in rvalue_opcodes:
- instr[1] = rvalue_modes[instr[1]]
- else:
- instr[1] = lvalue_modes[instr[1]]
- if len(instr[0]) >= 4:
- # move accumulator a/b from opcode to first argument
- if instr[0][:3] in acc_rvalue_opcodes:
- instr[:1] = [instr[0][:3], rvalue_modes[instr[0][3:]]]
- else:
- instr[:1] = [instr[0][:3], lvalue_modes[instr[0][3:]]]
+ instr = line.split()
+
+ # detect operation size (byte or word)
+ suffix = ''
+ if instr[0] not in byte_opcodes and instr[0] not in word_opcodes:
+ for j in instr[1:]:
+ if j in byte_operands:
+ assert suffix != '_word'
+ suffix = '_byte'
+ elif j in word_operands:
+ assert suffix != '_byte'
+ suffix = '_word'
+
+ # work out which operands are rvalue
+ j0, j1 = rvalue_opcodes.get(instr[0], (0, 0))
+ j0 += len(instr)
+ j1 += len(instr)
+
+ # translate operands
+ if suffix == '_byte' or instr[0] in byte_opcodes:
+ for k in range(1, len(instr)):
+ if k >= j0 and k < j1:
+ if instr[k] in byte_rvalue_modes:
+ instr[k] = byte_rvalue_modes[instr[k]]
+ elif instr[k] in byte_lvalue_modes:
+ instr[k] = 'cpu_6800_read_byte(self, {0:s})'.format(
+ byte_lvalue_modes[instr[k]]
+ )
+ elif instr[k] in byte_lvalue_modes:
+ instr[k] = byte_lvalue_modes[instr[k]]
+ elif suffix == '_word' or instr[0] in word_opcodes:
+ for k in range(1, len(instr)):
+ if k >= j0 and k < j1:
+ if instr[k] in word_rvalue_modes:
+ instr[k] = word_rvalue_modes[instr[k]]
+ elif instr[k] in word_lvalue_modes:
+ instr[k] = 'cpu_6800_read_word(self, {0:s})'.format(
+ word_lvalue_modes[instr[k]]
+ )
+ elif instr[k] in word_lvalue_modes:
+ instr[k] = word_lvalue_modes[instr[k]]
+
print(
- ' cpu_6800_{0:s}(self{1:s});'.format(
+ ' cpu_6800_{0:s}{1:s}(self{2:s});'.format(
instr[0],
- ''.join([', ' + j for j in instr[1:]])
+ suffix,
+ ''.join([', ' + k for k in instr[1:]])
)
)
print(' break;')
+
+line = sys.stdin.readline().strip()
+assert len(line) == 0
+
print(' }')
print('}')
+print()