3.3.10.1 Software Stack Examples
The software stack is manipulated using the PUSH and POP instructions. The PUSH and POP instructions are the equivalent of a MOV instruction with W15 as the Destination Pointer. For example, the contents of W0 can be pushed onto the stack by:
PUSH W0
This syntax is equivalent to:
MOV.L W0,[W15++]
The contents of the Top-of-Stack (TOS) can be returned to W0 by:
POP W0
This syntax is equivalent to:
MOV.L [--W15],W0
Figure 3-5 through Figure 3-8 illustrate examples of how the software stack is used. Figure 3-5 illustrates the software stack at device initialization. W15 has been initialized to 0x00004000. This example assumes the values, 0xAAAAAAAA and 0xBBBBBBBB, have been written to W0 and W1, respectively. In Figure 3-6, the stack is pushed for the first time, and the value contained in W0 is copied to the stack. W15 is automatically updated to point to the next available stack location (0x00004004). In Figure 3-7, the contents of W1 are pushed onto the stack. Figure 3-8 illustrates how the stack is popped and the Top-of-Stack value (previously pushed from W1) is written to W3.
PUSH
InstructionPUSH
InstructionPOP
Instruction