Uploaded by Warpmellow ™

4-Addressing Modes

advertisement
ADDRESSING MODES
&
Instruction set
8086 Microprocessor
Introduction
Program
A set of instructions written to solve
a problem.
Instruction
Directions which a microprocessor
follows to execute a task or part of a
task.
Computer language
High Level
Machine Language
 Binary bits
Low Level
Assembly Language
 English Alphabets
 ‘Mnemonics’
 Assembler
Mnemonics  Machine
2
Language
8086 Microprocessor
Introduction
Program is a set of instructions written to solve a problem. Instructions are
the directions which a microprocessor follows to execute a task or part of a
task. Broadly, computer language can be divided into two parts as highlevel language and low level language. Low level language are machine
specific. Low level language can be further divided into machine language
and assembly language.
Machine language is the only language which a machine can understand.
Instructions in this language are written in binary bits as a specific bit
pattern. The computer interprets this bit pattern as an instruction to
perform a particular task. The entire program is a sequence of binary
numbers. This is a machine-friendly language but not user friendly.
Debugging is another problem associated with machine language.
To overcome these problems, programmers develop another way in which
instructions are written in English alphabets. This new language is known
as Assembly language. The instructions in this language are termed
mnemonics. As microprocessor can only understand the machine
language so mnemonics are translated into machine language either
manually or by a program known as assembler.
Efficient software development for the microprocessor requires a complete
familiarity with the instruction set, their format and addressing modes. Here
in this chapter, we will focus on the addressing modes and instructions
formats of microprocessor 8086.
3
ADDRESSING MODES
8086 Microprocessor
Addressing Modes
Every instruction of a program has to operate on a data.
The different ways in which a source operand is denoted
in an instruction are known as addressing modes.
5
8086 Microprocessor
1.
Register Addressing
Addressing Modes
The instruction will specify the name of the
register which holds the data to be operated by
the instruction. IP will not be used in this mode.
Example:
MOV CL, DH
The content of 8-bit register DH is moved to
another 8-bit register CL
(CL)  (DH)
6
8086 Microprocessor
1.
Register Addressing
2.
Immediate Addressing
Addressing Modes
In immediate addressing mode, an 8-bit or 16-bit
data is specified as part of the instruction
Example:
MOV DL, 08H
The 8-bit data (08H) given in the instruction is
moved to DL
(DL)  08H
MOV AX, 0A9FH
The 16-bit data (0A9FH) given in the instruction is
moved to AX register
(AX)  0A9FH
7
8086 Microprocessor
Addressing Modes : Memory Access
Offset Value (16 bits)
Segment Register (16 bits)
0000
Adder
Physical Address (20 Bits)
8
8086 Microprocessor
Addressing Modes : Memory Access
20 Address lines  8086 can address up to
220 = 1M bytes of memory
However, the largest register is only 16 bits
Physical Address will have to be calculated
Physical Address : Actual address of a byte in
memory. i.e. the value which goes out onto the
address bus.
Memory Address represented in the form –
Seg : Offset (Eg - 89AB:F012)
Each time the processor wants to access
memory, it takes the contents of a segment
register, shifts it one hexadecimal place to the
left (same as multiplying by 1610), then add the
required offset to form the 20- bit address
16 bytes of
contiguous memory
89AB : F012  89AB  89AB0 (Paragraph to byte  89AB x 10 = 89AB0)
F012  0F012 (Offset is already in byte unit)
+ ------98AC2 (The absolute address)
9
8086 Microprocessor
1.
Register Addressing
2.
Immediate Addressing
3.
Direct Addressing
Addressing Modes
In the direct addressing mode, a 16 bit memory
address(offset) is directly specified in the
Instruction.
Example:
MOV
AX, [1354H]
Effective Address EA = 10H *DS + 1354H
Here data resides in a memory location in the
Data segment.
The data present in EA is moved to AX.
11
8086 Microprocessor
Addressing Modes
1.
Register Addressing
2.
Immediate Addressing
In Register indirect addressing, name of the
register which holds the offset address will be
specified in the instruction.
3.
Direct Addressing
BX, DI and SI.
4.
Register Indirect Addressing
The default segment is either DS or ES.
Example:
MOV AX, [BX]
Operations:
EA = 10H * DS + [BX]
The data
location.
is
present
in
the
memory
12
8086 Microprocessor
Addressing Modes
1.
Register Addressing
2.
Immediate Addressing
3.
Direct Addressing
4.
Register Indirect Addressing
5.
Indexed Addressing
Offset of the operand is stored in index registers.
DS & ES are the default segment registers.
Example:
MOV AX, [SI]
EA = 10H * DS +[SI].
13
8086 Microprocessor
Addressing Modes
1.
Register Addressing
2.
Immediate Addressing
3.
Direct Addressing
In this addressing mode, the data is available at an
effective address formed by adding an 8-bit or 16-bit
displacement with the content of any one of the register
BX, BP, SI & DI in the default(either in DS & ES)
segment.
4.
Register Indirect Addressing
Example:
5.
Indexed Addressing
MOV AX, 50H [BX]
6.
Register Relative Addressing
EA = 10H * DS + 50H +[BX]
14
8086 Microprocessor
Addressing Modes
1.
Register Addressing
2.
Immediate Addressing
3.
Direct Addressing
4.
Register Indirect Addressing
5.
Indexed Addressing
6.
Register Relative Addressing
7.
Based Index Addressing
The effective address of
addressing mode, by adding
(any one of BX or BP) to
register (any one of SI or
register may be ES or DS.
data is formed in this
content of a base register
the content of an index
DI). The default segment
Example: MOV AX, [BX][SI]
EA = 10H * DS + [BX] + [SI].
15
8086 Microprocessor
Addressing Modes
The effective address is formed by adding an 8 or 16-bit
displacement with the sum of contents of any of the
base registers (BX or BP) and any one of the index
registers, in a default segment.
1.
Register Addressing
2.
Immediate Addressing
3.
Direct Addressing
4.
Register Indirect Addressing
Example:
5.
Indexed Addressing
MOV AX, 50H [BX] [SI]
6.
Register Relative Addressing
EA = 10H * DS + [BX] + [SI] + 50H
7.
Based Index Addressing
8.
Relative Based Indexed
16
8086 Microprocessor
Addressing Modes
Branch-related addressing modes
Addressing Modes for control transfer instructions:
Intersegment direct Mode:
In this mode, the address to which the control is to be transferred is
in a different segment. This addressing mode provides a means of
branching from one code segment to another code segment. Here,
the CS and IP of the destination address are specified directly in the
instruction.
Example: JMP 5000H, 2000H
EA = 5000H * 10H + 2000H
17
8086 Microprocessor
Addressing Modes
Branch-related addressing modes
Addressing Modes for control transfer instructions:
Intersegment Indirect Mode:
In this mode, the address to which the control is to be transferred lies
in a different segment and it is passed to the instruction indirectly.
The starting address of the memory block may be referred using any
of the addressing modes , except immediate mode.
Example: JMP [2000H]
Jump to an address in the other segment specified at effective
address 2000H in DS.
EA = 10H * DS + 2000H
18
8086 Microprocessor
Addressing Modes
Branch-related addressing modes
Addressing Modes for control transfer instructions:
Intrasegment direct mode:
The effective branch address is the sum of an 8- or 16-bit
displacement and the current contents of IP.
When the displacement is 8 bits long, it is referred to as a short
jump.
The displacement is computed "relative" to the IP.
Example: JMP SHORT LABEL
EA = 10H * CS + IP + Label
19
Addressing Modes
Branch-related addressing modes
8086 Microprocessor
Addressing Modes for control transfer instructions:
Intrasegment Indirect mode:
In this mode, the displacement to which the control is to be
transferred is in the same segment in which the control transfer
instruction lies, but it is passed to the instruction indirectly. Here, the
branch address is found as the content of a register or a memory
location.
This addressing
instructions.
mode
may
be
used
in
unconditional
branch
Example: JMP [BX]
EA = 10H * CS + [BX]
20
Download