Task Stack

A project log for M0S - CortexM0 RTOS in 1024 bytes

Full blown RTOS written in Thumb ARM assembly language to fit in 1024 bytes

dumitru.stamadumitru.stama 12/03/2016 at 06:440 Comments

Here is how a task's stack looks like when the scheduler activates :

First part (top 8 registers in the diagram) is automatically saved by the interrupt handler, the remaining 8 registers are saved by the following code :

stmia r1!,{r4-r7}  // store r4-r7 and increment r1 for each one
mov r2,r8          // r2, r3, r4 and r5 are already saved
mov r3,r9          // so we can use them as intermediary regs
mov r4,r10
mov r5,r11
stmia r1!,{r2-r5}  // registers are in order on stack r4...r11