First page Back Continue Last page Overview Text

Notes:


Some processors have dedicated memory in the CPU for the stack. Most processors, however, use a section of general purpose RAM memory. For these processors a pointer must be initialized to point to the memory space used for the stack. Care must be taken not to overflow the stack or overwrite a return address saved on the stack.

Rather than simply hoping for the best, we can check periodically to make sure that we have not overflowed the stack, and branch to an appropriate error handling routine if we have. Obviously, there is additional time involved executing the instructions to check for stack overflow, so there the programmer must trade off between safety and efficiency. The storage space associated with the extra instructions can be reduced (slightly) and the code made more readable by implementing the instructions within a subroutine.