Chapter 7. THE STACK

The stack is a portion of memory which is shared with the operating system. It is used by programs for communication with subprograms, for temporary storage, and when making system calls. It is called the stack because it has a "last stored first retrieved" policy. It is in fact an example of the data structure that is called a stack. Because it is used by the operating system as well as by the programmer, it must be used responsibly. Misusing the stack is a very easy way to crash a program, or the whole system, if the operating system is unprotected.

Push and Pop Operations

The following figure shows the stack and the ESP register. This register has the job of keeping track of the stack. It does this by holding the address ...

Get Linux Assembly Language Programming now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.