1
0
mirror of https://github.com/jscrane/r65emu.git synced 2024-07-18 15:28:54 +00:00

use switch/case instead of array of fps

This commit is contained in:
Stephen Crane 2019-02-25 08:07:41 +00:00
parent 448c702237
commit 31ab9e59c9
2 changed files with 245 additions and 260 deletions

163
r6502.cpp
View File

@ -9,7 +9,7 @@ void r6502::run(unsigned clocks) {
while (clocks--) {
uint8_t op = _mem[PC];
PC++;
(this->*_ops[op])();
_op(op);
if (_halted)
break;
}
@ -106,17 +106,6 @@ void r6502::brk() {
P.bits._ = 1;
}
void r6502::rti() {
plp();
PC = popa();
}
void r6502::cli() {
P.bits.I = 0;
if (_irq)
irq();
}
void r6502::nmi() {
pusha(PC);
php();
@ -139,15 +128,6 @@ void r6502::plp() {
C = P.bits.C;
}
void r6502::rts() {
PC = popa()+1;
}
void r6502::jsr() {
pusha(PC+1);
PC = vector(PC);
}
static inline uint8_t fromBCD(uint8_t i) {
return ((i >> 4) & 0x0f)*10 + (i & 0x0f);
}
@ -183,11 +163,6 @@ void r6502::sbcd(uint8_t d) {
// V not tested for: http://www.6502.org/tutorials/decimal_mode.html
}
void r6502::ill() {
--PC;
_halted = true;
}
void r6502::reset()
{
_halted = false;
@ -199,72 +174,74 @@ void r6502::reset()
PC = vector(resvec);
}
r6502::r6502(Memory &m): CPU(m) {
void r6502::_op(uint8_t op) {
#define O(o, e) case o: e; break;
OP *p = _ops;
*p++=&r6502::brk; *p++=&r6502::ora_ix; *p++=&r6502::ill; *p++=&r6502::ill;
*p++=&r6502::nop2; *p++=&r6502::ora_z; *p++=&r6502::asl_z; *p++=&r6502::ill;
*p++=&r6502::php; *p++=&r6502::ora_; *p++=&r6502::asl; *p++=&r6502::ill;
*p++=&r6502::nop3; *p++=&r6502::ora_a; *p++=&r6502::asl_a; *p++=&r6502::ill;
*p++=&r6502::bpl; *p++=&r6502::ora_iy; *p++=&r6502::ill; *p++=&r6502::ill;
*p++=&r6502::nop2; *p++=&r6502::ora_zx; *p++=&r6502::asl_zx; *p++=&r6502::ill;
*p++=&r6502::clc; *p++=&r6502::ora_ay; *p++=&r6502::nop; *p++=&r6502::ill;
*p++=&r6502::nop2; *p++=&r6502::ora_ax; *p++=&r6502::asl_ax; *p++=&r6502::ill;
*p++=&r6502::jsr; *p++=&r6502::and_ix; *p++=&r6502::ill; *p++=&r6502::ill;
*p++=&r6502::bit_z; *p++=&r6502::and_z; *p++=&r6502::rol_z; *p++=&r6502::ill;
*p++=&r6502::plp; *p++=&r6502::and_; *p++=&r6502::rol; *p++=&r6502::ill;
*p++=&r6502::bit_a; *p++=&r6502::and_a; *p++=&r6502::rol_a; *p++=&r6502::ill;
*p++=&r6502::bmi; *p++=&r6502::and_iy; *p++=&r6502::ill; *p++=&r6502::ill;
*p++=&r6502::nop2; *p++=&r6502::and_zx; *p++=&r6502::rol_zx; *p++=&r6502::ill;
*p++=&r6502::sec; *p++=&r6502::and_ay; *p++=&r6502::nop; *p++=&r6502::ill;
*p++=&r6502::nop3; *p++=&r6502::and_ax; *p++=&r6502::rol_ax; *p++=&r6502::ill;
*p++=&r6502::rti; *p++=&r6502::eor_ix; *p++=&r6502::ill; *p++=&r6502::ill;
*p++=&r6502::nop2; *p++=&r6502::eor_z; *p++=&r6502::lsr_z; *p++=&r6502::ill;
*p++=&r6502::pha; *p++=&r6502::eor_; *p++=&r6502::lsr_; *p++=&r6502::ill;
*p++=&r6502::jmp; *p++=&r6502::eor_a; *p++=&r6502::lsr_a; *p++=&r6502::ill;
*p++=&r6502::bvc; *p++=&r6502::eor_iy; *p++=&r6502::ill; *p++=&r6502::ill;
*p++=&r6502::nop2; *p++=&r6502::eor_zx; *p++=&r6502::lsr_zx; *p++=&r6502::ill;
*p++=&r6502::cli; *p++=&r6502::eor_ay; *p++=&r6502::nop; *p++=&r6502::ill;
*p++=&r6502::nop3; *p++=&r6502::eor_ax; *p++=&r6502::lsr_ax; *p++=&r6502::ill;
*p++=&r6502::rts; *p++=&r6502::adc_ix; *p++=&r6502::ill; *p++=&r6502::ill;
*p++=&r6502::nop2; *p++=&r6502::adc_z; *p++=&r6502::ror_z; *p++=&r6502::ill;
*p++=&r6502::pla; *p++=&r6502::adc_; *p++=&r6502::ror_; *p++=&r6502::ill;
*p++=&r6502::jmp_i; *p++=&r6502::adc_a; *p++=&r6502::ror_a; *p++=&r6502::ill;
*p++=&r6502::bvs; *p++=&r6502::adc_iy; *p++=&r6502::ill; *p++=&r6502::ill;
*p++=&r6502::nop2; *p++=&r6502::adc_zx; *p++=&r6502::ror_zx; *p++=&r6502::ill;
*p++=&r6502::sei; *p++=&r6502::adc_ay; *p++=&r6502::nop; *p++=&r6502::ill;
*p++=&r6502::nop3; *p++=&r6502::adc_ax; *p++=&r6502::ror_ax; *p++=&r6502::ill;
*p++=&r6502::nop2; *p++=&r6502::sta_ix; *p++=&r6502::nop2; *p++=&r6502::ill;
*p++=&r6502::sty_z; *p++=&r6502::sta_z; *p++=&r6502::stx_z; *p++=&r6502::ill;
*p++=&r6502::dey; *p++=&r6502::nop2; *p++=&r6502::txa; *p++=&r6502::ill;
*p++=&r6502::sty_a; *p++=&r6502::sta_a; *p++=&r6502::stx_a; *p++=&r6502::ill;
*p++=&r6502::bcc; *p++=&r6502::sta_iy; *p++=&r6502::ill; *p++=&r6502::ill;
*p++=&r6502::sty_zx; *p++=&r6502::sta_zx; *p++=&r6502::stx_zy; *p++=&r6502::ill;
*p++=&r6502::tya; *p++=&r6502::sta_ay; *p++=&r6502::txs; *p++=&r6502::ill;
*p++=&r6502::ill; *p++=&r6502::sta_ax; *p++=&r6502::ill; *p++=&r6502::ill;
*p++=&r6502::ldy_; *p++=&r6502::lda_ix; *p++=&r6502::ldx_; *p++=&r6502::lax_ix;
*p++=&r6502::ldy_z; *p++=&r6502::lda_z; *p++=&r6502::ldx_z; *p++=&r6502::lax_z;
*p++=&r6502::tay; *p++=&r6502::lda_; *p++=&r6502::tax; *p++=&r6502::ill;
*p++=&r6502::ldy_a; *p++=&r6502::lda_a; *p++=&r6502::ldx_a; *p++=&r6502::lax_a;
*p++=&r6502::bcs; *p++=&r6502::lda_iy; *p++=&r6502::ill; *p++=&r6502::lax_iy;
*p++=&r6502::ldy_zx; *p++=&r6502::lda_zx; *p++=&r6502::ldx_zy; *p++=&r6502::lax_zy;
*p++=&r6502::clv; *p++=&r6502::lda_ay; *p++=&r6502::tsx; *p++=&r6502::ill;
*p++=&r6502::ldy_ax; *p++=&r6502::lda_ax; *p++=&r6502::ldx_ay; *p++=&r6502::lax_ay;
*p++=&r6502::cpy_; *p++=&r6502::cmp_ix; *p++=&r6502::nop2; *p++=&r6502::ill;
*p++=&r6502::cpy_z; *p++=&r6502::cmp_z; *p++=&r6502::dec_z; *p++=&r6502::ill;
*p++=&r6502::iny; *p++=&r6502::cmp_; *p++=&r6502::dex; *p++=&r6502::ill;
*p++=&r6502::cpy_a; *p++=&r6502::cmp_a; *p++=&r6502::dec_a; *p++=&r6502::ill;
*p++=&r6502::bne; *p++=&r6502::cmp_iy; *p++=&r6502::ill; *p++=&r6502::ill;
*p++=&r6502::nop2; *p++=&r6502::cmp_zx; *p++=&r6502::dec_zx; *p++=&r6502::ill;
*p++=&r6502::cld; *p++=&r6502::cmp_ay; *p++=&r6502::nop; *p++=&r6502::ill;
*p++=&r6502::nop3; *p++=&r6502::cmp_ax; *p++=&r6502::dec_ax; *p++=&r6502::ill;
*p++=&r6502::cpx_; *p++=&r6502::sbc_ix; *p++=&r6502::nop2; *p++=&r6502::ill;
*p++=&r6502::cpx_z; *p++=&r6502::sbc_z; *p++=&r6502::inc_z; *p++=&r6502::ill;
*p++=&r6502::inx; *p++=&r6502::sbc_; *p++=&r6502::nop; *p++=&r6502::ill;
*p++=&r6502::cpx_a; *p++=&r6502::sbc_a; *p++=&r6502::inc_a; *p++=&r6502::ill;
*p++=&r6502::beq; *p++=&r6502::sbc_iy; *p++=&r6502::ill; *p++=&r6502::ill;
*p++=&r6502::nop2; *p++=&r6502::sbc_zx; *p++=&r6502::inc_zx; *p++=&r6502::ill;
*p++=&r6502::sed; *p++=&r6502::sbc_ay; *p++=&r6502::nop; *p++=&r6502::ill;
*p++=&r6502::nop3; *p++=&r6502::sbc_ax; *p++=&r6502::inc_ax; *p++=&r6502::ill;
switch (op) {
O(0x00, brk()); O(0x01, ora_ix());
O(0x04, nop2()); O(0x05, ora_z()); O(0x06, asl_z());
O(0x08, php()); O(0x09, ora_()); O(0x0a, asl());
O(0x0c, nop3()); O(0x0d, ora_a()); O(0x0e, asl_a());
O(0x10, bpl()); O(0x11, ora_iy());
O(0x14, nop2()); O(0x15, ora_zx()); O(0x16, asl_zx());
O(0x18, clc()); O(0x19, ora_ay()); O(0x1a, nop());
O(0x1c, nop2()); O(0x1d, ora_ax()); O(0x1e, asl_ax());
O(0x20, jsr()); O(0x21, and_ix());
O(0x24, bit_z()); O(0x25, and_z()); O(0x26, rol_z());
O(0x28, plp()); O(0x29, and_()); O(0x2a, rol());
O(0x2c, bit_a()); O(0x2d, and_a()); O(0x2e, rol_a());
O(0x30, bmi()); O(0x31, and_iy());
O(0x34, nop2()); O(0x35, and_zx()); O(0x36, rol_zx());
O(0x38, sec()); O(0x39, and_ay()); O(0x3a, nop());
O(0x3c, nop3()); O(0x3d, and_ax()); O(0x3e, rol_ax());
O(0x40, rti()); O(0x41, eor_ix());
O(0x44, nop2()); O(0x45, eor_z()); O(0x46, lsr_z());
O(0x48, pha()); O(0x49, eor_()); O(0x4a, lsr_());
O(0x4c, jmp()); O(0x4d, eor_a()); O(0x4e, lsr_a());
O(0x50, bvc()); O(0x51, eor_iy());
O(0x54, nop2()); O(0x55, eor_zx()); O(0x56, lsr_zx());
O(0x58, cli()); O(0x59, eor_ay()); O(0x5a, nop());
O(0x5c, nop3()); O(0x5d, eor_ax()); O(0x5e, lsr_ax());
O(0x60, rts()); O(0x61, adc_ix());
O(0x64, nop2()); O(0x65, adc_z()); O(0x66, ror_z());
O(0x68, pla()); O(0x69, adc_()); O(0x6a, ror_());
O(0x6c, jmp_i()); O(0x6d, adc_a()); O(0x6e, ror_a());
O(0x70, bvs()); O(0x71, adc_iy());
O(0x74, nop2()); O(0x75, adc_zx()); O(0x76, ror_zx());
O(0x78, sei()); O(0x79, adc_ay()); O(0x7a, nop());
O(0x7c, nop3()); O(0x7d, adc_ax()); O(0x7e, ror_ax());
O(0x80, nop2()); O(0x81, sta_ix()); O(0x82, nop2());
O(0x84, sty_z()); O(0x85, sta_z()); O(0x86, stx_z());
O(0x88, dey()); O(0x89, nop2()); O(0x8a, txa());
O(0x8c, sty_a()); O(0x8d, sta_a()); O(0x8e, stx_a());
O(0x90, bcc()); O(0x91, sta_iy());
O(0x94, sty_zx()); O(0x95, sta_zx()); O(0x96, stx_zy());
O(0x98, tya()); O(0x99, sta_ay()); O(0x9a, txs());
O(0x9d, sta_ax());
O(0xa0, ldy_()); O(0xa1, lda_ix()); O(0xa2, ldx_()); O(0xa3, lax_ix());
O(0xa4, ldy_z()); O(0xa5, lda_z()); O(0xa6, ldx_z()); O(0xa7, lax_z());
O(0xa8, tay()); O(0xa9, lda_()); O(0xaa, tax());
O(0xac, ldy_a()); O(0xad, lda_a()); O(0xae, ldx_a()); O(0xaf, lax_a());
O(0xb0, bcs()); O(0xb1, lda_iy()); O(0xb3, lax_iy());
O(0xb4, ldy_zx()); O(0xb5, lda_zx()); O(0xb6, ldx_zy()); O(0xb7, lax_zy());
O(0xb8, clv()); O(0xb9, lda_ay()); O(0xba, tsx());
O(0xbc, ldy_ax()); O(0xbd, lda_ax()); O(0xbe, ldx_ay()); O(0xbf, lax_ay());
O(0xc0, cpy_()); O(0xc1, cmp_ix()); O(0xc2, nop2());
O(0xc4, cpy_z()); O(0xc5, cmp_z()); O(0xc6, dec_z());
O(0xc8, iny()); O(0xc9, cmp_()); O(0xca, dex());
O(0xcc, cpy_a()); O(0xcd, cmp_a()); O(0xce, dec_a());
O(0xd0, bne()); O(0xd1, cmp_iy());
O(0xd4, nop2()); O(0xd5, cmp_zx()); O(0xd6, dec_zx());
O(0xd8, cld()); O(0xd9, cmp_ay()); O(0xda, nop());
O(0xdc, nop3()); O(0xdd, cmp_ax()); O(0xde, dec_ax());
O(0xe0, cpx_()); O(0xe1, sbc_ix()); O(0xe2, nop2());
O(0xe4, cpx_z()); O(0xe5, sbc_z()); O(0xe6, inc_z());
O(0xe8, inx()); O(0xe9, sbc_()); O(0xea, nop());
O(0xec, cpx_a()); O(0xed, sbc_a()); O(0xee, inc_a());
O(0xf0, beq()); O(0xf1, sbc_iy());
O(0xf4, nop2()); O(0xf5, sbc_zx()); O(0xf6, inc_zx());
O(0xf8, sed()); O(0xf9, sbc_ay()); O(0xfa, nop());
O(0xfc, nop3()); O(0xfd, sbc_ax()); O(0xfe, inc_ax());
default: ill();
}
}

342
r6502.h
View File

@ -15,7 +15,8 @@ public:
void checkpoint(Stream &);
void restore(Stream &);
r6502(Memory &);
r6502(Memory &m): CPU(m) {}
private:
/* registers */
uint8_t S, A, X, Y;
@ -94,7 +95,9 @@ private:
inline Memory::address _iy() { return _i(_mem[PC++])+Y; }
void _adc(uint8_t a);
void _sbc(uint8_t a) { if (P.bits.D) sbcd(a); else _adc(~a); }
void _sbc(uint8_t a) {
if (P.bits.D) sbcd(a); else _adc(~a);
}
void sbcd(uint8_t a);
inline uint8_t __ror(uint8_t b) {
@ -109,11 +112,15 @@ private:
inline void _rol(Memory::address a) {
_mem[a] = __rol(_mem[a]);
}
inline uint8_t __asl(uint8_t b) { C=(b&0x80)!=0; return Z=N=b<<1; }
inline uint8_t __asl(uint8_t b) {
C=(b&0x80)!=0; return Z=N=b<<1;
}
inline void _asl(Memory::address a) {
_mem[a] = __asl(_mem[a]);
}
inline uint8_t __lsr(uint8_t b) { C=b&1; Z=b>>1; N=0; return Z; }
inline uint8_t __lsr(uint8_t b) {
C=b&1; Z=b>>1; N=0; return Z;
}
inline void _lsr(Memory::address a) {
_mem[a] = __lsr(_mem[a]);
}
@ -123,191 +130,192 @@ private:
inline void _dec(Memory::address a) {
Z=N=_mem[a]-1; _mem[a]=Z;
}
inline void _bit(uint8_t z) { V=((z & 0x40)!=0); N=(z & 0x80); Z=(A & z); }
inline void _bit(uint8_t z) {
V=((z & 0x40)!=0); N=(z & 0x80); Z=(A & z);
}
inline void _bra() {
uint8_t b = _mem[PC];
PC += b;
if (b > 127) PC -= 0x0100;
}
/* dispatch table */
typedef void (r6502::*OP)(); OP _ops[256];
void _op(uint8_t);
/* operations */
void brk();
void ora_ix() { _ora(_mem[_ix()]); }
void ill();
void nop2() { PC++; }
void ora_z() { _ora(_mem[_z()]); }
void asl_z() { _asl(_z()); }
void php();
void ora_() { _ora(_mem[PC++]); }
void asl() { C=(A&0x80)!=0; Z=N=A<<=1; }
void nop3() { PC+=2; }
void ora_a() { _ora(_mem[_a()]); }
void asl_a() { _asl(_a()); }
inline void brk();
inline void ora_ix() { _ora(_mem[_ix()]); }
inline void ill() { --PC; _halted = true; }
inline void nop2() { PC++; }
inline void ora_z() { _ora(_mem[_z()]); }
inline void asl_z() { _asl(_z()); }
inline void php();
inline void ora_() { _ora(_mem[PC++]); }
inline void asl() { C=(A&0x80)!=0; Z=N=A<<=1; }
inline void nop3() { PC+=2; }
inline void ora_a() { _ora(_mem[_a()]); }
inline void asl_a() { _asl(_a()); }
// 10
void bpl() { if (!(N & 0x80)) _bra(); PC++; }
void ora_iy() { _ora(_mem[_iy()]); }
void ora_zx() { _ora(_mem[_zx()]); }
void asl_zx() { _asl(_zx()); }
void clc() { C=0; }
void ora_ay() { _ora(_mem[_ay()]); }
void nop() {}
void ora_ax() { _ora(_mem[_ax()]); }
void asl_ax() { _asl(_ax()); }
inline void bpl() { if (!(N & 0x80)) _bra(); PC++; }
inline void ora_iy() { _ora(_mem[_iy()]); }
inline void ora_zx() { _ora(_mem[_zx()]); }
inline void asl_zx() { _asl(_zx()); }
inline void clc() { C=0; }
inline void ora_ay() { _ora(_mem[_ay()]); }
inline void nop() {}
inline void ora_ax() { _ora(_mem[_ax()]); }
inline void asl_ax() { _asl(_ax()); }
// 20
void jsr();
void and_ix() { _and(_mem[_ix()]); }
void bit_z() { _bit(_mem[_z()]); }
void and_z() { _and(_mem[_z()]); }
void rol_z() { _rol(_z()); }
void plp();
void and_() { _and(_mem[PC++]); }
void rol() { A=__rol(A); }
void bit_a() { _bit(_mem[_a()]); }
void and_a() { _and(_mem[_a()]); }
void rol_a() { _rol(_a()); }
inline void jsr() { pusha(PC+1); PC = vector(PC); }
inline void and_ix() { _and(_mem[_ix()]); }
inline void bit_z() { _bit(_mem[_z()]); }
inline void and_z() { _and(_mem[_z()]); }
inline void rol_z() { _rol(_z()); }
inline void plp();
inline void and_() { _and(_mem[PC++]); }
inline void rol() { A=__rol(A); }
inline void bit_a() { _bit(_mem[_a()]); }
inline void and_a() { _and(_mem[_a()]); }
inline void rol_a() { _rol(_a()); }
// 30
void bmi() { if (N & 0x80) _bra(); PC++; }
void and_iy() { _and(_mem[_iy()]); }
void and_zx() { _and(_mem[_zx()]); }
void rol_zx() { _rol(_zx()); }
void sec() { C=1; }
void and_ay() { _and(_mem[_ay()]); }
void and_ax() { _and(_mem[_ax()]); }
void rol_ax() { _rol(_ax()); }
inline void bmi() { if (N & 0x80) _bra(); PC++; }
inline void and_iy() { _and(_mem[_iy()]); }
inline void and_zx() { _and(_mem[_zx()]); }
inline void rol_zx() { _rol(_zx()); }
inline void sec() { C=1; }
inline void and_ay() { _and(_mem[_ay()]); }
inline void and_ax() { _and(_mem[_ax()]); }
inline void rol_ax() { _rol(_ax()); }
// 40
void rti();
void eor_ix() { _eor(_mem[_ix()]); }
void eor_z() { _eor(_mem[_z()]); }
void lsr_z() { _lsr(_z()); }
void pha() { pushb(A); }
void eor_() { _eor(_mem[PC++]); }
void lsr_() { A=__lsr(A); }
void jmp() { PC = _a(); }
void eor_a() { _eor(_mem[_a()]); }
void lsr_a() { _lsr(_a()); }
inline void rti() { plp(); PC = popa(); }
inline void eor_ix() { _eor(_mem[_ix()]); }
inline void eor_z() { _eor(_mem[_z()]); }
inline void lsr_z() { _lsr(_z()); }
inline void pha() { pushb(A); }
inline void eor_() { _eor(_mem[PC++]); }
inline void lsr_() { A=__lsr(A); }
inline void jmp() { PC = _a(); }
inline void eor_a() { _eor(_mem[_a()]); }
inline void lsr_a() { _lsr(_a()); }
// 50
void bvc() { if (!V) _bra(); PC++; }
void eor_iy() { _eor(_mem[_iy()]); }
void eor_zx() { _eor(_mem[_zx()]); }
void lsr_zx() { _lsr(_zx()); }
void cli();
void eor_ay() { _eor(_mem[_ay()]); }
void eor_ax() { _eor(_mem[_ax()]); }
void lsr_ax() { _lsr(_ax()); }
inline void bvc() { if (!V) _bra(); PC++; }
inline void eor_iy() { _eor(_mem[_iy()]); }
inline void eor_zx() { _eor(_mem[_zx()]); }
inline void lsr_zx() { _lsr(_zx()); }
inline void cli() { P.bits.I = 0; if (_irq) irq(); }
inline void eor_ay() { _eor(_mem[_ay()]); }
inline void eor_ax() { _eor(_mem[_ax()]); }
inline void lsr_ax() { _lsr(_ax()); }
// 60
void rts();
void adc_ix() { _adc(_mem[_ix()]); }
void adc_z() { _adc(_mem[_z()]); }
void ror_z() { _ror(_z()); }
void pla() { Z=N=A=popb(); }
void adc_() { _adc(_mem[PC++]); }
void ror_() { A=__ror(A); }
void jmp_i() { PC = _i(_a()); }
void adc_a() { _adc(_mem[_a()]); }
void ror_a() { _ror(_a()); }
inline void rts() { PC = popa()+1; }
inline void adc_ix() { _adc(_mem[_ix()]); }
inline void adc_z() { _adc(_mem[_z()]); }
inline void ror_z() { _ror(_z()); }
inline void pla() { Z=N=A=popb(); }
inline void adc_() { _adc(_mem[PC++]); }
inline void ror_() { A=__ror(A); }
inline void jmp_i() { PC = _i(_a()); }
inline void adc_a() { _adc(_mem[_a()]); }
inline void ror_a() { _ror(_a()); }
// 70
void bvs() { if (V) _bra(); PC++; }
void adc_iy() { _adc(_mem[_iy()]); }
void adc_zx() { _adc(_mem[_zx()]); }
void ror_zx() { _ror(_zx()); }
void sei() { P.bits.I = 1; }
void adc_ay() { _adc(_mem[_ay()]); }
void adc_ax() { _adc(_mem[_ax()]); }
void ror_ax() { _ror(_ax()); }
inline void bvs() { if (V) _bra(); PC++; }
inline void adc_iy() { _adc(_mem[_iy()]); }
inline void adc_zx() { _adc(_mem[_zx()]); }
inline void ror_zx() { _ror(_zx()); }
inline void sei() { P.bits.I = 1; }
inline void adc_ay() { _adc(_mem[_ay()]); }
inline void adc_ax() { _adc(_mem[_ax()]); }
inline void ror_ax() { _ror(_ax()); }
// 80
void sta_ix() { _mem[_ix()] = A; }
void sty_z() { _mem[_z()] = Y; }
void sta_z() { _mem[_z()] = A; }
void stx_z() { _mem[_z()] = X; }
void dey() { Z=N=--Y; }
void txa() { Z=N=A=X; }
void sty_a() { _mem[_a()] = Y; }
void sta_a() { _mem[_a()] = A; }
void stx_a() { _mem[_a()] = X; }
inline void sta_ix() { _mem[_ix()] = A; }
inline void sty_z() { _mem[_z()] = Y; }
inline void sta_z() { _mem[_z()] = A; }
inline void stx_z() { _mem[_z()] = X; }
inline void dey() { Z=N=--Y; }
inline void txa() { Z=N=A=X; }
inline void sty_a() { _mem[_a()] = Y; }
inline void sta_a() { _mem[_a()] = A; }
inline void stx_a() { _mem[_a()] = X; }
// 90
void bcc() { if (!C) _bra(); PC++; }
void sta_iy() { _mem[_iy()] = A; }
void sty_zx() { _mem[_zx()] = Y; }
void sta_zx() { _mem[_zx()] = A; }
void stx_zy() { _mem[_zy()] = X; }
void tya() { Z=N=A=Y; }
void sta_ay() { _mem[_ay()] = A; }
void txs() { S=X; }
void sta_ax() { _mem[_ax()] = A; }
inline void bcc() { if (!C) _bra(); PC++; }
inline void sta_iy() { _mem[_iy()] = A; }
inline void sty_zx() { _mem[_zx()] = Y; }
inline void sta_zx() { _mem[_zx()] = A; }
inline void stx_zy() { _mem[_zy()] = X; }
inline void tya() { Z=N=A=Y; }
inline void sta_ay() { _mem[_ay()] = A; }
inline void txs() { S=X; }
inline void sta_ax() { _mem[_ax()] = A; }
// a0
void ldy_() { _ldy(_mem[PC++]); }
void lda_ix() { _lda(_mem[_ix()]); }
void ldx_() { _ldx(_mem[PC++]); }
void lax_ix() { lda_ix(); X=A; }
void ldy_z() { _ldy(_mem[_z()]); }
void lda_z() { _lda(_mem[_z()]); }
void ldx_z() { _ldx(_mem[_z()]); }
void lax_z() { lda_z(); X=A; }
void tay() { Z=N=Y=A; }
void lda_() { _lda(_mem[PC++]); }
void tax() { Z=N=X=A; }
void ldy_a() { _ldy(_mem[_a()]); }
void lda_a() { _lda(_mem[_a()]); }
void ldx_a() { _ldx(_mem[_a()]); }
void lax_a() { lda_a(); X=A; }
inline void ldy_() { _ldy(_mem[PC++]); }
inline void lda_ix() { _lda(_mem[_ix()]); }
inline void ldx_() { _ldx(_mem[PC++]); }
inline void lax_ix() { lda_ix(); X=A; }
inline void ldy_z() { _ldy(_mem[_z()]); }
inline void lda_z() { _lda(_mem[_z()]); }
inline void ldx_z() { _ldx(_mem[_z()]); }
inline void lax_z() { lda_z(); X=A; }
inline void tay() { Z=N=Y=A; }
inline void lda_() { _lda(_mem[PC++]); }
inline void tax() { Z=N=X=A; }
inline void ldy_a() { _ldy(_mem[_a()]); }
inline void lda_a() { _lda(_mem[_a()]); }
inline void ldx_a() { _ldx(_mem[_a()]); }
inline void lax_a() { lda_a(); X=A; }
// b0
void bcs() { if (C) _bra(); PC++; }
void lda_iy() { _lda(_mem[_iy()]); }
void lax_iy() { lda_iy(); X=A; }
void ldy_zx() { _ldy(_mem[_zx()]); }
void lda_zx() { _lda(_mem[_zx()]); }
void ldx_zy() { _ldx(_mem[_zy()]); }
void lax_zy() { ldx_zy(); A=X; }
void clv() { V=0; }
void lda_ay() { _lda(_mem[_ay()]); }
void tsx() { Z=N=X=S; }
void ldy_ax() { _ldy(_mem[_ax()]); }
void lda_ax() { _lda(_mem[_ax()]); }
void ldx_ay() { _ldx(_mem[_ay()]); }
void lax_ay() { ldx_ay(); A=X; }
inline void bcs() { if (C) _bra(); PC++; }
inline void lda_iy() { _lda(_mem[_iy()]); }
inline void lax_iy() { lda_iy(); X=A; }
inline void ldy_zx() { _ldy(_mem[_zx()]); }
inline void lda_zx() { _lda(_mem[_zx()]); }
inline void ldx_zy() { _ldx(_mem[_zy()]); }
inline void lax_zy() { ldx_zy(); A=X; }
inline void clv() { V=0; }
inline void lda_ay() { _lda(_mem[_ay()]); }
inline void tsx() { Z=N=X=S; }
inline void ldy_ax() { _ldy(_mem[_ax()]); }
inline void lda_ax() { _lda(_mem[_ax()]); }
inline void ldx_ay() { _ldx(_mem[_ay()]); }
inline void lax_ay() { ldx_ay(); A=X; }
// c0
void cpy_() { _cpy(_mem[PC++]); }
void cmp_ix() { _cmp(_mem[_ix()]); }
void cpy_z() { _cpy(_mem[_z()]); }
void cmp_z() { _cmp(_mem[_z()]); }
void dec_z() { _dec(_z()); }
void iny() { Z=N=++Y; }
void cmp_() { _cmp(_mem[PC++]); }
void dex() { Z=N=--X; }
void cpy_a() { _cpy(_mem[_a()]); }
void cmp_a() { _cmp(_mem[_a()]); }
void dec_a() { _dec(_a()); }
inline void cpy_() { _cpy(_mem[PC++]); }
inline void cmp_ix() { _cmp(_mem[_ix()]); }
inline void cpy_z() { _cpy(_mem[_z()]); }
inline void cmp_z() { _cmp(_mem[_z()]); }
inline void dec_z() { _dec(_z()); }
inline void iny() { Z=N=++Y; }
inline void cmp_() { _cmp(_mem[PC++]); }
inline void dex() { Z=N=--X; }
inline void cpy_a() { _cpy(_mem[_a()]); }
inline void cmp_a() { _cmp(_mem[_a()]); }
inline void dec_a() { _dec(_a()); }
// d0
void bne() { if (Z) _bra(); PC++; }
void cmp_iy() { _cmp(_mem[_iy()]); }
void cmp_zx() { _cmp(_mem[_zx()]); }
void dec_zx() { _dec(_zx()); }
void cld() { P.bits.D = 0; }
void cmp_ay() { _cmp(_mem[_ay()]); }
void cmp_ax() { _cmp(_mem[_ax()]); }
void dec_ax() { _dec(_ax()); }
inline void bne() { if (Z) _bra(); PC++; }
inline void cmp_iy() { _cmp(_mem[_iy()]); }
inline void cmp_zx() { _cmp(_mem[_zx()]); }
inline void dec_zx() { _dec(_zx()); }
inline void cld() { P.bits.D = 0; }
inline void cmp_ay() { _cmp(_mem[_ay()]); }
inline void cmp_ax() { _cmp(_mem[_ax()]); }
inline void dec_ax() { _dec(_ax()); }
// e0
void cpx_() { _cpx(_mem[PC++]); }
void sbc_ix() { _sbc(_mem[_ix()]); }
void cpx_z() { _cpx(_mem[_z()]); }
void sbc_z() { _sbc(_mem[_z()]); }
void inc_z() { _inc(_z()); }
void inx() { Z=N=++X; }
void sbc_() { _sbc(_mem[PC++]); }
void cpx_a() { _cpx(_mem[_a()]); }
void sbc_a() { _sbc(_mem[_a()]); }
void inc_a() { _inc(_a()); }
inline void cpx_() { _cpx(_mem[PC++]); }
inline void sbc_ix() { _sbc(_mem[_ix()]); }
inline void cpx_z() { _cpx(_mem[_z()]); }
inline void sbc_z() { _sbc(_mem[_z()]); }
inline void inc_z() { _inc(_z()); }
inline void inx() { Z=N=++X; }
inline void sbc_() { _sbc(_mem[PC++]); }
inline void cpx_a() { _cpx(_mem[_a()]); }
inline void sbc_a() { _sbc(_mem[_a()]); }
inline void inc_a() { _inc(_a()); }
// f0
void beq() { if (!Z) _bra(); PC++; }
void sbc_iy() { _sbc(_mem[_iy()]); }
void sbc_zx() { _sbc(_mem[_zx()]); }
void inc_zx() { _inc(_zx()); }
void sed() { P.bits.D = 1; }
void sbc_ay() { _sbc(_mem[_ay()]); }
void sbc_ax() { _sbc(_mem[_ax()]); }
void inc_ax() { _inc(_ax()); }
inline void beq() { if (!Z) _bra(); PC++; }
inline void sbc_iy() { _sbc(_mem[_iy()]); }
inline void sbc_zx() { _sbc(_mem[_zx()]); }
inline void inc_zx() { _inc(_zx()); }
inline void sed() { P.bits.D = 1; }
inline void sbc_ay() { _sbc(_mem[_ay()]); }
inline void sbc_ax() { _sbc(_mem[_ax()]); }
inline void inc_ax() { _inc(_ax()); }
};
#endif