PushAll and PopAll demonstration

The "Q" command accepts no parameters; just 'Q'.

This very simple command uses the DumpRegs_Begin system command to demonstrate how the PushAll and PopAll system commands work.

Actually, do this first:

>r   ; This is the default format:

 10   32   54   76   98  1110 1312 1514 1716 1918 2120 2322 2524 2726 2928 3130  SP    SREG
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- --------
0000 077D 0908 0828-0004 0000 0000 4000-0000 0001 5201 0000-0000 0230 0280 3166 08F5 Ithsvnzc
>r = 0x7A

 10   32   54   76   98  1110 1312 1514 1716 1918 2120 2322 2524 2726 2928 3130  SP    SREG
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- --------
0000 2724 090B 0B28-0004 0000 0000 4000-0000 0001 5208 3D20-3D20 0230 0280 3166 08F5 Ithsvnzc
>r

 10   32   54   76   98  1110 1312 1514 1716 1918 2120 2322 2524 2726 2928 3130  SP  RetAdd   SREG
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ------ --------
0000 0BB8 090C 0C28-0004 0000 0000 4000-0000 0001 5201 0000-0000 0230 0280 3166 08F5  694E  Ithsvnzc
STACK contents:
08F0:                 31 34 A7-31 37 30 02 31 0D 3A C6       14.170.1.:.
>                                                                                                    
The "R = 0x7A" command above added the BIT_DR_INCL_RETADD and BIT_DR_DUMP_STACK bits to the default value of 42 to the bDumpRegsFlags system BYTE. It causes the Return Address column and the Stack to be output whenever a DumpRegisters or DumpRegs_Begin system function is executed.

So, after that little bunny trail, here is the "Q" command and its output:

>q

 10   32   54   76   98  1110 1312 1514 1716 1918 2120 2322 2524 2726 2928 3130  SP  RetAdd   SREG
---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ------ --------
0000 05FF 0990 FF28-0004 0000 0000 4000-0001 007E 5101 0000-0000 0230 0280 3165 08F3  6946  Ithsvnzc
STACK contents:
08F0:           31 34 A3 34 A1-31 37 30 02 31 0D 3A C6     14.4.170.1.:.
0000 05FF 0990 FF28-0004 0000 0000 4000-0001 007E 5101 0000-0000 0230 0280 3165 08D3  694A  Ithsvnzc
STACK contents:
08D0:           31 34 A5 00 00-FF 05 90 09 28 FF 04 00     14.......(...
08E0:  00 00 00 00 00 40 01 00-7E 00 01 51 00 00 00 00  .....@..~..Q....
08F0:  30 02 80 02 65 31 34 A1-31 37 30 02 31 0D 3A C6  0...e14.170.1.:.
0000 05FF 0990 FF28-0004 0000 0000 4000-0001 007E 5101 0000-0000 0230 0280 3165 08F7  626E  Ithsvnzc
STACK contents:
08F0:                       31-31 37 30 02 31 0D 3A C6         1170.1.:.
>                                                                                                    
This is the MIRTOS source code which generated the output for the "Q" command above.
Case_Q:                   ; Bytes Clocks
   RCALL   ACase_Q_Start     ;  2  3   Since PopAll() requires a JUMP, this way
   RJMP    ADumpRegs_Begin   ;  2  2    allows the return to come back here

Case_Q_Start:
   RCALL   ADumpRegs_Begin   ;  2  3   This is just a demonstration of PushAll
   RCALL   APushAll          ;  2  3    and PopAll, using DumpRegs() to show
   RCALL   ADumpRegs_Begin   ;  2  3    all registers before, during and after
   RJMP    APopAll           ;  2  3    PushAll and PopAll
An amazing amount of insight can be gleaned from examining the output along with the source code -- specifically the stack pointer, the return address, and the stack contents resulting from each call. Note also that the FLAGS byte (SREG) is unchanged throughout, as one would expect when simply using the AVR PUSH and POP assembly instructions.

See also:
  The Registers command and the "DumpRegs_Begin" system function.