Singapore Polytechnic
School of Electrical & Electronic Engineering
Microprocessor Systems (ET0708)
Experiment 2: The Addressing Modes of the 8086 Microprocessor
Objectives
• Learn about the different addressing modes for the 8086 microprocessor
• Use appropriate addressing modes to write assembly language programs
Introduction
1. The Programming Model
To program the microprocessor you must be familiar with its working registers or the
Programming Model, shown in Figure 1. Note that the registers are placed in logical groups
– the data group, the pointer & index group, status & control flags and the segment group.
AX AH AL Accumulator
BX BH BL Base
CX CH CL Count Status Flags
DX DH DL Data
Data Group Status & Control Flags
SP Stack pointer
BP Base pointer
ES Extra
SI Source index
CS Code
DI Destination index DS Data
IP Instruction pointer SS Stack
Pointer & Index Group Segment Group
Figure 1: 8086 Programming Model
Note that each of the data group can be accessed as a byte or a word. Data registers are
normally used for storing temporary results that will be acted on by subsequent instructions.
The pointer and index group are all 16-bit registers and are used as memory pointers.
Register IP is used to point to the next instruction to be fetched and executed.
Six of the flags of the 16-bit flag register are status indicators, used for recording specific
characteristics of the result of an arithmetic or logical instruction. The others are for
interrupt and other uses.
The segment registers are used to determine the memory address output by the CPU when it
is accessing memory. The 8086 organizes memory in sets of segments. Memory is
ET0708 EXPT 2
addressed using a two-component address that consists of a 16-bit segment value and a 16-
bit offset (forming the physical address). Each segment is a linear contiguous sequence of
64K (216) bytes of memory in the processor’s address space.
2. Addressing Modes
An assembly instruction is made up of an operation code (op-code) and zero, one or two
operands. The op-code identifies the operation to be performed while the operands identify
the source and destination of the data operated on. The operands can specify a CPU register,
a memory location in one of the memory segments, or an I/O port.
The 8086 uses eight categories of addressing modes to specify operands (the part of the
assembly language instruction that supplies the data or tells the processor where to get the
data). Two addressing modes are provided for instructions that operate on register or
immediate operands; six modes are provided to specify the location of an operand in a
memory segment.
Addressing Mode Examples
Addressing Mode Example
Register mov ax, dx
Immediate mov ax, 1234h
Direct mov ax, [5000h]
Register Indirect mov ax, [bx]
Indexed mov ax, [si]
Register Relative mov ax, [bx]4
Based Indexed mov ax, [bx][si]
Relative Based Indexed mov ax, [bx][si]4
Procedure
1. From the desktop, double click on batch file icon msp to extract lab exercise files to
the D:\msp folder.
2. Next, launch the EMU8086 program by double clicking the emu8086 icon. Close the
welcome window and at the emu8086 main window, select open from the toolbar.
Browse to D:\msp and open Lab2.asm. The source file Lab2.asm should be displayed
in the main window.
3. Select compile from the toolbar to assemble the program. The compiler will report
errors or warnings if compilation is unsuccessful. After successful compilation save
file as D:\Lab2.com. Next, click on the emulator button to load the compiled file and
open the emulator.
Refer to Experiment 1 for information on the emulator window.
4. Before performing single stepping, note the current values of the following registers:
Code Segment register CS __________
Data Segment register DS __________
Instruction Pointer IP __________
ET0708 EXPT 2
5. To perform single stepping, click on the single step button, or use F8.
6. Step through the program Lab2 and observe the data movement between the registers
and memory. Write down the results, i.e. contents of registers and/or memory that are
affected by each of the following instructions. Indicate the addressing mode used for
each instruction.
(Do you remember how to view memory locations to check the contents in memory?)
Instruction Addressing Mode Results in
Registers or
Destination Source Memory
mov ax, 1234h Register Immediate AX = 1234H
mov bx, 040ch
mov dx, ax
mov cx, 5678h
inc ch X
dec cl X
xchg ax, cx
mov [0410h], ah
mov [0411h], cl
mov cx, [0410h]
mov si, 0410h
inc [si] X
mov ax, [si]
mov [bx+6], dx
dec [bx+4] X
xchg [si]3, cl
mov [si+4], dx
mov bx, 3
mov dx, [bx+si]
dec [bx+si+2] X
7. What is the size of the program (including RET) and where in memory is the program
stored?
_____________________________________________________________________
8. Which are the memory locations in the data segment area used to store the data?
___________________________________________________________________
ET0708 EXPT 2
9. Exercise 1:
Write an assembly language program to fill memory locations 0700:1000H to
0700:1004H with the same value 1AH. Which addressing mode would you use?
Compile the program and perform single step to ensure that your program is working.
Exercise 2:
Using appropriate addressing modes, write an assembly language program to move a
block consisting of 5 bytes of data starting from memory location 0700:0400H. The
destination is to be at addressing starting from 0700:0420H.
Compile your program and run single step debugging to ensure that your program is
working. You have to preload the five memory locations from 0700:0400H with some
data before debugging the program.
ET0708 EXPT 2