void CPUcore::op_sta_isry_w() { sp = op_readpc(); op_io(); aa.l = op_readsp(sp + 0); aa.h = op_readsp(sp + 1); op_io(); op_writedbr(aa.w + regs.y.w + 0, regs.a.l); L op_writedbr(aa.w + regs.y.w + 1, regs.a.h); }
template<void (R65816::*op)()> void R65816::op_read_isry_b() { sp = op_readpc(); op_io(); aa.l = op_readsp(sp + 0); aa.h = op_readsp(sp + 1); op_io(); L rd.l = op_readdbr(aa.w + regs.y.w); call(op); }
void R65816::op_xba() { op_io(); L op_io(); regs.a.l ^= regs.a.h; regs.a.h ^= regs.a.l; regs.a.l ^= regs.a.h; regs.p.n = (regs.a.l & 0x80); regs.p.z = (regs.a.l == 0); }
void CPUcore::op_rtl_n() { op_io(); op_io(); rd.l = op_readstackn(); rd.h = op_readstackn(); L rd.b = op_readstackn(); regs.pc.b = rd.b; regs.pc.w = ++rd.w; }
void R65816::op_pld_e() { op_io(); op_io(); regs.d.l = op_readstackn(); L regs.d.h = op_readstackn(); regs.p.n = (regs.d.w & 0x8000); regs.p.z = (regs.d.w == 0); regs.s.h = 0x01; }
void CPUcore::op_rtl() { op_io(); op_io(); rd.l = op_readstackn(); rd.h = op_readstackn(); L rd.b = op_readstackn(); regs.pc.b = rd.b; regs.pc.w = ++rd.w; if(regs.e) regs.s.h = 0x01; }
template<int mask, int value> alwaysinline void SMP::op_bitbranch() { dp = op_readpc(); sp = op_readdp(dp); rd = op_readpc(); op_io(); if((bool)(sp & mask) != value) return; op_io(); op_io(); regs.pc += (int8)rd; }
alwaysinline void SMP::op_cbne_dp() { dp = op_readpc(); sp = op_readdp(dp); rd = op_readpc(); op_io(); if(regs.a == sp) return; op_io(); op_io(); regs.pc += (int8)rd; }
void R65816::op_plp_n() { op_io(); op_io(); L regs.p = op_readstack(); if(regs.p.x) { regs.x.h = 0x00; regs.y.h = 0x00; } update_table(); }
template<void (CPUcore::*op)()> void CPUcore::op_read_isry_w() { sp = op_readpc(); op_io(); aa.l = op_readsp(sp + 0); aa.h = op_readsp(sp + 1); op_io(); rd.l = op_readdbr(aa.w + regs.y.w + 0); L rd.h = op_readdbr(aa.w + regs.y.w + 1); call(op); }
alwaysinline void SMP::op_call() { rd = op_readpc() << 0; rd |= op_readpc() << 8; op_io(); op_io(); op_io(); op_writestack(regs.pc >> 8); op_writestack(regs.pc >> 0); regs.pc = rd; }
void R65816::op_rtl_e() { op_io(); op_io(); rd.l = op_readstackn(); rd.h = op_readstackn(); L rd.b = op_readstackn(); regs.pc.b = rd.b; regs.pc.w = ++rd.w; regs.s.h = 0x01; }
alwaysinline void SMP::op_dbnz_y() { rd = op_readpc(); op_io(); regs.y--; op_io(); if(regs.y == 0) return; op_io(); op_io(); regs.pc += (int8)rd; }
alwaysinline void SMP::op_dbnz_dp() { dp = op_readpc(); wr = op_readdp(dp); op_writedp(dp, --wr); rd = op_readpc(); if(wr == 0) return; op_io(); op_io(); regs.pc += (int8)rd; }
template<int n> alwaysinline void SMP::op_tcall() { dp = 0xffde - (n << 1); rd = op_readaddr(dp + 0) << 0; rd |= op_readaddr(dp + 1) << 8; op_io(); op_io(); op_io(); op_writestack(regs.pc >> 8); op_writestack(regs.pc >> 0); regs.pc = rd; }
template<int adjust> void R65816::op_move_w() { dp = op_readpc(); sp = op_readpc(); regs.db = dp; rd.l = op_readlong((sp << 16) | regs.x.w); op_writelong((dp << 16) | regs.y.w, rd.l); op_io(); regs.x.w += adjust; regs.y.w += adjust; L op_io(); if(regs.a.w--) regs.pc.w -= 3; }
alwaysinline void SMP::op_brk() { rd = op_readaddr(0xffde) << 0; rd |= op_readaddr(0xffdf) << 8; op_io(); op_io(); op_writestack(regs.pc >> 8); op_writestack(regs.pc >> 0); op_writestack(regs.p); regs.pc = rd; regs.p.b = 1; regs.p.i = 0; }
void R65816::op_rti_n() { op_io(); op_io(); regs.p = op_readstack(); if(regs.p.x) { regs.x.h = 0x00; regs.y.h = 0x00; } rd.l = op_readstack(); rd.h = op_readstack(); L rd.b = op_readstack(); regs.pc.d = rd.d & 0xffffff; update_table(); }
template<int n, int i> void CPUcore::op_write_dpr_w() { dp = op_readpc(); op_io_cond2(); op_io(); op_writedp(dp + regs.r[i] + 0, regs.r[n] >> 0); L op_writedp(dp + regs.r[i] + 1, regs.r[n] >> 8); }
template<int n, int i> void SMPcore::op_mov_dpr_reg() { dp = op_readpc(); op_io(); dp += regs.r[i]; op_readdp<false>(dp); op_writedp(dp, regs.r[n]); }
void R65816::op_bra() { rd.l = op_readpc(); aa.w = regs.pc.d + (int8)rd.l; op_io_cond6(aa.w); L op_io(); regs.pc.w = aa.w; }
void SMPcore::op_adjust_dpx() { dp = op_readpc(); op_io(); rd = op_readdp(dp + regs.x); rd = (this->*op)(rd); op_writedp(dp + regs.x, rd); }
template<int n, int i> void CPUcore::op_write_addrr_w() { aa.l = op_readpc(); aa.h = op_readpc(); op_io(); op_writedbr(aa.w + regs.r[i] + 0, regs.r[n] >> 0); L op_writedbr(aa.w + regs.r[i] + 1, regs.r[n] >> 8); }
template<void (R65816::*op)()> void R65816::op_read_sr_w() { sp = op_readpc(); op_io(); rd.l = op_readsp(sp + 0); L rd.h = op_readsp(sp + 1); call(op); }
void SMP::op_read_ya_dp() { dp = op_readpc(); rd = op_readdp(dp + 0) << 0; op_io(); rd |= op_readdp(dp + 1) << 8; regs.ya = (this->*op)(regs.ya, rd); }
void SMP::op_read_a_addrr() { dp = op_readpc() << 0; dp |= op_readpc() << 8; op_io(); rd = op_readaddr(dp + regs.r[i]); regs.a = (this->*op)(regs.a, rd); }
template<int n, int i> alwaysinline void SMP::op_mov_reg_dpr() { sp = op_readpc(); op_io(); regs.r[n] = op_readdp(sp + regs.r[i]); regs.p.n = (regs.r[n] & 0x80); regs.p.z = (regs.r[n] == 0); }
template<int n, int i> alwaysinline void SMP::op_mov_dpr_reg() { dp = op_readpc(); op_io(); dp += regs.r[i]; op_readdp(dp); op_writedp(dp, regs.r[n]); }
template<void (R65816::*op)(), int n> void R65816::op_read_dpr_b() { dp = op_readpc(); op_io_cond2(); op_io(); L rd.l = op_readdp(dp + regs.r[n].w); call(op); }
void R65816::op_jmp_iaddrx() { aa.l = op_readpc(); aa.h = op_readpc(); op_io(); rd.l = op_readpbr(aa.w + regs.x.w + 0); L rd.h = op_readpbr(aa.w + regs.x.w + 1); regs.pc.w = rd.w; }