//==============
//opcode_mov.bpp
//==============

@op_mov_reg(a, x)
@op_mov_reg(a, y)
@op_mov_reg(x, a)
@op_mov_reg(y, a)
@op_mov_reg(x, sp)
@op_mov_sp_x()

@op_mov_reg_const(a)
@op_mov_reg_const(x)
@op_mov_reg_const(y)
@op_mov_a_ix()
@op_mov_a_ixinc()

@op_mov_reg_dp(a)
@op_mov_reg_dp(x)
@op_mov_reg_dp(y)

@op_mov_reg_dpi(a, x)
@op_mov_reg_dpi(x, y)
@op_mov_reg_dpi(y, x)

@op_mov_reg_addr(a)
@op_mov_reg_addr(x)
@op_mov_reg_addr(y)

@op_mov_a_addri(x)
@op_mov_a_addri(y)

@op_mov_a_idpx()
@op_mov_a_idpy()
@op_mov_dp_dp()
@op_mov_dp_const()
@op_mov_ix_a()
@op_mov_ixinc_a()

@op_mov_dp_reg(a)
@op_mov_dp_reg(x)
@op_mov_dp_reg(y)

@op_mov_dpi_reg(a, x)
@op_mov_dpi_reg(x, y)
@op_mov_dpi_reg(y, x)

@op_mov_addr_reg(a)
@op_mov_addr_reg(x)
@op_mov_addr_reg(y)

@op_mov_addri_a(x)
@op_mov_addri_a(y)

@op_mov_idpx_a()
@op_mov_idpy_a()
@op_movw_ya_dp()
@op_movw_dp_ya()
@op_mov1_c_bit()
@op_mov1_bit_c()

//=============
//opcode_pc.bpp
//=============

@op_branch(bra, 0)
@op_branch(beq, !regs.p.z)
@op_branch(bne,  regs.p.z)
@op_branch(bcs, !regs.p.c)
@op_branch(bcc,  regs.p.c)
@op_branch(bvs, !regs.p.v)
@op_branch(bvc,  regs.p.v)
@op_branch(bmi, !regs.p.n)
@op_branch(bpl,  regs.p.n)

@op_bitbranch(bbs0, 0x01, !=)
@op_bitbranch(bbc0, 0x01, ==)
@op_bitbranch(bbs1, 0x02, !=)
@op_bitbranch(bbc1, 0x02, ==)
@op_bitbranch(bbs2, 0x04, !=)
@op_bitbranch(bbc2, 0x04, ==)
@op_bitbranch(bbs3, 0x08, !=)
@op_bitbranch(bbc3, 0x08, ==)
@op_bitbranch(bbs4, 0x10, !=)
@op_bitbranch(bbc4, 0x10, ==)
@op_bitbranch(bbs5, 0x20, !=)
@op_bitbranch(bbc5, 0x20, ==)
@op_bitbranch(bbs6, 0x40, !=)
@op_bitbranch(bbc6, 0x40, ==)
@op_bitbranch(bbs7, 0x80, !=)
@op_bitbranch(bbc7, 0x80, ==)

@op_cbne_dp()
@op_cbne_dpx()
@op_dbnz_dp()
@op_dbnz_y()
@op_jmp_addr()
@op_jmp_iaddrx()
@op_call()
@op_pcall()

@op_tcall( 0)
@op_tcall( 1)
@op_tcall( 2)
@op_tcall( 3)
@op_tcall( 4)
@op_tcall( 5)
@op_tcall( 6)
@op_tcall( 7)
@op_tcall( 8)
@op_tcall( 9)
@op_tcall(10)
@op_tcall(11)
@op_tcall(12)
@op_tcall(13)
@op_tcall(14)
@op_tcall(15)

@op_brk()
@op_ret()
@op_reti()

//===============
//opcode_read.bpp
//===============

@op_read_reg_const(adc, a)
@op_read_reg_const(and, a)
@op_read_reg_const(cmp, a)
@op_read_reg_const(cmp, x)
@op_read_reg_const(cmp, y)
@op_read_reg_const(eor, a)
@op_read_reg_const(or,  a)
@op_read_reg_const(sbc, a)

@op_read_a_ix(adc)
@op_read_a_ix(and)
@op_read_a_ix(cmp)
@op_read_a_ix(eor)
@op_read_a_ix(or)
@op_read_a_ix(sbc)

@op_read_reg_dp(adc, a)
@op_read_reg_dp(and, a)
@op_read_reg_dp(cmp, a)
@op_read_reg_dp(cmp, x)
@op_read_reg_dp(cmp, y)
@op_read_reg_dp(eor, a)
@op_read_reg_dp(or,  a)
@op_read_reg_dp(sbc, a)

@op_read_a_dpx(adc)
@op_read_a_dpx(and)
@op_read_a_dpx(cmp)
@op_read_a_dpx(eor)
@op_read_a_dpx(or)
@op_read_a_dpx(sbc)

@op_read_reg_addr(adc, a)
@op_read_reg_addr(and, a)
@op_read_reg_addr(cmp, a)
@op_read_reg_addr(cmp, x)
@op_read_reg_addr(cmp, y)
@op_read_reg_addr(eor, a)
@op_read_reg_addr(or,  a)
@op_read_reg_addr(sbc, a)

@op_read_a_addri(adc, x)
@op_read_a_addri(adc, y)
@op_read_a_addri(and, x)
@op_read_a_addri(and, y)
@op_read_a_addri(cmp, x)
@op_read_a_addri(cmp, y)
@op_read_a_addri(eor, x)
@op_read_a_addri(eor, y)
@op_read_a_addri(or,  x)
@op_read_a_addri(or,  y)
@op_read_a_addri(sbc, x)
@op_read_a_addri(sbc, y)

@op_read_a_idpx(adc)
@op_read_a_idpx(and)
@op_read_a_idpx(cmp)
@op_read_a_idpx(eor)
@op_read_a_idpx(or)
@op_read_a_idpx(sbc)

@op_read_a_idpy(adc)
@op_read_a_idpy(and)
@op_read_a_idpy(cmp)
@op_read_a_idpy(eor)
@op_read_a_idpy(or)
@op_read_a_idpy(sbc)

@op_read_ix_iy(adc, 1)
@op_read_ix_iy(and, 1)
@op_read_ix_iy(cmp, 0)
@op_read_ix_iy(eor, 1)
@op_read_ix_iy(or,  1)
@op_read_ix_iy(sbc, 1)

@op_read_dp_dp(adc, 1)
@op_read_dp_dp(and, 1)
@op_read_dp_dp(cmp, 0)
@op_read_dp_dp(eor, 1)
@op_read_dp_dp(or,  1)
@op_read_dp_dp(sbc, 1)

@op_read_dp_const(adc, 1)
@op_read_dp_const(and, 1)
@op_read_dp_const(cmp, 0)
@op_read_dp_const(eor, 1)
@op_read_dp_const(or,  1)
@op_read_dp_const(sbc, 1)

@op_read_ya_dp(addw)
@op_read_ya_dp(subw)
@op_cmpw_ya_dp()

@op_and1(bit, !!)
@op_and1(notbit, !)
@op_eor1()
@op_not1()
@op_or1(bit, !!)
@op_or1(notbit, !)

//==============
//opcode_rmw.bpp
//==============

@op_adjust_reg(inc, a)
@op_adjust_reg(inc, x)
@op_adjust_reg(inc, y)
@op_adjust_reg(dec, a)
@op_adjust_reg(dec, x)
@op_adjust_reg(dec, y)
@op_adjust_reg(asl, a)
@op_adjust_reg(lsr, a)
@op_adjust_reg(rol, a)
@op_adjust_reg(ror, a)

@op_adjust_dp(inc)
@op_adjust_dp(dec)
@op_adjust_dp(asl)
@op_adjust_dp(lsr)
@op_adjust_dp(rol)
@op_adjust_dp(ror)

@op_adjust_dpx(inc)
@op_adjust_dpx(dec)
@op_adjust_dpx(asl)
@op_adjust_dpx(lsr)
@op_adjust_dpx(rol)
@op_adjust_dpx(ror)

@op_adjust_addr(inc)
@op_adjust_addr(dec)
@op_adjust_addr(asl)
@op_adjust_addr(lsr)
@op_adjust_addr(rol)
@op_adjust_addr(ror)

@op_tadjust_addr(tset, |)
@op_tadjust_addr(tclr, &~)

@op_adjustw_dp(incw, ++)
@op_adjustw_dp(decw, --)

//===============
//opcode_misc.bpp
//===============

@op_nop()
@op_wait(sleep)
@op_wait(stop)
@op_xcn()
@op_daa()
@op_das()

@op_setbit(clrc, regs.p.c = 0)
@op_setbit(clrp, regs.p.p = 0)
@op_setbit(setc, regs.p.c = 1)
@op_setbit(setp, regs.p.p = 1)
@op_setbit(clrv, regs.p.v = regs.p.h = 0)

@op_notc()
@op_seti(ei, 1)
@op_seti(di, 0)

@op_setbit_dp(set0, |=  0x01)
@op_setbit_dp(clr0, &= ~0x01)
@op_setbit_dp(set1, |=  0x02)
@op_setbit_dp(clr1, &= ~0x02)
@op_setbit_dp(set2, |=  0x04)
@op_setbit_dp(clr2, &= ~0x04)
@op_setbit_dp(set3, |=  0x08)
@op_setbit_dp(clr3, &= ~0x08)
@op_setbit_dp(set4, |=  0x10)
@op_setbit_dp(clr4, &= ~0x10)
@op_setbit_dp(set5, |=  0x20)
@op_setbit_dp(clr5, &= ~0x20)
@op_setbit_dp(set6, |=  0x40)
@op_setbit_dp(clr6, &= ~0x40)
@op_setbit_dp(set7, |=  0x80)
@op_setbit_dp(clr7, &= ~0x80)

@op_push(a)
@op_push(x)
@op_push(y)
@op_push(p)

@op_pop(a)
@op_pop(x)
@op_pop(y)
@op_pop(p)

@op_mul_ya()
@op_div_ya_x()

