Keil Logo

Numeric literals

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_0616_01_en
Copyright © 2014–2021 Arm Limited or its affiliates. All rights reserved. 
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.