From ARMwiki
(Difference between revisions)
Jump to: navigation, search
(Typo fix.)
(Added more descriptive title.)
Line 8: Line 8:
==ADD[S] : Addition==
ADD will add two values.
ADD will add two values.

Latest revision as of 06:57, 22 December 2011

Instruction ADD[S]
Function Addition
Category Data processing
ARM family All
Notes -


[edit] ADD[S] : Addition

ADD will add two values.

Operand 1 is a register, operand 2 can be a register, shifted register, or an immediate value (which may be shifted).

If the S bit is set (ADDS), the N and Z flags are set according to the result, and the C and V flags are set as follows: C if the result generated a carry (unsigned overflow); V if the result generated a signed overflow.

ADD is useful for basic addition. Use ADC to perform addition with the Carry flag considered.

[edit] Syntax

  ADD<suffix>  <dest>, <op 1>, <op 2>

[edit] Function

  dest = op_1 + op_2

[edit] Example

  ADD  R0, R0, R1    ; Adds R1 to R0
  ADD  R0, R0, #1    ; Increment R0 by one

[edit] Technical

The instruction bit pattern is as follows:

31 - 28 27 26 25 24 - 21 20 19 - 16 15 - 12 11 - 0
condition 0 0 I 0 1 0 0 S op_1 dest op_2/shift

Note: If the I bit is zero, and bits 4 and 7 are both one (with bits 5,6 zero), the instruction is UMULL, not ADD.

Personal tools