| Purpose: |
Save the contents of all 32 MCU registers on the stack, preserving
the contents of each of them as well as SREG (i.e., all FLAGS) using
a callable subroutine. |
| Assumes: |
The return address is contained in the first two bytes on the stack,
which means this subroutine was reached using a CALL, not a JUMP. |
| Passed: |
Nothing |
| Returns: |
Nothing |
| Alters: |
SPH, SPL, and 32 bytes of stack space |
| Example: |
SetSameColor:
LDI R30, I_PushAll ; Load the index of the PushAll routine
CALL ASoftVector ; Call into the System Call table
RCALL ASharedSetup ; Call the local shared setup routine
SSC_Loop:
ST Z+, R17 ; Write the LED color GREEN component
ST Z+, R18 ; Write the LED color RED component
ST Z+, R19 ; Write the LED color BLUE component
SBIW R26, 1 ; Decrement the remaining LED count WORD
BRNE ASSC_Loop ; Loop back unless R27:R26 reached zero
CALL ASharedOutput ; Call the local shared WS2812 output routine
LDI R30, I_PopAll ; Load the PopAll index
JMP ASoftVector ; Exit, restoring all registers used |
| Notes: |
The PushAll routine removes the return address from the stack, saves
it for the return, then PUSHes all Registers, preserving the flags.
When it returns, execution resumes at that saved return address,
with the stack now having stored all 32 Registers. |
|
Think of it as its name implies, with no Registers or flags changed,
as would happen if the CPU literally executed the 33 instructions,
"PUSH R31", "PUSH R30", ..., "PUSH R1", "PUSH R0", and "RET".
|
| Also see: |
PopAll |