@macro op_read_const(name)
  void {class}::op_{name}_const_b() {
{lc}rd.l = op_readpc();
    op_{name}_b();
  }

  void {class}::op_{name}_const_w() {
    rd.l = op_readpc();
{lc}rd.h = op_readpc();
    op_{name}_w();
  }
@endmacro

@macro op_read_bit_const()
  void {class}::op_bit_const_b() {
{lc}rd.l = op_readpc();
    regs.p.z = ((rd.l & regs.a.l) == 0);
  }

  void {class}::op_bit_const_w() {
    rd.l = op_readpc();
{lc}rd.h = op_readpc();
    regs.p.z = ((rd.w & regs.a.w) == 0);
  }
@endmacro

@macro op_read_addr(name)
  void {class}::op_{name}_addr_b() {
    aa.l = op_readpc();
    aa.h = op_readpc();
{lc}rd.l = op_readdbr(aa.w);
    op_{name}_b();
  }

  void {class}::op_{name}_addr_w() {
    aa.l = op_readpc();
    aa.h = op_readpc();
    rd.l = op_readdbr(aa.w + 0);
{lc}rd.h = op_readdbr(aa.w + 1);
    op_{name}_w();
  }
@endmacro

@macro op_read_addrx(name)
  void {class}::op_{name}_addrx_b() {
    aa.l = op_readpc();
    aa.h = op_readpc();
    op_io_cond4(aa.w, aa.w + regs.x.w);
{lc}rd.l = op_readdbr(aa.w + regs.x.w);
    op_{name}_b();
  }

  void {class}::op_{name}_addrx_w() {
    aa.l = op_readpc();
    aa.h = op_readpc();
    op_io_cond4(aa.w, aa.w + regs.x.w);
    rd.l = op_readdbr(aa.w + regs.x.w + 0);
{lc}rd.h = op_readdbr(aa.w + regs.x.w + 1);
    op_{name}_w();
  }
@endmacro

@macro op_read_addry(name)
  void {class}::op_{name}_addry_b() {
    aa.l = op_readpc();
    aa.h = op_readpc();
    op_io_cond4(aa.w, aa.w + regs.y.w);
{lc}rd.l = op_readdbr(aa.w + regs.y.w);
    op_{name}_b();
  }

  void {class}::op_{name}_addry_w() {
    aa.l = op_readpc();
    aa.h = op_readpc();
    op_io_cond4(aa.w, aa.w + regs.y.w);
    rd.l = op_readdbr(aa.w + regs.y.w + 0);
{lc}rd.h = op_readdbr(aa.w + regs.y.w + 1);
    op_{name}_w();
  }
@endmacro

@macro op_read_long(name)
  void {class}::op_{name}_long_b() {
    aa.l = op_readpc();
    aa.h = op_readpc();
    aa.b = op_readpc();
{lc}rd.l = op_readlong(aa.d);
    op_{name}_b();
  }

  void {class}::op_{name}_long_w() {
    aa.l = op_readpc();
    aa.h = op_readpc();
    aa.b = op_readpc();
    rd.l = op_readlong(aa.d + 0);
{lc}rd.h = op_readlong(aa.d + 1);
    op_{name}_w();
  }
@endmacro

@macro op_read_longx(name)
  void {class}::op_{name}_longx_b() {
    aa.l = op_readpc();
    aa.h = op_readpc();
    aa.b = op_readpc();
{lc}rd.l = op_readlong(aa.d + regs.x.w);
    op_{name}_b();
  }

  void {class}::op_{name}_longx_w() {
    aa.l = op_readpc();
    aa.h = op_readpc();
    aa.b = op_readpc();
    rd.l = op_readlong(aa.d + regs.x.w + 0);
{lc}rd.h = op_readlong(aa.d + regs.x.w + 1);
    op_{name}_w();
  }
@endmacro

@macro op_read_dp(name)
  void {class}::op_{name}_dp_b() {
    dp = op_readpc();
    op_io_cond2();
{lc}rd.l = op_readdp(dp);
    op_{name}_b();
  }

  void {class}::op_{name}_dp_w() {
    dp = op_readpc();
    op_io_cond2();
    rd.l = op_readdp(dp + 0);
{lc}rd.h = op_readdp(dp + 1);
    op_{name}_w();
  }
@endmacro

@macro op_read_dpr(name, r)
  void {class}::op_{name}_dpr_b() {
    dp = op_readpc();
    op_io_cond2();
    op_io();
{lc}rd.l = op_readdp(dp + regs.{r}.w);
    op_{name}_b();
  }

  void {class}::op_{name}_dpr_w() {
    dp = op_readpc();
    op_io_cond2();
    op_io();
{lc}rd.l = op_readdp(dp + regs.{r}.w + 0);
    rd.h = op_readdp(dp + regs.{r}.w + 1);
    op_{name}_w();
  }
@endmacro

@macro op_read_idp(name)
  void {class}::op_{name}_idp_b() {
    dp = op_readpc();
    op_io_cond2();
    aa.l = op_readdp(dp + 0);
    aa.h = op_readdp(dp + 1);
{lc}rd.l = op_readdbr(aa.w);
    op_{name}_b();
  }

  void {class}::op_{name}_idp_w() {
    dp = op_readpc();
    op_io_cond2();
    aa.l = op_readdp(dp + 0);
    aa.h = op_readdp(dp + 1);
    rd.l = op_readdbr(aa.w + 0);
{lc}rd.h = op_readdbr(aa.w + 1);
    op_{name}_w();
  }
@endmacro

@macro op_read_idpx(name)
  void {class}::op_{name}_idpx_b() {
    dp = op_readpc();
    op_io_cond2();
    op_io();
    aa.l = op_readdp(dp + regs.x.w + 0);
    aa.h = op_readdp(dp + regs.x.w + 1);
{lc}rd.l = op_readdbr(aa.w);
    op_{name}_b();
  }

  void {class}::op_{name}_idpx_w() {
    dp = op_readpc();
    op_io_cond2();
    op_io();
    aa.l = op_readdp(dp + regs.x.w + 0);
    aa.h = op_readdp(dp + regs.x.w + 1);
    rd.l = op_readdbr(aa.w + 0);
{lc}rd.h = op_readdbr(aa.w + 1);
    op_{name}_w();
  }
@endmacro

@macro op_read_idpy(name)
  void {class}::op_{name}_idpy_b() {
    dp = op_readpc();
    op_io_cond2();
    aa.l = op_readdp(dp + 0);
    aa.h = op_readdp(dp + 1);
    op_io_cond4(aa.w, aa.w + regs.y.w);
{lc}rd.l = op_readdbr(aa.w + regs.y.w);
    op_{name}_b();
  }

  void {class}::op_{name}_idpy_w() {
    dp = op_readpc();
    op_io_cond2();
    aa.l = op_readdp(dp + 0);
    aa.h = op_readdp(dp + 1);
    op_io_cond4(aa.w, aa.w + regs.y.w);
    rd.l = op_readdbr(aa.w + regs.y.w + 0);
{lc}rd.h = op_readdbr(aa.w + regs.y.w + 1);
    op_{name}_w();
  }
@endmacro

@macro op_read_ildp(name)
  void {class}::op_{name}_ildp_b() {
    dp = op_readpc();
    op_io_cond2();
    aa.l = op_readdp(dp + 0);
    aa.h = op_readdp(dp + 1);
    aa.b = op_readdp(dp + 2);
{lc}rd.l = op_readlong(aa.d);
    op_{name}_b();
  }

  void {class}::op_{name}_ildp_w() {
    dp = op_readpc();
    op_io_cond2();
    aa.l = op_readdp(dp + 0);
    aa.h = op_readdp(dp + 1);
    aa.b = op_readdp(dp + 2);
    rd.l = op_readlong(aa.d + 0);
{lc}rd.h = op_readlong(aa.d + 1);
    op_{name}_w();
  }
@endmacro

@macro op_read_ildpy(name)
  void {class}::op_{name}_ildpy_b() {
    dp = op_readpc();
    op_io_cond2();
    aa.l = op_readdp(dp + 0);
    aa.h = op_readdp(dp + 1);
    aa.b = op_readdp(dp + 2);
{lc}rd.l = op_readlong(aa.d + regs.y.w);
    op_{name}_b();
  }

  void {class}::op_{name}_ildpy_w() {
    dp = op_readpc();
    op_io_cond2();
    aa.l = op_readdp(dp + 0);
    aa.h = op_readdp(dp + 1);
    aa.b = op_readdp(dp + 2);
    rd.l = op_readlong(aa.d + regs.y.w + 0);
{lc}rd.h = op_readlong(aa.d + regs.y.w + 1);
    op_{name}_w();
  }
@endmacro

@macro op_read_sr(name)
  void {class}::op_{name}_sr_b() {
    sp = op_readpc();
    op_io();
{lc}rd.l = op_readsp(sp);
    op_{name}_b();
  }

  void {class}::op_{name}_sr_w() {
    sp = op_readpc();
    op_io();
    rd.l = op_readsp(sp + 0);
{lc}rd.h = op_readsp(sp + 1);
    op_{name}_w();
  }
@endmacro

@macro op_read_isry(name)
  void {class}::op_{name}_isry_b() {
    sp = op_readpc();
    op_io();
    aa.l = op_readsp(sp + 0);
    aa.h = op_readsp(sp + 1);
    op_io();
{lc}rd.l = op_readdbr(aa.w + regs.y.w);
    op_{name}_b();
  }

  void {class}::op_{name}_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);
{lc}rd.h = op_readdbr(aa.w + regs.y.w + 1);
    op_{name}_w();
  }
@endmacro
