Overview Why you should care about the ISA Instruction sets in the Arm architecture Instruction set resources Simple sequential execution Registers in AArch64 - general-purpose registers Registers in AArch64 - other registers Registers in AArch64 - system registers Data processing - arithmetic and logic operations Data processing - floating point Data processing - bit manipulation Data processing - extension and saturation Data processing - format conversion Data processing - vector data Loads and stores Loads and stores - size Loads and stores - zero and sign extension Loads and stores - addressing Loads and stores - load pair and store pair Loads and stores - using floating point registers Program flow Program flow - loops and decisions Program flow - generating condition code Program flow - conditional select instructions Function calls Procedure Call Standard System calls Check your knowledge Related information Next steps
Extension and saturation
Sometimes it is necessary to convert data from one size to another. The SXTx
(sign extend) and UXTx
(unsign extend) instructions are available for this conversion. In this conversion, the x
determines the size of the data being extended, as shown in this figure:

In the first instruction, SXTB
, the B
means byte. It takes the bottom byte of W0
and sign extends it to 32 bits.
UXTH
is an unsigned extension of a halfword (H
). It takes the bottom 16 bits of W1
and zero extends it to 32 bits.
The first two examples have W
registers as a destination, meaning the extension is to 32 bits. The third example has an X
register, meaning the sign extension is to 64 bits.
Sub-register-sized integer data processing
Some instructions perform saturating arithmetic. This means that if the result is larger or smaller than the destination can hold, then the result is set to the largest or smallest value of the destination's integer range.
The data-processing instructions can efficiently handle 32-bit data and 64-bit data. In practice, you often see saturation instructions when handling sub-register calculations. Sub-register calculations are calculations of 16 bits or 8 bits. This table shows some examples of sub-register calculations in C and the generated assembler code:
C | Generated assembler |
uint32_t add32(uint32_t a, uint32_t b) |
add32: |
uint16_t uadd16(uint16_t a, uint16_t b) |
uadd16: |
int16_t sadd16(int16_t a, int16_t b) |
sadd16: |
In the first example in the table, the 32-bit addition maps onto W registers and therefore can be handled easily.
For the 16-bit examples in the table, an extra instruction is necessary. The third example in the table takes the 16-bit inputs, extends them to 32 bits, and then performs the addition. The sequence converts the 16-bit input to 32 bits, using:
SXTH W8,W1
Then, this instruction performs the addition and saturates the result to signed 16 bits:
ADD W0,W8,W0,SXTH
Adding , SXTH
to the end of the operand list of the ADD
operation causes the result to use saturating arithmetic. Because the destination is a W
register, the ADD
will saturate to a 16-bit integer range.