The Cortex-M0+ processor contains a set of registers, fast storage locations inside the processor itself (Figure 1.6.1). There are 13 general-purpose 32-bit registers (R0–R12) plus three special-purpose registers: SP (stack pointer, R13), LR (link register, R14), and PC (program counter, R15). All computation uses these registers; data must be loaded from memory first, processed, then written back.
Figure1.6.1.The Cortex-M0+ internal register file. The processor has thirteen general-purpose 32-bit registers (R0–R12) that hold operands and results during computation, plus three special-purpose registers: SP (stack pointer, R13), LR (link register for return addresses, R14), and PC (program counter, R15). Every GPIO write ultimately passes through this register file.
This pattern (fetch, decode, execute) repeats for every machine instruction (Figure 1.6.2). The processor fetches the instruction at the address in the PC, decodes what operation it encodes, executes it, then increments the PC.
Figure1.6.2.The instruction fetch-decode-execute cycle, illustrated for a GPIO write. On each cycle the CPU fetches the next instruction from flash at the address in PC, decodes its opcode, executes the operation (here a store to address 0x5000 0014), and advances PC.