Hello, in this lesson we are going to talk about the arm processor modes. 1
The arm v8 architecture has two modes, aarch32 and aarch64. 2
In aarch64 mode, 3
we can run 64-bit operating system and 64-bit programs. The aarch32 mode allows compatible execution of older code 4
. 5
In this course, we will only focus on aarch64 mode. 6
So, in this mode, we have 31 64-bit general purpose registers available to use, called x0 through x30 7
. 8
The pstate register indicates the state of the current process and the status of the previous operations. 9
For example, is the result of the previous operation negative? or if the overflow occurs, etc. 10
Then we have stack pointer which is used for stack operation. The use of the stack is described later in this course. 11
. 12
Zero register always holds the value zero. If we use zero register as a destination register, 13
which means we want to save data in this register, 14
it will not be changed. 15
And note that stack pointer and zero register share the same encoding 16
which means some instructions can access stack pointer, whereas others will access zero register. 17
The program counter or pc holds the address of the next instruction to be executed. 18
Let’s take a look at an example. 19
Suppose the pc holds the address of the instruction at memory address C. The processor will fetch the instruction in this location 20
from memory and execute, 21
it also increments pc by 4 to make it point to the next instruction. 22
Each arm instruction is 32bits or 4 bytes long. So the program counter is incremented by 4. 23
Then it will fetch the instruction from the address 10 and execute, increments pc by 4. 24
And it repeats the same process over and over. 25
By default, the cpu just executes instructions sequentially as shown in this example. 26
There are some instructions which can access program counter which means they can modify the value of pc 27
to make the cpu branch to a new location. 28
We will see those instructions later in this course. 29
OK, let's move on to the last part of this lesson. 30
the general-purpose registers. 31
They are used for data transfer, arithmetic and logical operations, etc. 32
As you can see, there are quite a few registers here. Registers in the first column are the 64-bit registers 33
. 34
The second column are the 32-bit registers which are the lower half of the 64-bit registers. 35
We will use x0 as an example. Other registers follow the same pattern. 36
The x0 is the 64-bit register. 37
If we want to access the 64 bits of the register, we simply use x0. 38
If we want to access the lower 32 bits of x0 register, we can use the name w0. 39
And note that register x30, also known as link register, is used to hold the return address for procedures 40
. 41
And register x29 is used for frame pointer in some cases, 42
so before we go into detail about these registers, you can use all the other registers in your project. 43
OK. 44
That is the introduction to the process modes 45
I'll see you in the next lesson.