Embedded Systems/ARM Microprocessors

From Wikibooks, open books for an open world
Jump to: navigation, search

The ARM architecture is a widely used 32-bit RISC processor architecture. In fact, the ARM family accounts for about 75% of all 32-bit CPUs, and about 90% of all embedded 32-bit CPUs. ARM Limited licenses several popular microprocessor cores to many vendors (ARM does not sell physical microprocessors). Originally ARM stood for Advanced RISC Machines.

Some cores offered by ARM:

  • ARM7TDMI
  • ARM9
  • ARM11

Some examples of ARM based processors:

  • Intel X-Scale (PXA-255 and PXA-270), used in Palm PDAs
  • Philips LPC2000 family (ARM7TDMI-S core), LPC3000 family (ARM9 core)
  • Atmel AT91SAM7 (ARM7TDMI core)
  • ST Microelectronics STR710 (ARM7TDMI core)
  • Freescale MCIMX27 series (ARM9 core)

The lowest-cost ARM processors (in the LPC2000 series) have dropped below US$ 5 in ones, which is less than the cost of many 16-bit and 8-bit microprocessors.

Contents

[edit] Thumb calling convention

In ARM Thumb code, the 16 registers r0 - r15 typically have the same roles they have in all ARM code:

  • r0 - r3, called a1 - a4: argument/scratch/result registers.
  • r4 - r9, called v1 - v6: variables
  • r10, called sl: stack limit
  • r11, called fp: frame pointer (usually not used in Thumb code)
  • r12, called ip
  • r13, called sp: stack pointer
  • r14, called lr: link register
  • r15, called pc: the program counter

The standard C calling convention for ARM Thumb is:[1]

[edit] Subroutine-preserved registers

When the return address is placed in pc (r15), returning from the subroutine, the sp, fp, sl, and v1-v6 registers must contain the same values they did when the subroutine was called.

[edit] The stack

Every execution environment has a limit to how low in memory the stack can grow -- the "minimum sp".

In order to give interrupts (which may occur at any time) room to work, at every instant the memory between sp and the "minimum sp" must contain nothing of value to the executing program.

Systems where the application and its library support code is responsible for detecting and handling stack overflow are called "explicit stack limit". In such systems, the sl register must always point at least 256 bytes higher address than the "minimum sp".

[edit] Caller-preserved registers

A subroutine is free to clobber a1-a4, ip, and lr.

[edit] Return values

If the subroutine returns a simple value no bigger than one word, the value must be in a1 (r0).

If the subroutine returns a simple floating-point value, the value is encoded in a1; or {a1, a2}; or {a1, a2, a3}, whichever is sufficient to hold the full precision.

[edit] A typical subroutine

The simplest entry and exit sequence for Thumb functions is:[1]

PUSH {save-registers, lr} ; one-line entry sequence
; ... first part of function ...
BL thumb_sub   ;Must be in a space of +/- 4 MB 
; ... rest of function goes here, perhaps including other function calls
POP {save-registers, pc} ; one-line exit sequence

[edit] ARM calling convention

The standard C calling convention for ARM is:[2]


[edit] For further reading

  1. a b ARM. ARM Software Development Toolkit. 1997. Chapter 9: ARM Procedure Call Standard. Chapter 10: Thumb Procedure Call Standard.
  2. The "Procedure Call Standard for the ARM Architecture"
Personal tools
Namespaces
Variants
Actions
Navigation
Community
Toolbox
Sister projects
Print/export