Chapter 3 Addressing Modes: Asst. Prof. Dr. Gazi Erkan BOSTANCI
Chapter 3 Addressing Modes: Asst. Prof. Dr. Gazi Erkan BOSTANCI
Slides are mainly based on The Intel Microprocessors by Barry B. Brey, 2008
• Efficient software development for the MP requires a complete
familiarity with the addressing modes employed by each instruction.
• MOV (move data) instruction will be used to describe the data
addressing modes.
• CALL and JUMP instructions will be used to describe program memory
addressing modes.
• PUSH and POP instructions will be used to describe the operation of
the stack memory.
Data Addressing Modes
• Because the MOV instruction is a very common and flexible
instruction, it provides a basis for the explanation of the data-
addressing modes.
• Figure below illustrates the MOV instruction and defines the direction
of data flow.
• The source is to the right and the destination is to the left, next to the
opcode MOV. (An opcode, or operation code, tells the microprocessor
which operation to perform.)
• This direction of flow, which is applied to all instructions, is awkward
at first.
• We naturally assume that things move from left to right, whereas here they
move from right to left.
• The MOV AX, BX instruction transfers the word contents of the source
register (BX) into the destination register (AX). The source never
changes, but the destination always changes.
• It is crucial to remember that a MOV instruction always copies the
source data into the destination. The MOV never actually picks up the
data and moves it.
• Also, note the flag register remains unaffected by most data transfer
instructions. The source and destination are often called operands.
• Figure below shows all possible variations of the data-addressing
modes using the MOV instruction. This illustration helps to show how
each data-addressing mode is formulated with the MOV instruction
and also serves as a reference on data-addressing modes.
• Register addressing: Register addressing transfers a copy of a byte or
word from the source register or contents of a memory location to
the destination register or memory location.
• Example: The MOV CX, DX instruction copies the word-sized contents of
register DX into register CX.
• Immediate addressing: Immediate addressing transfers the source, an
immediate byte, word, doubleword, or quadword of data, into the
destination register or memory location.
• Example: The MOV AL, 22H instruction copies a byte-sized 22H into register
AL
• Direct addressing: Direct addressing moves a byte or word between a
memory location and a register. The instruction set does not support
a memory-to memory transfer, except with the MOVS instruction.
• Example: The MOV CX, LIST instruction copies the word-sized contents of
memory location LIST into register CX.
• Register indirect addressing: Register indirect addressing transfers a
byte or word between a register and a memory location addressed by
an index or base register. The index and base registers are BP, BX, DI,
and SI.
• Example: The MOV AX, [BX] instruction copies the word-sized data from the
data segment offset address indexed by BX into register AX.
• Base-plus-index addressing: Base-plus-index addressing transfers a
byte or word between a register and the memory location addressed
by a base register (BP or BX) plus an index register (DI or SI).
• Example: The MOV [BX+DI], CL instruction copies the byte-sized contents of
register CL into the data segment memory location addressed by BX plus DI.
• Register relative addressing: Register relative addressing moves a byte or
word between a register and the memory location addressed by an index
or base register plus a displacement.
• Example: MOV AX,[BX+4] or MOV AX, ARRAY[BX].
• The first instruction loads AX from the data segment address formed by BX plus 4.
The second instruction loads AX from the data segment memory location in ARRAY
plus the contents of BX.
• Base relative-plus-index addressing Base relative-plus-index addressing
transfers a byte or word between a register and the memory location
addressed by a base and an index register plus a displacement.
• Example: MOV AX, ARRAY[BX+DI] or MOV AX, [BX+DI+4].
• These instructions load AX from a data segment memory location. The first
instruction uses an address formed by adding ARRAY, BX, and DI and the second by
adding BX, DI, and 4.
Program Memory Addressing Modes
• Program memory-addressing modes, used with the JMP (jump) and
CALL instructions, consist of three distinct forms:
• direct,
• relative,
• and indirect.
• This section introduces these three addressing forms, using the JMP
instruction to illustrate their operation.
Direct Program Memory Addressing
• Direct program memory addressing is what many early microprocessors
used for all jumps and calls.
• Direct program memory addressing is also used in high-level languages,
such as the GOTO instruction.
• The microprocessor uses this form of addressing, but not as often as
relative and indirect program memory addressing are used.
• The instructions for direct program memory addressing store the address
with the opcode. For example, if a program jumps to memory location
10000H for the next instruction, the address (10000H) is stored following
the opcode in the memory.
• Figure shows the direct intersegment JMP instruction and the 4 bytes required to
store the address 10000H.
• This JMP instruction loads CS with 1000H and IP with 0000H to jump to memory
location 10000H for the next instruction.