HomeARM CourseDay 8
DAY 8 · THE INSTRUCTION SET

Data-Processing Instructions — MOV, ADD, SUB & Logic

By EcrioniX · Updated Jun 6, 2026

Time to write real instructions. The data-processing instructions are the ALU's everyday work — moving, adding, subtracting and logic. Learn their one shared format and you can read most ARM assembly.

1. The one format to rule them all

Almost every data-processing instruction follows the same shape:

OP{cond}{S}  Rd,  Rn,  Operand2
ADD r0, r1, r2 ; r0 = r1 + r2 ADD r0, r1, #5 ; r0 = r1 + 5 (immediate Operand2) SUB r3, r3, #1 ; r3 = r3 - 1 (decrement)

2. The everyday instructions

GroupInstrMeaning
MoveMOV Rd, Op2Rd = Op2
MVN Rd, Op2Rd = NOT Op2 (bitwise invert)
ArithmeticADD Rd, Rn, Op2Rd = Rn + Op2
ADC Rd, Rn, Op2add with carry (for >32-bit)
SUB Rd, Rn, Op2Rd = Rn − Op2
RSB Rd, Rn, Op2reverse subtract: Op2 − Rn
LogicAND Rd, Rn, Op2bitwise AND
ORR Rd, Rn, Op2bitwise OR
EOR Rd, Rn, Op2bitwise XOR
BIC Rd, Rn, Op2bit clear: Rn AND (NOT Op2)

RSB (reverse subtract) exists because Operand2 is the flexible one — RSB r0, r1, #0 negates r1. BIC is the clean way to clear specific bits: BIC r0, r0, #0xF clears the low nibble.

3. The S suffix — set the flags

By default, arithmetic/logic instructions compute a result and leave the CPSR flags untouched. Add S and they update N, Z, C, V (the flags from Day 3):

ADD r0, r1, r2 ; result only — flags unchanged ADDS r0, r1, r2 ; result AND update N Z C V SUBS r3, r3, #1 ; decrement and set Z when it hits 0

That SUBS is the classic loop counter: subtract 1, and the Z flag tells you when you've reached zero. The S is what connects computation to decision-making (Day 11).

4. Compare instructions: CMP and TST

Often you want to test values without keeping a result — just set the flags. That's CMP and TST:

InstrDoesEquivalent to
CMP Rn, Op2flags from Rn − Op2SUBS, result discarded
CMN Rn, Op2flags from Rn + Op2ADDS, discarded
TST Rn, Op2flags from Rn AND Op2ANDS, discarded
TEQ Rn, Op2flags from Rn EOR Op2EORS, discarded
CMP r0, #10 ; compare r0 with 10 (sets Z if equal) TST r0, #1 ; test bit 0 (sets Z if it's clear)

5. Loading constants — a heads-up

Because an ARM instruction is only 32 bits, the immediate field can't hold every possible 32-bit constant — it stores a limited pattern. Small/round constants work in MOV; arbitrary ones use a PC-relative load from a literal pool (we'll see it in Day 10) or the MOV/MOVT pair. The assembler's handy LDR r0, =0x12345678 picks the best method for you.

✅ The mental model

One format — OP{cond}{S} Rd, Rn, Operand2 — covers move, add, subtract and logic. Operand2 is the flexible part. S turns a calculation into something the next branch can react to. CMP/TST set flags without keeping a result.

🎯 Day 8 takeaways

Quick check

  1. What's the difference between ADD and ADDS?
  2. Write one instruction to clear the lowest 4 bits of r0.
  3. Why use CMP instead of SUBS when you only want to compare?

FAQ

What are data-processing instructions?

The ALU operations on registers — MOV/MVN, ADD/ADC/SUB/RSB, AND/ORR/EOR/BIC, and the compares CMP/CMN/TST/TEQ.

What does the S suffix do?

It makes the instruction update the N Z C V flags from its result. Without S, the flags stay unchanged.

CMP vs SUB?

SUB keeps the result; CMP does the same subtraction but only sets flags (result discarded) for comparing before a branch.

Previous
← Day 7: The pipeline

← Back to the full course roadmap