Fork me on GitHub

A. ARM Programmer’s Model

A simplified ARM programmer’s model is provided in this section.

Register File. In the ARM processor, 16 general purpose registers are available at any time. Each register is 32-bit in size. The registers are referred to as rn, where n represents the register index. All instructions treat registers r0 to r13 equally. Any operation that can be performed on r0 can be performed equally well on registers r1 to r13. But r14 and r15 are assigned special functions by the processor. r15 is the program counter, and contains the address of the next instruction to be fetched. r14 is the link register, and used to store the return address, when a subroutine is invoked.

[Tip] Tip

Though register r13 has no special function assigned to by the processor, conventionally operating systems use it as the stack pointer, and thus points to the top of the stack.

Current Program Status Register. The Current Program Status Register (cpsr) is a dedicated 32-bit register, that contains the following fields.

  1. Condition Flags
  2. Interrupt Masks
  3. Processor Mode
  4. Processor State

Only the condition flags field will be used in the examples provided in this tutorial. And hence only the condition flags will be elaborated here.

The condition flags indicates the various conditions that occur while performing arithmetic and logical operations. The various condition flags and their meaning are given in the following table.

Table A.1. Condition Flags

Flag Meaning

Carry C

Operation caused a carry.

Overflow O

Operation caused an overflow.

Zero Z

Operation resulted in 0.

Negative N

Operation resulted in a negative value.