Behold the Stack, Part IV

To simulate stack storage in a C program, you need to emulate the four basic parts of a stack:

  1. The stack storage
  2. A stack pointer
  3. A function to push a value onto the stack
  4. A function to pop a value from the stack

Further, you need to implement controls that prevent a stack overflow or underflow. And you can get real fancy, but those four items are the basics.
Continue reading

Behold the Stack, Part II

At the lowest programming level, you encounter machine code. This is the language of the processor itself. Machine code directs the processor to do things, such as read from or write to memory, store data, perform math, and other tasks. And if you dare to program a processor directly, you’ll encounter something called the stack pointer register.
Continue reading