# `subx`

[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/subx

**Subtract extended**

Category: Arithmetic

Subtracts the source and X flag from the destination, and stores the result in the destination.

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

## 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 |

Reads: X

## Forms

- `subx Dn, Dn`
- `subx -(An), -(An)`

## Operands

- [`Dn`](https://asm-editor.specy.app/documentation/m68k/addressing-mode/direct.md): A data register, `d0` to `d7`.
- [`-(An)`](https://asm-editor.specy.app/documentation/m68k/addressing-mode/indirect-post-pre-increment.md): Decreases an address register by 1, 2 or 4 bytes for a byte, word or long access, then accesses memory there. A byte access through `sp` decreases it by 2 to keep it even.

## Description

Both operands must be data registers, or both must use predecrement addressing. The registers need not be the same. For a value split into several parts, start with the least significant part so X carries each borrow into the next subtraction.

Z is cumulative: a zero result preserves its previous value, and a nonzero result clears it. Set Z and clear X before the first part, for example with `move.w #4, ccr`. Z then remains set only if every result part is zero. C and X report the borrow from the current part.
