adds

Add and Set Flags (Shifted Register)

ADDS <Wd>, <Wn>, <Wm> {, <shift> #<amount>}

Adds shifted register and updates flags.

Details

Add shifted 32-bit register to another and set condition flags. Adds the optionally shifted value of Wm to Wn, stores the result in Wd, and updates the N, Z, C, and V flags based on the result. AArch64-only instruction executing at any privilege level.

Pseudocode Operation

shifted_val ← Wm << amount
result ← Wn + shifted_val
Wd ← result
N ← result[31]
Z ← (result == 0)
C ← CarryOut(Wn, shifted_val)
V ← OverflowFrom(Wn, shifted_val)

Example

ADDS w0, w1, w2

Encoding

Binary Layout
0
0
1
01011
shift
0
Rm
imm6
Rn
Rd
 
Format Data Processing (Register)
Opcode 0x2B000000
Extension Base

Operands

  • Wd
    Destination 32-bit integer register
  • Wn
    First source / base 32-bit integer register
  • Wm
    Second source / offset 32-bit integer register

Reference (Arm A64 ISA)

Instruction Forms

Encoding Instruction ISA Bit pattern
0x2B200000 ADDS <Wd>, <Wn|WSP>, <Wm>{, <extend> {#<amount>}} A64 0 | 0 | 1 | 01011 | 00 | 1 | Rm | option | imm3 | Rn | Rd
0xAB200000 ADDS <Xd>, <Xn|SP>, <R><m>{, <extend> {#<amount>}} A64 1 | 0 | 1 | 01011 | 00 | 1 | Rm | option | imm3 | Rn | Rd
0x31000000 ADDS <Wd>, <Wn|WSP>, #<imm>{, <shift>} A64 0 | 0 | 1 | 100010 | sh | imm12 | Rn | Rd
0xB1000000 ADDS <Xd>, <Xn|SP>, #<imm>{, <shift>} A64 1 | 0 | 1 | 100010 | sh | imm12 | Rn | Rd
0x2B000000 ADDS <Wd>, <Wn>, <Wm>{, <shift> #<amount>} A64 0 | 0 | 1 | 01011 | shift | 0 | Rm | imm6 | Rn | Rd
0xAB000000 ADDS <Xd>, <Xn>, <Xm>{, <shift> #<amount>} A64 1 | 0 | 1 | 01011 | shift | 0 | Rm | imm6 | Rn | Rd

Description

Add (shifted register), setting flags, adds a register value and an optionally-shifted register value, and writes the result to the destination register. It updates the condition flags based on the result.

Operation

bits(datasize) result;
bits(datasize) operand1 = X[n, datasize];
bits(datasize) operand2 = ShiftReg(m, shift_type, shift_amount, datasize);
bits(4) nzcv;


(result, nzcv) = AddWithCarry(operand1, operand2, '0');

PSTATE.<N,Z,C,V> = nzcv;

X[d, datasize] = result;