8086 Addressing Mode: Microprocessors
8086 Addressing Mode: Microprocessors
University of Technology
Computer Engineering Department
2019 - 2020
8086 Addressing Mode
Introduction
x Program is a sequence of commands used to tell a microcomputer what to do.
x Each command in a program is an instruction
x Programs must always be coded in machine language before they can be executed by the
microprocessor.
x A program written in machine language is often referred to as machine code.
x Machine code is encoded using 0s and 1s
x A single machine language instruction can take up one or more bytes of code
x In assembly language, each instruction is described with alphanumeric symbols instead of
with 0s and 1s
x Instruction can be divided into two parts : its opcodeand operands
x Op-codeidentify the operation that is to be performed.
x Each opcode is assigned a unique letter combination called a mnemonic.
x Operands describe the data that are to be processed as the microprocessor carried out,
the operation specified by the opcode.
x For example, the move instruction is one of the instructions in the data transfer group of
the 8086 instruction set.
x Execution of this instruction transfers a byte or a word of data from a source location to a
destination location.
- 20 -
x Sreg : segment registers: CS, DS, ES, or SS. There is an exception: CS cannot be a
destination.
For register addressing modes, there is no need to compute the effective address. The operand
is in a register and to get the operand there is no memory access involved.
Example: Register Operands
MOV AX, BX ;mov reg16, reg16
ADD AX, SI ; add reg16, reg16
MOV DS, AX ; movSreg, reg16
Some rules in register addressing modes:
1. You may not specify CS as the destination operand.
Example: MOV CS, 02H –> wrong
2. Only one of the operands can be a segment register. You cannot move data from one segment
register to another with a single MOV instruction. To copy the value of CS to DS, you would have
to use some sequence like:
MOV DS,CS -> wrong
MOV AX, CS
MOV DS, AX -> the way we do it
3. You should never use the segment registers as data registers to hold arbitrary values. They
should only contain segment addresses.
- 21 -
for this purpose. Physical address can computed from a segment base address (SBA) and an
effective address (EA). SBA identifies the starting location of the segment in memory, and EA
represents the offset of the operand from the beginning of this segment of memory.
PA=SBA (segment): EA (offset)
PA=segment base: base + index + Displacement
MOV AL,DS:[8088H] ; move the contents of the memory location with offset 8088 orMOV
AL,[8088H] into register AL
MOV DS:[1234H],DL; stores the value in the DL register to memory location with
or MOV [1234H],DLoffset 1234H
- 22 -
By default, all displacement-only values provide offsets into the data segment. If you
want to provide an offset into a different segment, you must use a segment override prefix
before your address. For example, to access location 1234H in the extra segment (ES) you would
use an instruction of the form MOV AX,ES:[1234H]. Likewise, to access this location in the code
segment you would use the instruction MOV AX, CS:[1234H].
The [BX], [SI], and [DI] modes use the DS segment by default. The [BP] addressing mode uses the
stack segment (SS) by default. You can use the segment override prefix symbols if you wish to
access data in different segments. The following instructions demonstrate the use of these
overrides:
MOV AL, CS:[BX]
MOV AL, DS:[BP]
MOV AL, SS:[SI]
MOV AL, ES:[DI]
For example:
MOV SI, 1234H
MOV AL, [SI]
If SI contains 1234Hand DS contains 0200H the result produced by executing the instruction is
that the contents of the memory location at address:
PA = 02000H + 1234H
= 03234 are moved to the AX register.
- 23 -
For example if BX=1000, DS=0200, and AL=EDH, for the following instruction:
MOV [BX] + 1234H, AL
So it writes the contents of source operand AL (EDH) into the memory location 04234H. If BP is
used instead of BX, the calculation of the physical address is performed using the contents of the
stack segment (SS) register instead of DS. This permits access to data in the stack segment of
memory.
- 24 -
of the array, and the index register identifies the n coordinate. Simply changing the values in the
base and index registers permits access to any element in the array.
MOV AL, [BX+SI]
MOV AL, [BX+DI]
MOV AL, [BP+SI]
MOV AL, [BP+DI]
Suppose that BX contains 1000H and si contains 880H. Then the instruction
MOV AL,[BX][SI]
would load AL from location DS:1880h.
Likewise, if BP contains 1598h and DI contains 1004,
MOV AX,[BP+DI]
will load the 16 bits in AX from locations SS:259C and SS:259D.
The addressing modes that do not involve BP use the data segment by default. Those that have
BP as an operand use the stack segment by default.
- 25 -
Q: Compute the physical address for the specified operand in each of the following instructions.
The register contents and variable are as follows: (CS)=0A00H, (DS)=0B00H, (SS)=0D00H,
(SI)=0FF0H, (DI)=00B0H, (BP)=00EAH and (IP)=0000H, LIST=00F0H, AX=4020H, BX=2500H.
- 26 -
References
The 8088 and 8086 Microprocessors: Programming, Interfacing, Software, Hardware, and
Applications (4th Edition) 4th Edition by Walter A. Triebel (Author), Avtar Singh
8086 Microprocessors and its Applications Paperback – January 1, 2012 by A Nagoor Kani
The Intel Microprocessors 8086/8088, 80186/80188, 80286, 80386, 80486, Pentium, and Pentium
Pro Processor Architecture, Programming, and Inter- facing 5th Edition by Barry B. Bre