A reference for the ARM Cortex-M4 assembly instructions used throughout the Morph-RT context switching implementation. Not exhaustive, scoped to what actually appears in context_switch.s and startup.s.

OpExampleWhat it doesC analog
ldrldr r0, =SCB_ICSRLoad a value or address into a registeruint32_t r0 = SCB_ICSR;
strstr r1, [r0]Store a register’s value to a memory address*r0 = r1;
movmov r2, #0Copy a value directly into a registerr2 = 0;
orrorr r0, r0, #2Logical OR. Set specific bits without touching othersr0 = r0 | 2;
blbl scheduler_switch_contextBranch with link. Call a function, save return address in lrscheduler_switch_context();
bxbx lrBranch to address in a register. Used to return from a function or exceptionreturn;
cbzcbz r1, switch_logicCompare and branch if zero. Jump if register is NULLif (r1 == 0) goto switch_logic;
mrsmrs r0, pspRead a special-purpose CPU register into a general registerr0 = PSP;
msrmsr psp, r0Write a general register into a special-purpose CPU registerPSP = r0;
stmdbstmdb r0!, {r4-r11, lr}Store multiple registers to memory, decrementing address before each write (push onto descending stack). ! writes the final address back to r0*(--r0) = r4; ... *(--r0) = lr;
ldmialdmia r0!, {r4-r11, lr}Load multiple registers from memory, incrementing address after each read (pop from stack). ! writes the final address back to r0r4 = *(r0++); ... lr = *(r0++);
pushpush {r7, lr}Push registers onto the current stack, decrement SPstack[--sp] = r7; stack[--sp] = lr;
poppop {r4-r11, lr}Pop registers off the current stack, increment SPlr = stack[sp++]; ... r4 = stack[sp++];
cpsidcpsid iDisable interrupts globally (sets PRIMASK)__disable_irq();
cpsiecpsie iEnable interrupts globally (clears PRIMASK)__enable_irq();
dsbdsbData Synchronization Barrier. Ensure all memory writes complete before continuing__DSB();
isbisbInstruction Synchronization Barrier. Flush the pipeline, force re-fetch of instructions__ISB();
udivudiv r2, r1, r0Unsigned integer divide. r2 = r1 / r0r2 = r1 / r0;
subsub r2, r2, #1Subtract. r2 = r2 - 1r2 = r2 - 1;