CHAPTER 9Stack Operations
9.1 INTRODUCTION
In our programming exercises, we have been reserving data statically in memory sections such as .rodata, .data and .bss. This means that once memory is allocated for a data element, it remains reserved throughout the program execution. However, sometimes a program may require memory temporarily, only for the duration of a subroutine. For example, to save registers at the beginning of a subroutine and restore them before returning, or to store the local variables in a subroutine. Once the subroutine returns, this temporary storage can be made available to other subroutines.
To understand the memory usage pattern, let us take a sequence of subroutine calls: the main function calls subA and subB. subA, in turn, calls subA1 and ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access