5.9 Numeric literals

armasm syntax assembly and GNU syntax assembly provide different methods for specifying some types of numeric literal.

Implicit shift operations

armasm syntax assembly allows immediate values with an implicit shift operation. For example, the MOVK instruction takes a 16-bit operand with an optional left shift. armasm accepts the instruction MOVK x1, #0x40000, converting the operand automatically to MOVK x1, #0x4, LSL #16.

GNU syntax assembly expects immediate values to be presented as encoded. The instruction MOVK x1, #0x40000 results in the following message: error: immediate must be an integer in range [0, 65535].

Hexadecimal literals

armasm syntax assembly provides two methods for specifying hexadecimal literals, the prefixes "&" and "0x".

For example, the following are equivalent:

ADD     r1, #0xAF
ADD     r1, #&AF

GNU syntax assembly only supports the "0x" prefix for specifying hexadecimal literals. Convert any "&" prefixes to "0x".

n_base-n-digits format

armasm syntax assembly lets you specify numeric literals using the following format:


For example:

  • 2_1101 is the binary literal 1101 (13 in decimal).
  • 8_27 is the octal literal 27 (23 in decimal).

GNU syntax assembly does not support the n_base-n-digits format. Convert all instances to a supported numeric literal form.

For example, you could convert:

ADD     r1, #2_1101


ADD     r1, #13


ADD     r1, #0xD
Non-ConfidentialPDF file icon PDF version100068_0609_00_en
Copyright © 2014–2017 Arm Limited (or its affiliates). All rights reserved.