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

Instruction Set and addressing modes of 8051

The document provides an overview of the addressing modes and instruction set of the 8086 microprocessor. It categorizes addressing modes into two groups: those for register and immediate data, and those for memory data, detailing various types such as Register Addressing, Immediate Addressing, and Direct Addressing. Additionally, it outlines the instruction types including Data Transfer, Arithmetic, Logical, and String Instructions, along with specific examples of each instruction type.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Instruction Set and addressing modes of 8051

The document provides an overview of the addressing modes and instruction set of the 8086 microprocessor. It categorizes addressing modes into two groups: those for register and immediate data, and those for memory data, detailing various types such as Register Addressing, Immediate Addressing, and Direct Addressing. Additionally, it outlines the instruction types including Data Transfer, Arithmetic, Logical, and String Instructions, along with specific examples of each instruction type.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 27

Microprocessor Architecture and Interfacing:

Intel x86

Module 2

1
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.

1. Register Addressing
Group I : Addressing modes for
2. Immediate Addressing register and immediate data

3. Direct Addressing

4. Register Indirect Addressing

5. Based Addressing

6. Indexed Addressing
Group II : Addressing modes for
7. Based Index Addressing memory data

8. Register Relative Addressing

9. Relative based indexed

3
8086 Microprocessor Group I : Addressing modes for
Addressing Modes register and immediate data

The instruction will specify the name of the


register which holds the data to be operated by
the instruction.
1. Register Addressing
Example:
2. Immediate Addressing
MOV CL, DH
3. Direct Addressing
The content of 8-bit register DH is moved to
4. Register Indirect Addressing another 8-bit register CL
5. Based Addressing
(CL)  (DH)
6. Indexed Addressing

7. Based Index Addressing

8. Register Relative Addressing

9. Relative based indexed

4
8086 Microprocessor Group I : Addressing modes for
Addressing Modes register and immediate data

1. Register Addressing
In immediate addressing mode, an 8-bit or 16-bit
2. Immediate Addressing data is specified as part of the instruction
3. Direct Addressing
Example:
4. Register Indirect Addressing
MOV DL, 08H
5. Based Addressing
The 8-bit data (08H) given in the instruction is
6. Indexed Addressing moved to DL

7. Based Index Addressing (DL)  08H

8. Register Relative Addressing


MOV AX, 0A9FH
9. Relative based indexed
The 16-bit data (0A9FH) given in the instruction is
moved to AX register

(AX)  0A9FH

5
8086 Microprocessor Group II : Addressing modes
Addressing Modes for memory data

1. Register Addressing

2. Immediate Addressing
Here, the effective address of the memory
3. Direct Addressing
location at which the data operand is stored is
4. Register Indirect Addressing given in the instruction.

5. Based Addressing The effective address is just a 16-bit number


written directly in the instruction.
6. Indexed Addressing
Example:
7. Based Index Addressing
MOV BX, [1354H]
8. Register Relative Addressing MOV BL, [0400H]
9. Relative based indexed
The square brackets around the 1354H denotes
the contents of the memory location. When
executed, this instruction will copy the contents of
the memory location into BX register.

This addressing mode is called direct because the


displacement of the operand from the segment
base is specified directly in the instruction.

6
8086 Microprocessor Group II : Addressing modes
Addressing Modes for memory data

1. Register Addressing In Register indirect addressing, name of the


register which holds the effective address (EA)
2. Immediate Addressing will be specified in the instruction.

3. Direct Addressing Registers used to hold EA are any of the following


registers:
4. Register Indirect Addressing
BX, BP, DI and SI.
5. Based Addressing
Content of the DS register is used for base
6. Indexed Addressing
address calculation.
7. Based Index Addressing
Example:
8. Register Relative Addressing
MOV CX, [BX]
9. Relative based indexed
Operations:

CX = 10H*DS+[BX]

7
8086 Microprocessor Group II : Addressing modes
Addressing Modes for memory data

1. Register Addressing In Based Addressing, BX or BP is used to hold the


base value for effective address and a signed 8-bit
2. Immediate Addressing or unsigned 16-bit displacement will be specified
in the instruction.
3. Direct Addressing
In case of 8-bit displacement, it is sign extended
4. Register Indirect Addressing to 16-bit before adding to the base value.

5. Based Addressing When BX holds the base value of EA, 20-bit


physical address is calculated from BX and DS.
6. Indexed Addressing
When BP holds the base value of EA, BP and SS is
7. Based Index Addressing
used.
8. Register Relative Addressing
Example:
9. Relative based indexed
MOV AX, [BX + 08H]

Operations:

AX = 10H*DS+[BX] + [08H]

8
8086 Microprocessor Group II : Addressing modes
Addressing Modes for memory data

1. Register Addressing SI or DI register is used to hold an index value for


memory data and a signed 8-bit or unsigned 16-
2. Immediate Addressing bit displacement will be specified in the
instruction.
3. Direct Addressing
Displacement is added to the index value in SI or
4. Register Indirect Addressing DI register to obtain the EA.

5. Based Addressing In case of 8-bit displacement, it is sign extended


to 16-bit before adding to the base value.
6. Indexed Addressing

7. Based Index Addressing


Example:
8. Register Relative Addressing
MOV CX, [SI]
9. Relative based indexed
Operations:

CX = 10HxDS+[SI]

9
8086 Microprocessor Group II : Addressing modes
Addressing Modes for memory data

1. Register Addressing In Based Index Addressing, the effective address


is computed from the sum of a base register (BX
2. Immediate Addressing or BP), an index register (SI or DI) and a
displacement.
3. Direct Addressing
Example:
4. Register Indirect Addressing
MOV DX, [BX] [SI]
5. Based Addressing
Operations:
6. Indexed Addressing
DX = 10HxDS +[BX]+[SI]
7. Based Index Addressing

8. Register Relative Addressing

9. Relative based indexed

10
8086 Microprocessor Group II : Addressing modes
Addressing Modes for memory data

1. Register Addressing this addressing mode, effective address is formed


by adding 8 or 16 bit displacement with sum of
2. Immediate Addressing contents of any one of the registers BX,BP,SI and
DI.
3. Direct Addressing
Example:
4. Register Indirect Addressing
MOV AX, 50H [BX]
5. Based Addressing
Operations:
6. Indexed Addressing
AX = 10HxDS +50H+[BX]
7. Based Index Addressing

8. Register Relative Addressing

9. Relative based indexed

11
8086 Microprocessor Group II : Addressing modes
Addressing Modes for memory data

1. Register Addressing
In this addressing mode, effective address is
2. Immediate Addressing formed by adding 8 or 16 bit displacement with
sum of contents of any one of the base registers
3. Direct Addressing (BX or BP) and any one of the index registers in a
default segment.
4. Register Indirect Addressing
Example:
5. Based Addressing
MOV AX,50H [BX][ SI]
6. Indexed Addressing

7. Based Index Addressing


Operations:
8. Register Relative Addressing
AX = 10H*DS+{BX]+[SI]+50H
9. Relative based indexed

12
INSTRUCTION SET
8086 Microprocessor
Instruction Set

8086 supports 6 types of instructions.

1. Data Transfer Instructions

2. Arithmetic Instructions

3. Logical Instructions

4. Shift and Rotate Instructions

5. Branch and Loop Instructions

6. Machine Control Instructions

7. Flag Manipulation Instructions

8. String Instructions

14
8086 Microprocessor
Instruction Set

1. Data Transfer Instructions

These instructions are used to transfer the data from the source operand to the
destination operand. Following are the list of instructions under this group :

Instruction to transfer a word


MOV − Used to copy the byte or word from the provided source to the
provided destination.
PUSH − Used to put a word at the top of the stack.
POP − Used to get a word from the top of the stack to the provided location.
XCHG − Used to exchange the data from two locations.
XLAT − Used to translate a byte in AL using a table in the memory.

15
8086 Microprocessor
Instruction Set

1. Data Transfer Instructions

Instructions for input and output port transfer:


IN − Used to read a byte or word from the provided port to the accumulator.
OUT − Used to send out a byte or word from the accumulator to the provided port.
Instructions to transfer the address
LEA − Load Effective Address – loads the effective address formed by destination
operand into specified source register.
LDS/ LES − load DS or ES register from the memory.
Instructions to transfer flag registers
LAHF − Used to load AH with the low byte of the flag register.
SAHF − Used to store AH register to low byte of the flag register.
PUSHF − Used to copy the flag register at the top of the stack.
POPF − Used to copy a word at the top of the stack to the flag register 16
8086 Microprocessor
Instruction Set

2. Arithmetic Instructions
Instructions to perform addition:
ADD − Used to add the provided byte to byte/word to word.
ADC − Used to add with carry.
INC − Used to increment the provided byte/word by 1.
AAA − Used to adjust ASCII after addition.
DAA − Used to adjust the decimal after the addition/subtraction operation.
Instructions to perform subtraction
SUB − Used to subtract the byte from byte/word from word.
SBB − Used to perform subtraction with borrow.
DEC − Used to decrement the provided byte/word by 1.
AAS − Used to adjust ASCII codes after subtraction.
DAS − Used to adjust decimal after subtraction.
17
8086 Microprocessor
Instruction Set

2. Arithmetic Instructions
Instruction to perform multiplication:
MUL − Used to multiply unsigned byte by byte/word by word.
IMUL − Used to multiply signed byte by byte/word by word.
AAM − Used to adjust ASCII codes after multiplication.
Instructions to perform division
DIV − Used to divide the unsigned word by byte or unsigned double word by
word.
IDIV − Used to divide the signed word by byte or signed double word by word.
AAD − Used to adjust ASCII codes after division.

18
8086 Microprocessor
Instruction Set

2. Arithmetic Instructions
Other Arithmetic Instruction:
CMP − Used to compare 2 provided byte/word.
NEG − Used to negate each bit of the provided byte/word and forms 2’s
complement.
CBW − Used to covert a signed byte to a signed word.
CWD − Used to covert a signed word to double word.

19
8086 Microprocessor
Instruction Set

3. Logical Instructions
NOT − Used to invert each bit of a byte or word.
AND − Used for adding each bit in a byte/word with the corresponding bit in
another byte/word.
OR − Used to multiply each bit in a byte/word with the corresponding bit in
another byte/word.
XOR − Used to perform Exclusive-OR operation over each bit in a byte/word with
the corresponding bit in another byte/word.
TEST − Used to add operands to update flags, without affecting operands.
SHL− Used to shift bits of a byte/word towards left and put zero(S) in LSBs.
SHR − Used to shift bits of a byte/word towards the right and put zero(S) in
MSBs.

20
8086 Microprocessor
Instruction Set
4. Shift and Rotate Instructions

SHL− Used to shift bits of a byte/word towards left and put zero(S) in LSBs.
SHR − Used to shift bits of a byte/word towards the right and put zero(S) in
MSBs.
SAR − Used to shift bits of a byte/word towards the right and copy the old MSB
into the new MSB.
ROL − Used to rotate bits of byte/word towards the left, i.e. MSB to LSB and to
Carry Flag [CF].
ROR − Used to rotate bits of byte/word towards the right, i.e. LSB to MSB and to
Carry Flag [CF].
RCR − Used to rotate bits of byte/word towards the right, i.e. LSB to CF and CF
to MSB.
RCL − Used to rotate bits of byte/word towards the left, i.e. MSB to CF and CF to
LSB.

21
8086 Microprocessor
Instruction Set

5. Branch and Loop Instructions


Unconditional Instruction:
CALL − Used to call a procedure and save their return address to the stack.
RET − Used to return from the procedure to the main program.
JMP − Used to jump to the provided address to proceed to the next instruction.
LOOP − Used to loop a group of instructions until the condition satisfies, i.e., CX
=0

22
8086 Microprocessor
Instruction Set
5. Branch and Loop Instructions
Conditional Jump Instruction:

23
8086 Microprocessor
Instruction Set

5. Branch and Loop Instructions


Conditional Loop Instruction:

24
8086 Microprocessor
Instruction Set

6. Machine Control Instructions

25
8086 Microprocessor
Instruction Set

7. Flag Manipulation Instructions

CLC --- Clear carry flag.


CMC --- Complement Carry flag.
STC --- Set Carry Flag.
CLD --- Clear Direction Flag.
STD --- Set Direction Flag.
CLI --- Clear Interrupt Flag.
STI --- Set Interrupt Flag.

26
8086 Microprocessor
Instruction Set

8. String Manipulation Instructions

REP − Used to repeat the given instruction till CX ≠ 0.


MOVSB/MOVSW − Used to move the byte/word from one string to
another.
CMPS − Used to compare two string bytes/words.
SCAS− Used to scan a string and compare its byte with a byte in AL or
string word with a word in AX.
LODS− Used to load the string byte into AL or string word into AX.
STOS − Used to copy a byte from AL or a word from AX to a memory
location in the extra segment.

27

You might also like