[MMT] [HTML 2.0 Checked!]

2.2.4 Stack Pointer

[image]

As mentioned earlier, the a7 address register is made up of two stacks each of which have a register called the stack pointer, which holds the address of the top of the stack. The stack is neccessary if the flow of a program is changed by an interupt or a subroutine call. Essential information to continue the running of the program is store on the stack i.e. the program counter and the status register. To add to the stack an item is pushed and to take from it an item is popped and all actions take place relative to the stack pointer.

[image]

The original stack position.

[image]

The result of a push on the stack

[image]

The result of a pop on the stack

The two stack pointers are; The CPU controls which stack is being used at one time. An assembly program can only manipulate the user stack pointer for subroutine calls.
[back][contents][next]