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 O’Reilly online learning.

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