Page 71 - ARM 64 Bit Assembly Language
P. 71
56 Chapter 3
Figure 3.3: Fields in the PSTATE register.
Registers R0-R7 are used for passing arguments when calling a procedure or function Reg-
isters R9-R15 are scratch registers and can be used at any time because no assumptions are
made about what they contain. They are called scratch registers because they are useful for
holding temporary results of calculations. Registers R16-R29 can also be used as scratch
registers, but their contents must be saved before they are used, and restored to their original
contents before the procedure exits.
Some of the registers have alternate names. For example, X16 is also known as IP0.Mostof
these alternate names are only of interest to people writing compilers and operating systems.
However, two of these registers are of interest to all AArch64 programmers.
3.2.2 Frame pointer
The frame pointer, x29, is used by high-level language compilers to track the current stack
frame. This register can be helpful when the program is running under a debugger, and can
sometimes help the compiler to generate more efficient code for returning from a subroutine.
The GNU C compiler can be instructed to use x29 as a general-purpose register by using the
fomit-frame-pointer command line option. The use of x29 as the frame pointer is a
programming convention. Some instructions (e.g. branches) implicitly modify the program
counter, the link register, and even the stack pointer, so they are considered to be hardware
special registers. As far as the hardware is concerned, the frame pointer is exactly the same
as the other general-purpose registers, but AArch64 programmers use it for the frame pointer
because of the ABI.
3.2.3 PSTATE register
The PSTATE register contains bits that indicate the status of the current process, including in-
formation about the results of previous operations. Fig. 3.3 shows all of its bits. The dashed
lines indicate unused space that may be reserved for future AArch64 architectural extensions.
The PSTATE register is actually a collection of independent fields, most of which are only
used by the operating system. User programs make use of the first four bits, N, Z, C, and V.
These are referred to as the condition flags field. Most instructions can modify these flags, and
later instructions can use the flags to control their operation. Their meaning is as follows: