SPRUI30H November 2015 – May 2024 DRA745 , DRA746 , DRA750 , DRA756
The ARP32 CPU has only one stack pointer and thus a unified stack is used for background and interrupt code. As a result, the programmer is responsible for maintaining a clean boundary of operations that modifies the stack pointer (for example, stack allocation and de-allocation for a function, context save onto stack via push/pop operations using the LDRF/STRF instructions).
Instructions/operations in the CPU that modify the stack pointer are designed so that an interrupt cannot disrupt the operations halfway through to completion. For example, a stack allocation and de-allocation for function can happen via the ADDucst16, SP instruction that atomically modifies the stack. The return address save while taking a CALL or retrieving the return address while executing a RET is also atomic, and cannot be interrupted. The LDRF/STRF instructions used for single or multiple pop and push are also uninterruptable. The ARP32 C/++ compiler uses these instructions to maintain the C/C++ stack and thus the sanity of the stack is always maintained.
Under certain scenarios, to save additional user context onto the stack, it is done via the LDRF/STRF instruction. LDRF/STRF modifies the stack pointer and hence results in the stack layout of a function to be not valid anymore. Hence, such additional context save/restore to the stack must happen at function boundaries only.
These considerations are important for assembly level programmers doing additional context save/restore (beyond what the ARP32 compiler does) and also to new custom instruction design for the ARP32 CPU if they depend on stack pointer relative operations.