Guide to Assembly Language Programming in Linux

Chapter 12: More on Procedures

Overview

We introduced the basics of the assembly language procedures in the last chapter. We have discussed the two parameter passing mechanisms used in invoking procedures. However, we did not discuss how local variables, declared in a procedure, are handled in the assembly language. We start this chapter with a discussion of this topic.

Although short assembly language programs can be stored in a single file, real application programs are likely to be broken into several files, called modules. The issues involved in writing and assembling multiple source program modules are discussed in detail.

Most high-level languages use procedures that receive a fixed number of arguments. However, languages like C support variable number of arguments. By means of an example, we look at how we can pass a variable number of arguments to a procedure. It turns out that passing a variable number of arguments is straightforward using the stack. The last section provides a summary of the chapter.

Introduction

This chapter builds on the material presented in the last chapter. Specifically, we focus on three issues: handling local variables, splitting a program into multiple modules, and passing a variable number of arguments.

In the last chapter, we did not consider how local variables can be used in a procedure. To focus our discussion, let us look at the following C code:

      int compute(int a, int b)      {         int  ...

UNLIMITED FREE
ACCESS
TO THE WORLD'S BEST IDEAS

SUBMIT
Already a GlobalSpec user? Log in.

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.

Customize Your GlobalSpec Experience

Category: Programmable Logic Controllers (PLC)
Finish!
Privacy Policy

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.