O'Reilly logo

8051 Microcontrollers, 2nd Edition by Subrata Ghoshal

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required