= Stacks =
The stack is used like a stack of trays in a cafeteria. The last one put on is the first one taken off.
Here are some general tutorials on stacks in assembly programming:
Stacks
In the 68HC11, there is a stack pointer register that tells the machine where to store values in RAM. When you push something onto the stack, the variable gets stored and the stack pointer is changed to the new position. When you pop something off, the value is read, and the stack pointer is changed to the previous value on the stack.
Programmers need to be careful that they don't corrupt the stack, because it could make your program jump off to random locations.
The stack is used for 2 things:
subroutine parameters and temporary value storage.
Remember that if you are using it for temporary value storage inside a subroutine, you must pop it off before you return, otherwise the return instruction will use it as an address!
--
AlexHarford - 30 Jun 2006
Topic revision: r1 - 30 Jun 2006 - 22:51:38 -
AlexHarford