@macro op_adjust_reg(name, r)
  void {class}::op_{name}_{r}() {
    op_io();
    regs.{r} = op_{name}(regs.{r});
  }
@endmacro

@macro op_adjust_dp(name)
  void {class}::op_{name}_dp() {
    dp = op_readpc();
    rd = op_readdp(dp);
    rd = op_{name}(rd);
    op_writedp(dp, rd);
  }
@endmacro

@macro op_adjust_dpx(name)
  void {class}::op_{name}_dpx() {
    dp = op_readpc();
    op_io();
    rd = op_readdp(dp + regs.x);
    rd = op_{name}(rd);
    op_writedp(dp + regs.x, rd);
  }
@endmacro

@macro op_adjust_addr(name)
  void {class}::op_{name}_addr() {
    dp  = op_readpc() << 0;
    dp |= op_readpc() << 8;
    rd  = op_readaddr(dp);
    rd  = op_{name}(rd);
    op_writeaddr(dp, rd);
  }
@endmacro

@macro op_tadjust_addr(name, op)
  void {class}::op_{name}_addr_a() {
    dp  = op_readpc() << 0;
    dp |= op_readpc() << 8;
    rd  = op_readaddr(dp);
    regs.p.n = ((regs.a - rd) & 0x80);
    regs.p.z = ((regs.a - rd) == 0);
    op_readaddr(dp);
    op_writeaddr(dp, rd {op} regs.a);
  }
@endmacro

@macro op_adjustw_dp(name, op)
  void {class}::op_{name}_dp() {
    dp  = op_readpc();
    rd  = op_readdp(dp) << 0;
    rd {op};
    op_writedp(dp++, rd);
    rd += op_readdp(dp) << 8;
    op_writedp(dp, rd >> 8);
    regs.p.n = (rd & 0x8000);
    regs.p.z = (rd == 0);
  }
@endmacro

