Abstract

This chapter focuses on the registers used in the Cortex-M3 processor and their functions. The Cortex-M3 has registers R0–R15 and a number of special registers. R0–R12 are general purpose, but some of the 16-bit Thumb instructions can only access R0–R7 (low registers), whereas 32-bit Thumb-2 instructions can access all these registers. Special registers have predefined functions and can only be accessed by special register access instructions. In the Cortex-M3 processor, R13 is the stack pointer and it is of two types: main stack pointer (MSP) and process stack pointer (PSP). The former is the default stack pointer, used by the OS kernel, exception handlers, and all application codes that require privileged access, and the latter is used by the base-level application code when not running an exception handler. It is not necessary to use both stack pointers. Simple applications can rely purely on the MSP. The stack pointers are used for accessing stack memory processes such as PUSH and POP. The Cortex-M3 uses a full-descending stack arrangement. Therefore, the stack pointer decrements when new data is stored in the stack. PUSH and POP are usually used to save register contents to stack memory at the start of a subroutine and then restore the registers from stack at the end of the subroutine.

Full Text
Published version (Free)

Talk to us

Join us for a 30 min session where you can share your feedback and ask us any queries you have

Schedule a call