# `subq`

[M68K Documentation](https://asm-editor.specy.app/documentation/m68k.md) › [Instructions](https://asm-editor.specy.app/documentation/m68k/instruction.md)

Web page: https://asm-editor.specy.app/documentation/m68k/instruction/subq

**Subtract quick**

Category: Arithmetic

Subtracts an immediate value of 1 to 8 from the second operand.

Sizes .b .w .l, .w by default

Used in: [Length of a string](https://asm-editor.specy.app/learn/courses/m68k/examples/string-length.md) (M68K assembly), [Reverse a string in place](https://asm-editor.specy.app/learn/courses/m68k/examples/reverse-a-string.md) (M68K assembly), [Recursion: factorial and Fibonacci](https://asm-editor.specy.app/learn/courses/m68k/examples/factorial-and-fibonacci.md) (M68K assembly), [Binary search](https://asm-editor.specy.app/learn/courses/m68k/examples/binary-search.md) (M68K assembly), [The snake game](https://asm-editor.specy.app/learn/courses/m68k/examples/snake.md) (M68K assembly), [Flappy ASM](https://asm-editor.specy.app/learn/courses/m68k/examples/flappy-asm.md) (M68K assembly)

## Flags

| Flag | Effect |
| --- | --- |
| X | depends on the result |
| N | depends on the result |
| Z | depends on the result |
| V | depends on the result |
| C | depends on the result |

## Forms

- `subq #imm, <ea>`
  - Destination: Dn, An, (An), (An)+, -(An), d(An), d(An,Xn), abs (alterable)

## Operands

- [`#imm`](https://asm-editor.specy.app/documentation/m68k/addressing-mode/immediate.md): An immediate from `1` to `8`, for example `#1`.
- [`<ea>`](https://asm-editor.specy.app/documentation/m68k/addressing-mode.md): An operand using one of the addressing modes listed for this form. The list determines whether it can be a register, memory or an immediate value. With `opt p=68020`, an allowed `d(An,Xn)` or `d(PC,Xn)` mode also permits the corresponding 68020 indexed and memory indirect forms. See [68020 addressing](https://asm-editor.specy.app/documentation/m68k/addressing-mode/68020.md).

## Description

The first operand value must be between 1 and 8. If the destination is an address register, it is always treated as a long, and the condition codes are not affected.

## Example

```m68k
move.l #$10, d0
subq.l #8, d0
subq.l #1, d0
; subq.w #9, d0 ; error! immediate must be 1-8
```
