0% found this document useful (0 votes)
19 views

Chapter 2 Addressing Modes 2009 V STD

This document discusses the different addressing modes of the 8086 processor. It describes 6 categories of addressing modes: register and immediate, memory, I/O, relative, and implied. The memory addressing modes are discussed in detail, including direct, register indirect, based, indexed, based and indexed, and string addressing modes. These addressing modes specify how the processor accesses and operates on data through instructions.

Uploaded by

Desalegn Dga
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views

Chapter 2 Addressing Modes 2009 V STD

This document discusses the different addressing modes of the 8086 processor. It describes 6 categories of addressing modes: register and immediate, memory, I/O, relative, and implied. The memory addressing modes are discussed in detail, including direct, register indirect, based, indexed, based and indexed, and string addressing modes. These addressing modes specify how the processor accesses and operates on data through instructions.

Uploaded by

Desalegn Dga
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 21

Chapter 2

8086 Addressing Mode

1
Outline
Programming Overview
Programming Language Levels
Addressing Modes
Register and Immediate
Memory
I/O
Relative
Implied

2
Programming Overview
Programming Language Levels
 There are three programming language levels that can be used to write programs
for a microcomputer
 Machine Language
 Assembly Language
 High Level Language

 Machine Language
 Sequence of binary codes
 Very difficult to understand and error prone
 To make it easier, HEX representation is used
 E.g. 1011 1000 B8
1001 0100 94
0000 0001 01
This is binary code for the 8086 instruction
MOV AX, 0194H
3
Programming Overview
Programming Language Levels…
Assembly language
 Makes programming easier
 A special program called assembler is required to translate it to
machine language
 Uses two-, three- or four-letter mnemonics to represent each
instruction type
 Mnemonics in assembly languages
 Initials or shortened form of the operation performed by the instruction
 Statements usually written in a standard form that consists of
four fields
LABEL OP CODE OPERAND COMMENT FIELD
FIELD FIELD FIELD
NEXT: ADD AL, 07H ;ADD
CORRECTION
FACTOR 4
Programming Overview
Programming Language Levels…
Assembly language…
 Label Field
 A symbol or group of symbols used to represent an address
which is not specifically known at the time the statement is
written
 Usually followed by a colon
 Not required in every statement, inserted where it is needed
 Op Code Field
 Contain mnemonic for the instruction to be performed
 E.g.LABEL
ADD is theOPmnemonic
CODE for the instruction
OPERAND to do addition
COMMENT FIELD
FIELD FIELD FIELD
NEXT: ADD AL, 07H ;ADD CORRECTION
FACTOR 5
Programming Overview
Programming Language Levels…
 Assembly language…
 Operand Field
 Contains the data, the memory address, the port address or the name of the register on
which the instruction is performed
 Operand is another name for data items to be acted up on by an instruction
 E.g. The figure below contain two operands 07H and AL
 Comment Field
 Starts with a semicolon, not part of the machine language program
 Reminds the function that an instruction or group of instructions performs in the
program
 To convert assembly to machine
 Manual: E.g. MOV AX, 0194  B8 94 01  BINARY
 Use assembler
LABEL OP CODE OPERAND COMMENT FIELD
FIELD FIELD FIELD
NEXT: ADD AL, 07H ;ADD CORRECTION
FACTOR 6
Addressing Modes
The different ways in which a processor can access
data that it operates on
Indicated in the instruction in assembly languages
E.g. Move instruction format
MOV destination, source
Copies a word or byte from the specified source location to the
specified destination location
Source – could be a number, register or memory location
Destination – can be register or memory (1 of 24 ways)
Both source and destination can’t be memory locations in an
instruction

7
Addressing Modes…
The 8086 has 12 basic addressing modes that can be
classified into five groups
Register and Immediate
Memory
I/O
Relative
Implied

8
Addressing Modes…
Immediate
8 or 16-bit data can be specified as part of the instruction
 E.g. MOV CX, 437BH
 Puts immediate hexadecimal number 437B in the 16-bit CX register
 E.g. MOV CL, 48H
 Puts immediate hexadecimal number 48 in the 8-bit CL register
 Immediate:
 Because the number to be loaded into CX/CL will be put in
memory locations immediately following the code for the move
instruction
Data part of the instruction
 Located in the memory addressed by CS and IP registers

9
Addressing Modes…
Register
A register is the source, destination or both of an
operand for the instruction
E.g. MOV CX, AX
 Copies contents of the AX register into 16-bit CX register
Any 16-bit register can be moved to any 16-bit register
Any 8-bit register can be moved to any 8-bit register
BUT register sizes must be the same
E.g. MOV BX, CH is ILLEGAL!

10
Addressing Modes…
Memory
Used to specify location of an operand in memory
8086 provides 17 different ways to access memory
To access data, Effective Address (EA) is added to
segment base address
The EA represents the displacement (offset) of the
operand from the segment base
EU calculates EA for an operand from the information
specified in the instruction
Depending on the way the EA is provided to EU
There are various memory addressing modes
11
Memory Addressing Modes…
Direct
The simplest memory addressing mode
EA is 16-bit number written directly in instruction
 E.g. 1
 MOV BL, [437AH]

 Copy contents of memory location at a displacement of 437AH from DS

base into BL
Direct
 Displacement of operand from segment base is specified
directly in the instruction

Unless BIU is told to add the displacement to some other


segment base , it is added to the data segment base DS
12
Memory Addressing Modes…
Direct…
 E.g. 2
 MOV BX, [437AH]
 Copies 16-bit word from memory to BX register
 Byte at displacement 437AH from DS is copied into BL
 Byte at displacement 437BH from DS is copied into BH
 8086 automatically identifies # of bytes to copy from the instruction
coding
 8086 stores low byte in lower address & high byte in higher address
 Direct addressing can also specify destination
 E.g. MOV [437AH], BX
 Copies contents of the BX register to two memory locations in the data

segment
 Contents of BL copied to memory location at displacement of 437AH

13
Memory Addressing Modes…
Register Indirect
EA is specified in either a pointer or index register
 Pointers
 Base Register (BX) & Base Pointer Register (BP)
 Index
 Source Index (SI) & Destination Index (DI)
The 20-bit physical address is computed using DS and EA
 E.g. MOV [DI], BX
 Copies content of BX into memory at offset DI from current DS
 E.g. If [DS] = 5004H, [DI] = 0020H and [BX] = 2456H,
 Then after MOV [DI], BX content of BX (2456H) is moved to
memory locations 50060H and 50061H
14
Memory Addressing Modes…
Based
EA is obtained by adding a displacement to contents
of BX or BP
The displacement can be signed 8-bit or unsigned 16-bit
DS and SS become segment registers for BX and BP
respectively
E.g. MOV AL, START[BX] or, MOV AL, [BX+START]
 EA is obtained by adding value of START and [BX]
Based addressing mode provides convenient way to
address structure which may be stored at different
places in memory
15
Memory Addressing Modes…
Indexed
EA is calculated by adding the unsigned 16-bit or sign-
extended 8 bit displacement and contents of SI or DI
E.g. MOV BH, START[SI]
 Moves contents of 20-bit address computed from
displacement START, SI and DS into BH
 The displacement START is provided by the programmer
using the assembler pseudo instruction
Indexed addressing can be used to access a single table,
where displacement is starting address of table
 SI/DI used as an index to access a particular element in
the table
16
Memory Addressing Modes…
Based and Indexed
EA is computed by adding base register (BX or BP), and
index register (SI or DI), and displacement
E.g. MOV ALPHA[SI][BX], CL
 If [BX] = 0200H, ALPHA = 08H, [SI] = 1000H, & [DS] = 3000H,
then 8-bit content of CL is moved to 20-bit physical address
31208H
Provides a convenient way for a subroutine to address
an array allocated on a stack
 BP loaded with offset in stack segment, SS
 Displacement, a value which is the difference b/n top of
the stack and the beginning of the array
17
Memory Addressing Modes…
String
Uses index registers
String instructions automatically assume
 SI to point to first byte/word of source string/operand
 DI to point to first byte/word of destination operand
Contents of SI & DI automatically incremented
 By clearing the direction flag to 0 by CLD instruction
Contents of SI & DI automatically decremented
 By setting the direction flag to 1 by STD instruction
Segment register for source is DS (can be overridden)
Segment register for destination is ES (cannot be
overridden)
18
Addressing Modes…
I/O
Memory mapped I/O uses memory addressing modes
Standard I/O uses port addressing modes

Two types of port addressing:


 Direct: port number is immediate 8-bit operand
 Allows fixed access to ports o to 255
 E.g. OUT 05H, AL
 outputs [AL] to 8-bit port 05H

 Indirect: port number is taken from DX


 Allows 64K 8-bit or 32K 16-bit ports
 E.g. IN AL, DX ;where [DX]=5040H
 Inputs the 8-bit content of port 5040

19
Addressing Modes…
Relative & Implied
Relative
Operand is specified as signed 8-bit displacement
relative to PC
 E.g. JNC START
Implied
Instructions using this mode have no operands
 E.g. CLC - clears carry flag to zero

20
End of Chapter 2

21

You might also like