INTRODUCTION

FOUR-COMPONENT ADDRESSING

An example of four-component addressing (three-component logical address plus seg- ment base) is shown in Figure 1-15, and is described as follows:

Suppose you're writing a program to com- pute the payroll for a large corporation. This corporation has several groups of employees. Within each group there are multiple em- ployees, and for each employee certain data is kept in a record of information. Included in this data are the employee's address, social security number, and a wage code indicating how much that employee is being paid.

The task at hand is to select the wage code for a particular employee from the entire com- plex array of employee data. The 8088 can do it with a single instruction after the registers are set llP. Here's how: First, set the data segment register to the base of the employee data, set a base register such as BX to contain the offset number of bytes between the employee data base address and the start of the data that applies only to the desired group of employees. Next we set an index register such as SI to index to the desired employee's information within the given group of employees. Finally, we use an abso-

lute displacement value to point to the given employee's wage code within the employee's data record.

The single instruction MOV AX, [BX + SI + 12] then, will select the appropriate employee's wage code. To implement the same function with any other 8-bit microprocessor would require multiple instructions to build the address.

Symmetric Use of Memory

Another way these powerful addressing modes work is that memory locations can be used as either source or destination operand of most instructions. A single 8088 instruc- tion can perform a logical AND between the contents of a given memory address and an immediate data value, and store the results back in the same memory address. The equi- valent function would take multiple instructions on an 8-bit processor such as an 8080. It is as though you can treat any memory location as a CPU register for sim- ple arithmetic and logic operations. Follow- ing are several operations which can be performed directly on memory locations.

AND [memory address], 7FH OR [BX + SI + 12], lF80H ADD [memory address], 2500

PAYROLL

DATA

<

<

<

<

I DISPLACEMENT = 12 (WAGE CODE)

I INDEX

= SI (EMPLOYEE #N)

I BASE

= BX (EMPLOYEE GROUP)

ISEGMENT

= OS (PAYROLL SEGMENT)

MOVAX,[BX+SI+12];GETWAGE CODE

Figure 1-15. Four-Component Addressing Example

1-9

Page 20
Image 20
Intel 210200-002 manual Displacement = 12 Wage Code Index