Page 72 - ARM 64 Bit Assembly Language
P. 72
Load/store and branch instructions 57
Negative: This bit is set to one if the signed result of an operation is negative, and set to zero
if the result is positive or zero.
Zero: This bit is set to one if the result of an operation is zero, and set to zero if the result is
non-zero.
Carry: This bit is set to one if an add operation results in a carry out of the most significant
bit, or if a subtract operation results in a borrow. For shift operations, this flag is set to
the last bit shifted out by the shifter.
oVerflow: For addition and subtraction, this flag is set if a signed overflow occurred.
3.2.4 Link register
The procedure link register, x30, is used to hold the return address for subroutines. Certain
instructions cause the program counter to be copied to the link register, then the program
counter is loaded with a new address. These branch-and-link instructions are briefly covered
in Section 3.5 and in more detail in Section 5.4. The link register could theoretically be used
as a scratch register, but its contents are modified by hardware when a subroutine is called, in
order to save the correct return address. Using x30 as a general-purpose register is dangerous
and is strongly discouraged.
3.2.5 Stack pointer
The program stack was introduced in Section 1.4. The stack pointer, sp, is used to hold the
address where the stack ends. This is commonly referred to as the top of the stack, although
on most systems the stack grows downwards and the stack pointer really refers to the low-
est address in the stack. The address where the stack ends may change when registers are
pushed onto the stack, or when temporary local variables (automatic variables) are allocated
or deleted. The use of the stack for storing automatic variables is described in Chapter 5.The
stack pointer can only be modified or read by a small set of instructions.
3.2.6 Zero register
The zero register, zr, can be referred to as a 64-bit register, xzr, or a 32-bit register, wzr.It
always has the value zero. Most instructions can use the zero register as an operand, even as
a destination register. If this is the case, the instruction will not change the destination regis-
ter. However, it can still have side effects, including updating the PSTATE flags based on the
ALU operation and incrementing a register in pre-indexed or post-indexed addressing. The
zero register cannot always be used as an operand. It shares the same binary encoding with the
stack pointer register, sp, which is the value 31. Some instructions can access the zero regis-
ter, while others can access the stack pointer.