Details of the CPU that assembler programmers must know

  • Registers:

    • The name of each register

    • The structure of each register

    • Reserved registers:

      • Some (general purpose) register can be designated for a special function

        E.g.: stack pointer frame pointer

  • Addressing modes:

    • Different ways to access the memory

      E.g.: indexing

The registers in the ARM CPU

The ARM processor contains 16 registers:   R0, R1, ..., R15

Register names: R0, R1, ..., R15
The registers R0, R1, ..., R10 are are general purpose registers
The registers R11, R12, R13, R14, R15 are "special" purpose registers

Structure of each register in the ARM processor
 

Structure of each register in the ARM processor:

 

Every register in ARM contains 32 bits

The general purpose registers of the ARM processor

Names of ARM's 11 general purpose registers (named r0, r1, ..., r10 - case insensitive)

  • R0 (or r0, the register names are not case senstive)
  • R1
  • R2
  • ...
  • R10
 

The use of the general purpose registers:

  • Use general purpose registers as temporal storage to:

    • Store the operands when you want to perform operations on data stored in memory variables

    • Store the result of computations

  • The program must fetch the value from a memory variable into a general register before it can perform an operation on the data

The special purpose registers of the ARM processor

 
  • R11 or the Frame Pointer (FP) register

      • The FP register is used to access the parameters and the local variables of a function

    Note:

    • We will learn to use the FP register when we discuss how to write function calls in assembler programming

The special purpose registers of the ARM processor

 
  • R12 or the Intra Procedure (IP) Call register

      • The IP register is used by the compiler as a "scratch" register to hold intermediate results of computations.

    We will not need to use the IP register in CS255.


  • R13 or the Stack Pointer (SP) register

      • The stack pointer (SP) register contains the address (= location) of the top of the system stack

    We will learn to use the SP register when we discuss how to write function calls in assembler programming

The special purpose registers of the ARM processor

 
  • R14 or the Link Register (LR)

      • The Link Register (SP) contains the return address of the calling program

    We will learn to use the LR register when we discuss how to write function calls in assembler programming


  • R15 or the Program Counter (PC)

      • The Program Counter (PC) contains the address of the next program instruction

    You have already learned the use of the Program Counter in this webpage (lecture): click here)

Recommended register names for assembler programming in ARM

                         Commonly used register name
    ARM register         in assembler programming 
   ---------------     -------------------------------
         R0                r0  or R0
         R1                r1  or R1
         R2                r2  or R2
         R3                r3  or R3
         R4                r4  or R4
         R5                r5  or R5
         R6                r6  or R6
         R7                r7  or R7
         R8                r8  or R8
         R9                r9  or R9
         R10               r10 or R10
         R11               fp  (frame pointer)
         R12               ip  (intra procedure)
         R13               sp  (stack pointer)
         R14               lr  (link register)
         R15               pc  (program counter)