Dump_Stack

Purpose: Display the contents of the 328P Stack. If the BIT_DR_DUMP_STACK bit in the system variable bDumpRegsFlags is TRUE, it will also be output after a DumpRegisters or a DumpRegs_Begin System Function call.
Assumes: Nothing.
Passed: Nothing.
Returns: Nothing.
Alters: Only the serial port output buffer; not even the FLAGs byte is changed
Example: 
.ORG 0x0F00

StackUsageExample:
   CALL    ADumpStack               ; Display before we do anything
   CALL    AStackAlloc50            ; The buffer pointer is returned in R31:R30
   CALL    ADumpStack
   MOVW    R24, R30                 ; R25:R24 receives the buffer address
   LDI     R22, '0'                 ; R22 is the value to write to the range
   LDI     R21, 0                   ; R21:R20 specifies the number of bytes to
   LDI     R20, 50                  ;  be set to the value in R22
   CALL    Ameminit                 ; Initialize the block of memory
   CALL    ADumpStack
   CALL    AStackFree50             ; Release the temporary stack-based buffer
   CALL    ADumpStack               ; Display the last time before returning
   RET
Notes:
>DF+ 0xF00 48   ; Verify that the FLASH block is unused
FLASH (program memory) contents:
:100F0000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF1
:100F1000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE1
:100F2000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFD1
:00000001FF
m>  ;Logon and write the iHex file with the code above to FLASH memory
m>:100F00000E947C300E9402300E947C30CF0160E35E
m>:100F100050E042E30E941B300E947C300E9403306C
m>:060F20000E947C300895E0
m>:00000001FF
m>:00000001FF
m>@ 0x0F00   ; Call the above subroutine from the command line
STACK contents:
08F0:                 07 07 82-31 37 30 02 31 0D 3A E9       ...170.1.:.
STACK contents:
08B0:                                         08 07 86               ...
08C0:  B9 3A 05 00 00 00 FF 08-48 09 00 00 80 02 80 01  .:......H.......
08D0:  36 50 21 00 2D E1 00 00-77 06 41 09 28 FF 04 00  6P!.-...w.A.(...
08E0:  00 00 00 00 00 40 21 00-00 00 10 0D 80 07 00 00  .....@!.........
08F0:  00 00 80 02 80 07 07 84-31 37 30 02 31 0D 3A E9  ........170.1.:.
STACK contents:
08B0:                                         08 07 8E               ...
08C0:  B9 3A 05 30 30 30 30 30-30 30 30 30 30 30 30 30  .:.0000000000000
08D0:  30 30 30 30 30 30 30 30-30 30 30 30 30 30 30 30  0000000000000000
08E0:  30 30 30 30 30 30 30 30-30 30 30 30 30 30 30 30  0000000000000000
08F0:  30 30 30 30 30 07 07 84-31 37 30 02 31 0D 3A E9  00000...170.1.:.
STACK contents:
08F0:                 08 07 92-31 37 30 02 31 0D 3A E9       ...170.1.:.
m>                                                                              
Also see:  The DumpRegisters and "R" system commands.