CMP
Compare by subtraction
Compute the flags of SUBS with a zero-register destination; discard the data result.
| Form | Bits | Requires | Encoding |
|---|---|---|---|
CMP Wn, Wm{, shift #amount} | 32 | Armv8-A | 01101011xx0xxxxxxxxxxxxxxxx11111 |
CMP Wn|WSP, #imm{, LSL #12} | 32 | Armv8-A | 011100010xxxxxxxxxxxxxxxxxx11111 |
CMP Xn, Xm{, shift #amount} | 64 | Armv8-A | 11101011xx0xxxxxxxxxxxxxxxx11111 |
CMP Xn|SP, #imm{, LSL #12} | 64 | Armv8-A | 111100010xxxxxxxxxxxxxxxxxx11111 |
Operation#
Pseudo-C · selected form
b = shift_within_width(Rm, shift, amount)
result = (Rn - b) mod 2^width
// result discarded
N = most_significant_bit(result)
Z = (result == 0)
C = (unsigned(Rn) >= unsigned(b))
V = signed_overflow(Rn - b, width)What to watch for
- The optional shift is LSL, LSR or ASR, with amount 0–31. Omission means LSL #0. Shifts operate within 32 bits; ASR replicates the sign bit.
- SP is not an operand of this encoding. WZR/XZR reads as zero and discards writes.
- Arithmetic wraps at the selected width; it does not saturate.
- Encodes SUBS with Rd = WZR (register number 31). This alias adds no new architectural encoding.
Architectural details#
- Flags
- N is the result sign bit; Z is set for a zero result; C records no unsigned borrow; V records signed overflow. Incoming NZCV is not used.
- Destination
- Updates NZCV only. General-purpose registers and SP are unchanged.
- Encoding
01101011xx0xxxxxxxxxxxxxxxx11111- Operands
Wnread · 32 bitsWmread · 32 bitsamount (optional)read · unsigned
- Coverage
- 32/64-bit aliases of the selected base encodings. Extended-register and logical-immediate forms are outside this selection.
- Alias of
- SUBS_32_addsub_shift with the encoding constraints shown for this form.
- Shift amount
- 0 to 31.
Exception information & execution requirements
Complete exception conditions have not been imported.
The MRS snapshot supplies encoding and availability conditions, not a complete exception model.
Feature availability alone does not guarantee execution: OS state and execution-level controls also apply. Use the linked architecture documentation for the full exception conditions.
Sources & provenance#
Technical fields are imported from pinned upstream files. Explanations and explorer behavior are maintained separately.
Architectural references for this form
Arm · aarchmrs
- Revision
2026-03_rel- SHA-256
bf355d263eed08ef6b3e4e680e6bba3642fa7c3dd0be77ffb4783420041a0860- Terms
- BSD-3-Clause