# `cmpm`

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

**Compare memory**

Category: Comparison

Compares two memory operands that use post-increment addressing and sets the flags.

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

## Flags

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

## Forms

- `cmpm (An)+, (An)+`

## Operands

- [`(An)+`](https://asm-editor.specy.app/documentation/m68k/addressing-mode/indirect-post-pre-increment.md): Memory at an address register, followed by an increase of 1, 2 or 4 bytes for a byte, word or long access. A byte access through `sp` increases it by 2 to keep it even.

## Example

```m68k
* --- Compare two memory blocks byte by byte ---
lea $2000, a0 ; free memory: the program itself is at $1000
lea $2100, a1
move.l #$AABB, (a0)
move.l #$AABB, (a1)

cmpm.b (a0)+, (a1)+ ; compare 1st byte (equal)
seq d0
cmpm.b (a0)+, (a1)+ ; compare 2nd byte (equal)
seq d1
; a0 and a1 are auto-incremented after each cmpm
```
