C6.6.1 ADC Add with carry: Rd = Rn + Rm + C 31 30 29 28 27 26 25 24 23 22 21 20 16 15 14 13 12 11 10 9 5 4 0 sf 0 0 1 1 0 1 0 0 0 0 Rm 0 0 0 0 0 0 Rn Rd op S 32-bit variant Applies when sf = 0. ADC , , 64-bit variant Applies when sf = 1. ADC , , Decode for all variants of this encoding integer d = UInt(Rd); integer n = UInt(Rn); integer m = UInt(Rm); integer datasize = if sf == '1' then 64 else 32; boolean sub_op = (op == '1'); boolean setflags = (S == '1'); Assembler symbols Is the 32-bit name of the general-purpose destination register, encoded in the "Rd" field. Is the 32-bit name of the first general-purpose source register, encoded in the "Rn" field. Is the 32-bit name of the second general-purpose source register, encoded in the "Rm" field. Is the 64-bit name of the general-purpose destination register, encoded in the "Rd" field. Is the 64-bit name of the first general-purpose source register, encoded in the "Rn" field. Is the 64-bit name of the second general-purpose source register, encoded in the "Rm" field. Operation bits(datasize) result; bits(datasize) operand1 = X[n]; bits(datasize) operand2 = X[m]; bits(4) nzcv; if sub_op then operand2 = NOT(operand2); (result, nzcv) = AddWithCarry(operand1, operand2, PSTATE.C); if setflags then PSTATE. = nzcv; X[d] = result; C6-400 Copyright © 2013, 2014 ARM Limited. All rights reserved. ARM DDI 0487A.e Non-Confidential - Beta ID121714 C6 A64 Base Instruction Descriptions C6.6 Alphabetical list of instructions C6.6.2 ADCS Add with carry, setting the condition flags: Rd = Rn + Rm + C 31 30 29 28 27 26 25 24 23 22 21 20 16 15 14 13 12 11 10 9 5 4 0 sf 0 1 1 1 0 1 0 0 0 0 Rm 0 0 0 0 0 0 Rn Rd op S 32-bit variant Applies when sf = 0. ADCS , , 64-bit variant Applies when sf = 1. ADCS , , Decode for all variants of this encoding integer d = UInt(Rd); integer n = UInt(Rn); integer m = UInt(Rm); integer datasize = if sf == '1' then 64 else 32; boolean sub_op = (op == '1'); boolean setflags = (S == '1'); Assembler symbols Is the 32-bit name of the general-purpose destination register, encoded in the "Rd" field. Is the 32-bit name of the first general-purpose source register, encoded in the "Rn" field. Is the 32-bit name of the second general-purpose source register, encoded in the "Rm" field. Is the 64-bit name of the general-purpose destination register, encoded in the "Rd" field. Is the 64-bit name of the first general-purpose source register, encoded in the "Rn" field. Is the 64-bit name of the second general-purpose source register, encoded in the "Rm" field. Operation bits(datasize) result; bits(datasize) operand1 = X[n]; bits(datasize) operand2 = X[m]; bits(4) nzcv; if sub_op then operand2 = NOT(operand2); (result, nzcv) = AddWithCarry(operand1, operand2, PSTATE.C); if setflags then PSTATE. = nzcv; X[d] = result; ARM DDI 0487A.e Copyright © 2013, 2014 ARM Limited. All rights reserved. C6-401 ID121714 Non-Confidential - Beta C6 A64 Base Instruction Descriptions C6.6 Alphabetical list of instructions C6.6.3 ADD (extended register) Add (extended register): Rd = Rn + LSL(extend(Rm), amount) 31 30 29 28 27 26 25 24 23 22 21 20 16 15 13 12 10 9 5 4 0 sf 0 0 0 1 0 1 1 0 0 1 Rm option imm3 Rn Rd op S 32-bit variant Applies when sf = 0. ADD , , {, {#}} 64-bit variant Applies when sf = 1. ADD , , {, {#}} Decode for all variants of this encoding integer d = UInt(Rd); integer n = UInt(Rn); integer m = UInt(Rm); integer datasize = if sf == '1' then 64 else 32; boolean sub_op = (op == '1'); boolean setflags = (S == '1'); ExtendType extend_type = DecodeRegExtend(option); integer shift = UInt(imm3); if shift > 4 then ReservedValue(); Assembler symbols Is the 32-bit name of the destination general-purpose register or stack pointer, encoded in the "Rd" field. Is the 32-bit name of the first source general-purpose register or stack pointer, encoded in the "Rn" field. Is the 32-bit name of the second general-purpose source register, encoded in the "Rm" field. Is the 64-bit name of the destination general-purpose register or stack pointer, encoded in the "Rd" field. Is the 64-bit name of the first source general-purpose register or stack pointer, encoded in the "Rn" field. Is a width specifier, encoded in the "option" field. It can have the following values: W when option = 00x W when option = 010 X when option = x11 W when option = 10x W when option = 110 Is the number [0-30] of the second general-purpose source register or the name ZR (31), encoded in the "Rm" field. C6-402 Copyright © 2013, 2014 ARM Limited. All rights reserved. ARM DDI 0487A.e Non-Confidential - Beta ID121714 C6 A64 Base Instruction Descriptions C6.6 Alphabetical list of instructions For the 32-bit variant: is the extension to be applied to the second source operand, encoded in the "option" field. It can have the following values: UXTB when option = 000 UXTH when option = 001 LSL|UXTW when option = 010 UXTX when option = 011 SXTB when option = 100 SXTH when option = 101 SXTW when option = 110 SXTX when option = 111 If "Rd" or "Rn" is '11111' (WSP) and "option" is '010' then LSL is preferred, but may be omitted when "imm3" is '000'. In all other cases is required and must be UXTW when "option" is '010'. For the 64-bit variant: is the extension to be applied to the second source operand, encoded in the "option" field. It can have the following values: UXTB when option = 000 UXTH when option = 001 UXTW when option = 010 LSL|UXTX when option = 011 SXTB when option = 100 SXTH when option = 101 SXTW when option = 110 SXTX when option = 111 If "Rd" or "Rn" is '11111' (SP) and "option" is '011' then LSL is preferred, but may be omitted when "imm3" is '000'. In all other cases is required and must be UXTX when "option" is '011'. Is the left shift amount to be applied after extension in the range 0 to 4, defaulting to 0, encoded in the "imm3" field. It must be absent when is absent, is required when is LSL, and is optional when is present but not LSL. Operation bits(datasize) result; bits(datasize) operand1 = if n == 31 then SP[] else X[n]; bits(datasize) operand2 = ExtendReg(m, extend_type, shift); bits(4) nzcv; bit carry_in; if sub_op then operand2 = NOT(operand2); carry_in = '1'; else carry_in = '0'; (result, nzcv) = AddWithCarry(operand1, operand2, carry_in); if setflags then PSTATE. = nzcv; if d == 31 && !setflags then SP[] = result; else X[d] = result; ARM DDI 0487A.e Copyright © 2013, 2014 ARM Limited. All rights reserved. C6-403 ID121714 Non-Confidential - Beta C6 A64 Base Instruction Descriptions C6.6 Alphabetical list of instructions C6.6.4 ADD (immediate) Add (immediate): Rd = Rn + shift(imm) This instruction is used by the alias MOV (to/from SP). See the Alias conditions table for details of when each alias is preferred. 31 30 29 28 27 26 25 24 23 22 21 10 9 5 4 0 sf 0 0 1 0 0 0 1 shift imm12 Rn Rd op S 32-bit variant Applies when sf = 0. ADD , , #{, } 64-bit variant Applies when sf = 1. ADD , , #{, } Decode for all variants of this encoding integer d = UInt(Rd); integer n = UInt(Rn); integer datasize = if sf == '1' then 64 else 32; boolean sub_op = (op == '1'); boolean setflags = (S == '1'); bits(datasize) imm; case shift of when '00' imm = ZeroExtend(imm12, datasize); when '01' imm = ZeroExtend(imm12 : Zeros(12), datasize); when '1x' ReservedValue(); Alias conditions Alias is preferred when MOV (to/from SP) shift == '00' && imm12 == '000000000000' && (Rd == '11111' || Rn == '11111') Assembler symbols Is the 32-bit name of the destination general-purpose register or stack pointer, encoded in the "Rd" field. Is the 32-bit name of the source general-purpose register or stack pointer, encoded in the "Rn" field. Is the 64-bit name of the destination general-purpose register or stack pointer, encoded in the "Rd" field. Is the 64-bit name of the source general-purpose register or stack pointer, encoded in the "Rn" field. Is an unsigned immediate, in the range 0 to 4095, encoded in the "imm12" field. C6-404 Copyright © 2013, 2014 ARM Limited. All rights reserved. ARM DDI 0487A.e Non-Confidential - Beta ID121714 C6 A64 Base Instruction Descriptions C6.6 Alphabetical list of instructions Is the optional left shift to apply to the immediate, defaulting to LSL #0 and encoded in the "shift" field. It can have the following values: LSL #0 when shift = 00 LSL #12 when shift = 01 It is RESERVED when shift = 1x. Operation bits(datasize) result; bits(datasize) operand1 = if n == 31 then SP[] else X[n]; bits(datasize) operand2 = imm; bits(4) nzcv; bit carry_in; if sub_op then operand2 = NOT(operand2); carry_in = '1'; else carry_in = '0'; (result, nzcv) = AddWithCarry(operand1, operand2, carry_in); if setflags then PSTATE. = nzcv; if d == 31 && !setflags then SP[] = result; else X[d] = result; ARM DDI 0487A.e Copyright © 2013, 2014 ARM Limited. All rights reserved. C6-405 ID121714 Non-Confidential - Beta C6 A64 Base Instruction Descriptions C6.6 Alphabetical list of instructions C6.6.5 ADD (shifted register) Add (shifted register): Rd = Rn + shift(Rm, amount) 31 30 29 28 27 26 25 24 23 22 21 20 16 15 10 9 5 4 0 sf 0 0 0 1 0 1 1 shift 0 Rm imm6 Rn Rd op S 32-bit variant Applies when sf = 0. ADD , , {, #} 64-bit variant Applies when sf = 1. ADD , , {, #} Decode for all variants of this encoding integer d = UInt(Rd); integer n = UInt(Rn); integer m = UInt(Rm); integer datasize = if sf == '1' then 64 else 32; boolean sub_op = (op == '1'); boolean setflags = (S == '1'); if shift == '11' then ReservedValue(); if sf == '0' && imm6<5> == '1' then ReservedValue(); ShiftType shift_type = DecodeShift(shift); integer shift_amount = UInt(imm6); Assembler symbols Is the 32-bit name of the general-purpose destination register, encoded in the "Rd" field. Is the 32-bit name of the first general-purpose source register, encoded in the "Rn" field. Is the 32-bit name of the second general-purpose source register, encoded in the "Rm" field. Is the 64-bit name of the general-purpose destination register, encoded in the "Rd" field. Is the 64-bit name of the first general-purpose source register, encoded in the "Rn" field. Is the 64-bit name of the second general-purpose source register, encoded in the "Rm" field. Is the optional shift type to be applied to the second source operand, defaulting to LSL and encoded in the "shift" field. It can have the following values: LSL when shift = 00 LSR when shift = 01 ASR when shift = 10 It is RESERVED when shift = 11. For the 32-bit variant: is the shift amount, in the range 0 to 31, defaulting to 0 and encoded in the "imm6" field. C6-406 Copyright © 2013, 2014 ARM Limited. All rights reserved. ARM DDI 0487A.e Non-Confidential - Beta ID121714 C6 A64 Base Instruction Descriptions C6.6 Alphabetical list of instructions For the 64-bit variant: is the shift amount, in the range 0 to 63, defaulting to 0 and encoded in the "imm6" field. Operation bits(datasize) result; bits(datasize) operand1 = X[n]; bits(datasize) operand2 = ShiftReg(m, shift_type, shift_amount); bits(4) nzcv; bit carry_in; if sub_op then operand2 = NOT(operand2); carry_in = '1'; else carry_in = '0'; (result, nzcv) = AddWithCarry(operand1, operand2, carry_in); if setflags then PSTATE. = nzcv; X[d] = result; ARM DDI 0487A.e Copyright © 2013, 2014 ARM Limited. All rights reserved. C6-407 ID121714 Non-Confidential - Beta C6 A64 Base Instruction Descriptions C6.6 Alphabetical list of instructions C6.6.6 ADDS (extended register) Add (extended register), setting the condition flags: Rd = Rn + LSL(extend(Rm), amount) This instruction is used by the alias CMN (extended register). See the Alias conditions table for details of when each alias is preferred. 31 30 29 28 27 26 25 24 23 22 21 20 16 15 13 12 10 9 5 4 0 sf 0 1 0 1 0 1 1 0 0 1 Rm option imm3 Rn Rd op S 32-bit variant Applies when sf = 0. ADDS , , {, {#}} 64-bit variant Applies when sf = 1. ADDS , , {, {#}} Decode for all variants of this encoding integer d = UInt(Rd); integer n = UInt(Rn); integer m = UInt(Rm); integer datasize = if sf == '1' then 64 else 32; boolean sub_op = (op == '1'); boolean setflags = (S == '1'); ExtendType extend_type = DecodeRegExtend(option); integer shift = UInt(imm3); if shift > 4 then ReservedValue(); Alias conditions Alias is preferred when CMN (extended Rd == '11111' register) Assembler symbols Is the 32-bit name of the general-purpose destination register, encoded in the "Rd" field. Is the 32-bit name of the first source general-purpose register or stack pointer, encoded in the "Rn" field. Is the 32-bit name of the second general-purpose source register, encoded in the "Rm" field. Is the 64-bit name of the general-purpose destination register, encoded in the "Rd" field. Is the 64-bit name of the first source general-purpose register or stack pointer, encoded in the "Rn" field. Is a width specifier, encoded in the "option" field. It can have the following values: W when option = 00x C6-408 Copyright © 2013, 2014 ARM Limited. All rights reserved. ARM DDI 0487A.e Non-Confidential - Beta ID121714 C6 A64 Base Instruction Descriptions C6.6 Alphabetical list of instructions W when option = 010 X when option = x11 W when option = 10x W when option = 110 Is the number [0-30] of the second general-purpose source register or the name ZR (31), encoded in the "Rm" field. For the 32-bit variant: is the extension to be applied to the second source operand, encoded in the "option" field. It can have the following values: UXTB when option = 000 UXTH when option = 001 LSL|UXTW when option = 010 UXTX when option = 011 SXTB when option = 100 SXTH when option = 101 SXTW when option = 110 SXTX when option = 111 If "Rn" is '11111' (WSP) and "option" is '010' then LSL is preferred, but may be omitted when "imm3" is '000'. In all other cases is required and must be UXTW when "option" is '010'. For the 64-bit variant: is the extension to be applied to the second source operand, encoded in the "option" field. It can have the following values: UXTB when option = 000 UXTH when option = 001 UXTW when option = 010 LSL|UXTX when option = 011 SXTB when option = 100 SXTH when option = 101 SXTW when option = 110 SXTX when option = 111 If "Rn" is '11111' (SP) and "option" is '011' then LSL is preferred, but may be omitted when "imm3" is '000'. In all other cases is required and must be UXTX when "option" is '011'. Is the left shift amount to be applied after extension in the range 0 to 4, defaulting to 0, encoded in the "imm3" field. It must be absent when is absent, is required when is LSL, and is optional when is present but not LSL. Operation bits(datasize) result; bits(datasize) operand1 = if n == 31 then SP[] else X[n]; bits(datasize) operand2 = ExtendReg(m, extend_type, shift); bits(4) nzcv; bit carry_in; if sub_op then operand2 = NOT(operand2); carry_in = '1'; else carry_in = '0'; (result, nzcv) = AddWithCarry(operand1, operand2, carry_in); if setflags then ARM DDI 0487A.e Copyright © 2013, 2014 ARM Limited. All rights reserved. C6-409 ID121714 Non-Confidential - Beta C6 A64 Base Instruction Descriptions C6.6 Alphabetical list of instructions PSTATE. = nzcv; if d == 31 && !setflags then SP[] = result; else X[d] = result; C6-410 Copyright © 2013, 2014 ARM Limited. All rights reserved. ARM DDI 0487A.e Non-Confidential - Beta ID121714 C6 A64 Base Instruction Descriptions C6.6 Alphabetical list of instructions C6.6.7 ADDS (immediate) Add (immediate), setting the condition flags: Rd = Rn + shift(imm) This instruction is used by the alias CMN (immediate). See the Alias conditions table for details of when each alias is preferred. 31 30 29 28 27 26 25 24 23 22 21 10 9 5 4 0 sf 0 1 1 0 0 0 1 shift imm12 Rn Rd op S 32-bit variant Applies when sf = 0. ADDS , , #{, } 64-bit variant Applies when sf = 1. ADDS , , #{, } Decode for all variants of this encoding integer d = UInt(Rd); integer n = UInt(Rn); integer datasize = if sf == '1' then 64 else 32; boolean sub_op = (op == '1'); boolean setflags = (S == '1'); bits(datasize) imm; case shift of when '00' imm = ZeroExtend(imm12, datasize); when '01' imm = ZeroExtend(imm12 : Zeros(12), datasize); when '1x' ReservedValue(); Alias conditions Alias is preferred when CMN (immediate) Rd == '11111' Assembler symbols Is the 32-bit name of the general-purpose destination register, encoded in the "Rd" field. Is the 32-bit name of the source general-purpose register or stack pointer, encoded in the "Rn" field. Is the 64-bit name of the general-purpose destination register, encoded in the "Rd" field. Is the 64-bit name of the source general-purpose register or stack pointer, encoded in the "Rn" field. Is an unsigned immediate, in the range 0 to 4095, encoded in the "imm12" field. Is the optional left shift to apply to the immediate, defaulting to LSL #0 and encoded in the "shift" field. It can have the following values: LSL #0 when shift = 00 ARM DDI 0487A.e Copyright © 2013, 2014 ARM Limited. All rights reserved. C6-411 ID121714 Non-Confidential - Beta C6 A64 Base Instruction Descriptions C6.6 Alphabetical list of instructions LSL #12 when shift = 01 It is RESERVED when shift = 1x. Operation bits(datasize) result; bits(datasize) operand1 = if n == 31 then SP[] else X[n]; bits(datasize) operand2 = imm; bits(4) nzcv; bit carry_in; if sub_op then operand2 = NOT(operand2); carry_in = '1'; else carry_in = '0'; (result, nzcv) = AddWithCarry(operand1, operand2, carry_in); if setflags then PSTATE. = nzcv; if d == 31 && !setflags then SP[] = result; else X[d] = result; C6-412 Copyright © 2013, 2014 ARM Limited. All rights reserved. ARM DDI 0487A.e Non-Confidential - Beta ID121714 C6 A64 Base Instruction Descriptions C6.6 Alphabetical list of instructions C6.6.8 ADDS (shifted register) Add (shifted register), setting the condition flags: Rd = Rn + shift(Rm, amount) This instruction is used by the alias CMN (shifted register). See the Alias conditions table for details of when each alias is preferred. 31 30 29 28 27 26 25 24 23 22 21 20 16 15 10 9 5 4 0 sf 0 1 0 1 0 1 1 shift 0 Rm imm6 Rn Rd op S 32-bit variant Applies when sf = 0. ADDS , , {, #} 64-bit variant Applies when sf = 1. ADDS , , {, #} Decode for all variants of this encoding integer d = UInt(Rd); integer n = UInt(Rn); integer m = UInt(Rm); integer datasize = if sf == '1' then 64 else 32; boolean sub_op = (op == '1'); boolean setflags = (S == '1'); if shift == '11' then ReservedValue(); if sf == '0' && imm6<5> == '1' then ReservedValue(); ShiftType shift_type = DecodeShift(shift); integer shift_amount = UInt(imm6); Alias conditions Alias is preferred when CMN (shifted Rd == '11111' register) Assembler symbols Is the 32-bit name of the general-purpose destination register, encoded in the "Rd" field. Is the 32-bit name of the first general-purpose source register, encoded in the "Rn" field. Is the 32-bit name of the second general-purpose source register, encoded in the "Rm" field. Is the 64-bit name of the general-purpose destination register, encoded in the "Rd" field. Is the 64-bit name of the first general-purpose source register, encoded in the "Rn" field. Is the 64-bit name of the second general-purpose source register, encoded in the "Rm" field. ARM DDI 0487A.e Copyright © 2013, 2014 ARM Limited. All rights reserved. C6-413 ID121714 Non-Confidential - Beta C6 A64 Base Instruction Descriptions C6.6 Alphabetical list of instructions Is the optional shift type to be applied to the second source operand, defaulting to LSL and encoded in the "shift" field. It can have the following values: LSL when shift = 00 LSR when shift = 01 ASR when shift = 10 It is RESERVED when shift = 11. For the 32-bit variant: is the shift amount, in the range 0 to 31, defaulting to 0 and encoded in the "imm6" field. For the 64-bit variant: is the shift amount, in the range 0 to 63, defaulting to 0 and encoded in the "imm6" field. Operation bits(datasize) result; bits(datasize) operand1 = X[n]; bits(datasize) operand2 = ShiftReg(m, shift_type, shift_amount); bits(4) nzcv; bit carry_in; if sub_op then operand2 = NOT(operand2); carry_in = '1'; else carry_in = '0'; (result, nzcv) = AddWithCarry(operand1, operand2, carry_in); if setflags then PSTATE. = nzcv; X[d] = result; C6-414 Copyright © 2013, 2014 ARM Limited. All rights reserved. ARM DDI 0487A.e Non-Confidential - Beta ID121714 C6 A64 Base Instruction Descriptions C6.6 Alphabetical list of instructions C6.6.9 ADR Address of label at a PC-relative offset 31 30 29 28 27 26 25 24 23 5 4 0 0 immlo 1 0 0 0 0 immhi Rd op Literal variant ADR ,