8
SUBROUTINES AND STACK
CHAPTER OBJECTIVES
Usage of subroutines makes the program size optimum and offers a scope of its modular development. During the use of subroutines, stack is used for related data storage. In this chapter, the reader is introduced to these two aspects and related instructions details. After completion of the chapter, the reader should be able to understand
- How subroutines and stack work.
- When and how to incorporate subroutines.
- Functioning of instructions like LCALL, ACALL, RET, PUSH and POP.
- Importance and usage of stack and stack pointer (SP).
8.1 | Need of Subroutines
Imagine a situation where an 8051 microcontroller is to read thermal values of three different locations of a furnace using three ports, say P0, P1 ...
Get 8051 Microcontrollers, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.