SlideShare a Scribd company logo
1 of 25
Lecture 4
8086 Instruction Set
1Zelalem Birhanu, AAiT
In this lecture
• Introduction
• 8086 Instruction Types
• 8086 Addressing Modes
2Zelalem Birhanu, AAiT
Introduction – recap
• There are three language levels that can be used to
write a program for a microcomputer
Machine language
Assembly Language
High-Level Language
3Zelalem Birhanu, AAiT
Introduction – recap…cntd
Machine Language
• These are the binary codes for the instructions you want
the microcomputer to execute
• It is hard or impossible for a programmer to write code
in machine language, because it requires memorizing all the
instructions in binary form and soon the program will
get out of control!
4Zelalem Birhanu, AAiT
11101001000000000101000
Introduction – recap…cntd
Assembly Language
• Uses two, three, or four letter mnemonics to represent each
instruction type
• The letters in an assembly language mnemonic are usually
initials or a short form of the English word(s) for the operation
performed by the instruction
e.g., SUB for subtract , XOR for Exclusive OR , etc
• Assembly language program has to be translated to
machine language so that it can be loaded into memory
and run – This is done by the assembler
5Zelalem Birhanu, AAiT
Introduction – recap…cntd
High-Level Languages
• These languages use program statements which are even more
English-like than those of assembly language
e.g. BASIC, C, C++, Java, ...
• Each high-level statement may represent many machine code
instructions
• An interpreter (compiler) program is used to translate higher-
level language statements to machine codes, which can be
loaded into memory and executed.
6Zelalem Birhanu, AAiT
Introduction – recap…cntd
• Elements of an instruction
• 8086 has variable-length instructions (8 bits to 40 bits)
7Zelalem Birhanu, AAiT
Operation Code
(Opcode)
Addresses
(operands)
8086 Instruction Types
• The 8086 instructions can be grouped in to six
categories
Data transfer instructions
 Arithmetic instructions
Bit manipulation instructions
String manipulation instructions
Control transfer instructions
Processor control instructions
8Zelalem Birhanu, AAiT
Data Transfer Instructions
• Used to transfer data from source operand to destination
operand
 Memory to register e.g. MOV AX, [0005h] (AX←[0005h])
 Register to memory e.g. PUSH AL
 Immediate to memory/register e.g. MOV AH, 09h
 I/O device to register e.g. IN AX, 4
 Register to I/O device e.g. OUT AL, 2
• All the store, move, load, exchange, input and output
instructions belong to this category
MOV , PUSH, POP , XCHG, XLAT, IN, OUT, LEA, PUSHF, POPF
9Zelalem Birhanu, AAiT
Arithmetic instructions
• Perform arithmetic operations
 Addition e.g. ADD, ADC, INC, AAA,
 Subtraction e.g. SUB, SBB, DEC, CMP
 Multiplication e.g. MUL, IMUL
 Division e.g. DIV, IDIV
e.g. ADD AL, 5 (AL←AL+5)
MUL BL (AX ←AL*BL)
MUL BX (DX:AX ←AX*BX)
10Zelalem Birhanu, AAiT
Bit Manipulation Instructions
• Logical instructions
NOT, AND, OR, XOR
• Shift instructions
SHL, SHR, SAL, SAR
• Rotate instructions
ROL, ROR, RCL, RCR
e.g. MOV AL, 1Ch (AL←1Ch (00011100b))
ROR AL, 1 (rotate AL one bit to the right) (AL = 00001110b)
11Zelalem Birhanu, AAiT
Byte/WordCF
Byte/WordCF
RCL
RCR
String Manipulation Instructions
• A string is a series of bytes or a series of words in
sequential memory locations. It often consists of ASCII
character codes
e.g. LODSB – Load byte at DS: [SI] into AL. Update SI
STOSW – Store word in AX into ES:[DI]. Update DI
CMPSB – Compare bytes: ES:[DI] from DS:[SI]
12Zelalem Birhanu, AAiT
Control Transfer Instructions
• These instructions are used to tell the processor to start
fetching instructions from some new address, rather
than continuing in sequence
 Unconditional transfer instructions e.g. CALL, RET, JMP
 Conditional transfer instructions e.g. JE, JG, JGE, JL, JLE, JZ
 Iteration control instructions e.g. LOOP, LOOPE, JCXZ
 Interrupt instructions e.g. INT, IRET
e.g. SUB AX, 32
JZ label
…
label:
MOV BX, 10
13Zelalem Birhanu, AAiT
AX=AX-32;
If(AX==0)
{
BX=10;
}
Processor Control Instructions
• Set/clear flags, control the operation of the processor
Flag instructions
e.g. STC – set carry flag
External hardware synchronization instructions
e.g. WAIT - Do nothing until signal on the TEST pin is low
No operation instructions e.g. NOP
14Zelalem Birhanu, AAiT
Addressing Modes
• Describe the types of operands and the way they are
accessed for executing an instruction
• 8086 addressing modes:
 Immediate
 Direct
 Register
 Register Indirect
 Indexed
 Register Relative
 Based Indexed
 Relative Based Indexed
15Zelalem Birhanu, AAiT
Immediate Addressing
• Immediate data is a part of instruction, and appears in
the form of successive byte(s)
e.g. MOV AX, 0005H (AX←0005H)
Here, 0005H is the immediate data. The immediate
data may be 8-bit or 16-bit in size.
16Zelalem Birhanu, AAiT
Direct Addressing
• In the direct addressing mode, a 16-bit memory address
(offset) is directly specified in the instruction
e.g. MOV AX, [5000H ] (AX←[DS:5000H])
Here, data resides in a memory location in the data
segment, whose effective address may be computed
using 5000H as the offset address and content of DS
as segment address.
17Zelalem Birhanu, AAiT
Register Addressing
• In register addressing mode, the data is stored in a
register and it is referred using the particular register
• All the registers, except IP, may be used in this mode
e.g. MOV AX, BX (AX←BX)
Here, data is transferred from register BX to register AX
18Zelalem Birhanu, AAiT
Register Indirect Addressing
• Sometimes, the address of the memory location, which
contains data or operand, is determined in an indirect
way, using the offset registers
• The offset address of data is in either BX, SI or DI
registers. The default segment is either DS or ES.
e.g. MOV AX, [BX ] (AX←[DS:BX])
Here, data is present in a memory location in DS whose
offset address is in BX.
19Zelalem Birhanu, AAiT
Indexed Addressing
• Offset of the operand is stored in one of the index
registers (SI and DI). DS and ES are the default segments
for SI and DI respectively
• This mode is a special case of register indirect
addressing mode
e.g. MOV AX, [SI ] (AX←[DS:SI])
Here, data is present in a memory location in DS whose
offset address is in SI.
20Zelalem Birhanu, AAiT
Register Relative Addressing
• 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 registers BX, BP, SI and DI in the default
segment (DS or ES)
e.g. MOV AX, 50H[BX ] (AX←[DS:BX+50H])
21Zelalem Birhanu, AAiT
Based Indexed Addressing
• The effective address of data is formed by adding
content of a base register (BX or BP) to the content of an
index register (SI or DI)
e.g. MOV AX, [BX ][SI] (AX←[DS:BX+SI])
22Zelalem Birhanu, AAiT
Relative Based Indexed Addressing
• The effective address is formed by adding an 8 or 16-bit
displacement with the sum of contents of any one of the
base registers (BX or BP) and any one of the index
registers (SI or DI), in a default segment
e.g. MOV AX, 50H[BX ][SI] (AX←[DS:BX+SI+50])
23Zelalem Birhanu, AAiT
Emu8086
• Assembler (flat assembler)+ emulator (MS-DOS
system)
24Zelalem Birhanu, AAiT
More Readings
1. Dr. Manoj’s Handouts, Chapter 2
2. 8086 datasheet
3. emu8086 documentation
25Zelalem Birhanu, AAiT

More Related Content

What's hot

SAURABH MITRA-8086 MICROPROCESSOR
SAURABH MITRA-8086 MICROPROCESSORSAURABH MITRA-8086 MICROPROCESSOR
SAURABH MITRA-8086 MICROPROCESSORSAURABH MITRA
 
4. Instruction Set Of MP 8085.pptx
4. Instruction Set Of MP 8085.pptx4. Instruction Set Of MP 8085.pptx
4. Instruction Set Of MP 8085.pptxISMT College
 
Symbolic instructions for 8086 micro processor
Symbolic instructions for 8086 micro processorSymbolic instructions for 8086 micro processor
Symbolic instructions for 8086 micro processorSaurabh Mehta
 
Stacks & subroutines 1
Stacks & subroutines 1Stacks & subroutines 1
Stacks & subroutines 1deval patel
 
8086 microprocessor-architecture
8086 microprocessor-architecture8086 microprocessor-architecture
8086 microprocessor-architectureprasadpawaskar
 
Stack and subroutine
Stack and subroutineStack and subroutine
Stack and subroutineAshim Saha
 
8086 Microprocessor by Nitish Nagar
8086 Microprocessor by Nitish Nagar8086 Microprocessor by Nitish Nagar
8086 Microprocessor by Nitish NagarNitish Nagar
 
Chapter 6 - Introduction to 8085 Instructions
Chapter 6 - Introduction to 8085 InstructionsChapter 6 - Introduction to 8085 Instructions
Chapter 6 - Introduction to 8085 Instructionscmkandemir
 
T imingdiagram
T imingdiagramT imingdiagram
T imingdiagrampuja00
 
Introduction to 8086 microprocessor
Introduction to 8086 microprocessorIntroduction to 8086 microprocessor
Introduction to 8086 microprocessorShreyans Pathak
 
8085 Architecture
8085 Architecture8085 Architecture
8085 Architecturedeval patel
 
3 organization of intel 8086
3 organization of intel 80863 organization of intel 8086
3 organization of intel 8086ELIMENG
 

What's hot (20)

SAURABH MITRA-8086 MICROPROCESSOR
SAURABH MITRA-8086 MICROPROCESSORSAURABH MITRA-8086 MICROPROCESSOR
SAURABH MITRA-8086 MICROPROCESSOR
 
Lecture2
Lecture2Lecture2
Lecture2
 
8085 micro processor
8085 micro processor8085 micro processor
8085 micro processor
 
Instruction.pdf
Instruction.pdfInstruction.pdf
Instruction.pdf
 
4. Instruction Set Of MP 8085.pptx
4. Instruction Set Of MP 8085.pptx4. Instruction Set Of MP 8085.pptx
4. Instruction Set Of MP 8085.pptx
 
Lecture9
Lecture9Lecture9
Lecture9
 
Symbolic instructions for 8086 micro processor
Symbolic instructions for 8086 micro processorSymbolic instructions for 8086 micro processor
Symbolic instructions for 8086 micro processor
 
Various type of register
Various type of registerVarious type of register
Various type of register
 
Internal microprocessor architecture
Internal microprocessor architectureInternal microprocessor architecture
Internal microprocessor architecture
 
Stacks & subroutines 1
Stacks & subroutines 1Stacks & subroutines 1
Stacks & subroutines 1
 
8086 microprocessor-architecture
8086 microprocessor-architecture8086 microprocessor-architecture
8086 microprocessor-architecture
 
Stack and subroutine
Stack and subroutineStack and subroutine
Stack and subroutine
 
8086 Microprocessor by Nitish Nagar
8086 Microprocessor by Nitish Nagar8086 Microprocessor by Nitish Nagar
8086 Microprocessor by Nitish Nagar
 
8086 micro processor
8086 micro processor8086 micro processor
8086 micro processor
 
Chapter 6 - Introduction to 8085 Instructions
Chapter 6 - Introduction to 8085 InstructionsChapter 6 - Introduction to 8085 Instructions
Chapter 6 - Introduction to 8085 Instructions
 
T imingdiagram
T imingdiagramT imingdiagram
T imingdiagram
 
Introduction to 8086 microprocessor
Introduction to 8086 microprocessorIntroduction to 8086 microprocessor
Introduction to 8086 microprocessor
 
intel 8086 introduction
intel 8086 introductionintel 8086 introduction
intel 8086 introduction
 
8085 Architecture
8085 Architecture8085 Architecture
8085 Architecture
 
3 organization of intel 8086
3 organization of intel 80863 organization of intel 8086
3 organization of intel 8086
 

Viewers also liked

Module 10 - Section 2: ICTs, the environment and climate change & Section 3: ...
Module 10 - Section 2: ICTs, the environment and climate change & Section 3: ...Module 10 - Section 2: ICTs, the environment and climate change & Section 3: ...
Module 10 - Section 2: ICTs, the environment and climate change & Section 3: ...Richard Labelle
 
Scsi express overview
Scsi express overviewScsi express overview
Scsi express overviewrbeetle
 
Microprocessors-based systems (under graduate course) Lecture 9 of 9
Microprocessors-based systems (under graduate course) Lecture 9 of 9 Microprocessors-based systems (under graduate course) Lecture 9 of 9
Microprocessors-based systems (under graduate course) Lecture 9 of 9 Randa Elanwar
 
8086 microprocessor introduction
8086 microprocessor introduction8086 microprocessor introduction
8086 microprocessor introductionAakash Ugale
 
Time delay programs and assembler directives 8086
Time delay programs and assembler directives 8086Time delay programs and assembler directives 8086
Time delay programs and assembler directives 8086Dheeraj Suri
 
Input Output programming in AVR microcontroller
Input  Output  programming in AVR microcontrollerInput  Output  programming in AVR microcontroller
Input Output programming in AVR microcontrollerRobo India
 
PIN Specification of 8086 Microprocessor
PIN Specification of 8086 MicroprocessorPIN Specification of 8086 Microprocessor
PIN Specification of 8086 MicroprocessorNikhil Kumar
 
Assembly Language Lecture 1
Assembly Language Lecture 1Assembly Language Lecture 1
Assembly Language Lecture 1Motaz Saad
 

Viewers also liked (20)

Lecture1
Lecture1Lecture1
Lecture1
 
Emu86 short
Emu86 shortEmu86 short
Emu86 short
 
Introduction To EMU
Introduction To EMUIntroduction To EMU
Introduction To EMU
 
Emu8086
Emu8086Emu8086
Emu8086
 
Module 10 - Section 2: ICTs, the environment and climate change & Section 3: ...
Module 10 - Section 2: ICTs, the environment and climate change & Section 3: ...Module 10 - Section 2: ICTs, the environment and climate change & Section 3: ...
Module 10 - Section 2: ICTs, the environment and climate change & Section 3: ...
 
Lecture8
Lecture8Lecture8
Lecture8
 
Scsi express overview
Scsi express overviewScsi express overview
Scsi express overview
 
Ch6 030702
Ch6 030702Ch6 030702
Ch6 030702
 
Class11
Class11Class11
Class11
 
Microprocessors-based systems (under graduate course) Lecture 9 of 9
Microprocessors-based systems (under graduate course) Lecture 9 of 9 Microprocessors-based systems (under graduate course) Lecture 9 of 9
Microprocessors-based systems (under graduate course) Lecture 9 of 9
 
8086 microprocessor introduction
8086 microprocessor introduction8086 microprocessor introduction
8086 microprocessor introduction
 
07 input output
07 input output07 input output
07 input output
 
3. adressingmodes1
3. adressingmodes13. adressingmodes1
3. adressingmodes1
 
Time delay programs and assembler directives 8086
Time delay programs and assembler directives 8086Time delay programs and assembler directives 8086
Time delay programs and assembler directives 8086
 
Scsi
ScsiScsi
Scsi
 
Input Output programming in AVR microcontroller
Input  Output  programming in AVR microcontrollerInput  Output  programming in AVR microcontroller
Input Output programming in AVR microcontroller
 
PIN Specification of 8086 Microprocessor
PIN Specification of 8086 MicroprocessorPIN Specification of 8086 Microprocessor
PIN Specification of 8086 Microprocessor
 
Smart City #ITUWORLD
Smart City #ITUWORLDSmart City #ITUWORLD
Smart City #ITUWORLD
 
Assembly Language Lecture 1
Assembly Language Lecture 1Assembly Language Lecture 1
Assembly Language Lecture 1
 
8086 pin function
8086 pin function8086 pin function
8086 pin function
 

Similar to Lecture4

Chapter 3 INSTRUCTION SET AND ASSEMBLY LANGUAGE PROGRAMMING
Chapter 3 INSTRUCTION SET AND ASSEMBLY LANGUAGE PROGRAMMINGChapter 3 INSTRUCTION SET AND ASSEMBLY LANGUAGE PROGRAMMING
Chapter 3 INSTRUCTION SET AND ASSEMBLY LANGUAGE PROGRAMMINGFrankie Jones
 
8086 Register organization and Architecture details
8086 Register organization and Architecture details8086 Register organization and Architecture details
8086 Register organization and Architecture detailsMahendraMunirathnam1
 
8086 microprocessor pptx JNTUH ece 3rd year
8086 microprocessor pptx JNTUH ece 3rd year8086 microprocessor pptx JNTUH ece 3rd year
8086 microprocessor pptx JNTUH ece 3rd yearBharghavteja1
 
Instruction sets of 8086
Instruction sets of 8086Instruction sets of 8086
Instruction sets of 8086Mahalakshmiv11
 
Intel8086_Flags_Addr_Modes_sample_pgms.pdf
Intel8086_Flags_Addr_Modes_sample_pgms.pdfIntel8086_Flags_Addr_Modes_sample_pgms.pdf
Intel8086_Flags_Addr_Modes_sample_pgms.pdfAnonymous611358
 
8086 instruction set (with simulator)
8086 instruction set (with simulator)8086 instruction set (with simulator)
8086 instruction set (with simulator)Aswini Dharmaraj
 
Microprocessor
MicroprocessorMicroprocessor
Microprocessoradnanqayum
 
Microprocessors-based systems (under graduate course) Lecture 3 of 9
Microprocessors-based systems (under graduate course) Lecture 3 of 9 Microprocessors-based systems (under graduate course) Lecture 3 of 9
Microprocessors-based systems (under graduate course) Lecture 3 of 9 Randa Elanwar
 
8086 microprocessor-architecture-120207111857-phpapp01
8086 microprocessor-architecture-120207111857-phpapp018086 microprocessor-architecture-120207111857-phpapp01
8086 microprocessor-architecture-120207111857-phpapp01destaw belay
 
8086 microprocessor-architecture-120207111857-phpapp01
8086 microprocessor-architecture-120207111857-phpapp018086 microprocessor-architecture-120207111857-phpapp01
8086 microprocessor-architecture-120207111857-phpapp01Siva Raman
 
Introduction of 8086 micro processor .
Introduction of 8086 micro processor .Introduction of 8086 micro processor .
Introduction of 8086 micro processor .Siraj Ahmed
 
INTEL 8086 MICROPROCESSOR
INTEL 8086 MICROPROCESSORINTEL 8086 MICROPROCESSOR
INTEL 8086 MICROPROCESSORSagar Kuntumal
 
Assembly language.pptx
Assembly language.pptxAssembly language.pptx
Assembly language.pptxShaistaRiaz4
 
8086-microprocessor-architecture.ppt
8086-microprocessor-architecture.ppt8086-microprocessor-architecture.ppt
8086-microprocessor-architecture.pptMadhan7771
 
8086 Architecture ppt.pdf
8086 Architecture ppt.pdf8086 Architecture ppt.pdf
8086 Architecture ppt.pdfUmamaheswariV4
 

Similar to Lecture4 (20)

Chapter 3 INSTRUCTION SET AND ASSEMBLY LANGUAGE PROGRAMMING
Chapter 3 INSTRUCTION SET AND ASSEMBLY LANGUAGE PROGRAMMINGChapter 3 INSTRUCTION SET AND ASSEMBLY LANGUAGE PROGRAMMING
Chapter 3 INSTRUCTION SET AND ASSEMBLY LANGUAGE PROGRAMMING
 
8086 Register organization and Architecture details
8086 Register organization and Architecture details8086 Register organization and Architecture details
8086 Register organization and Architecture details
 
8086 microprocessor pptx JNTUH ece 3rd year
8086 microprocessor pptx JNTUH ece 3rd year8086 microprocessor pptx JNTUH ece 3rd year
8086 microprocessor pptx JNTUH ece 3rd year
 
UNIT 1.pptx
UNIT 1.pptxUNIT 1.pptx
UNIT 1.pptx
 
UNIT 1.pptx
UNIT 1.pptxUNIT 1.pptx
UNIT 1.pptx
 
Instruction sets of 8086
Instruction sets of 8086Instruction sets of 8086
Instruction sets of 8086
 
8086
8086 8086
8086
 
Coal (1)
Coal (1)Coal (1)
Coal (1)
 
Intel8086_Flags_Addr_Modes_sample_pgms.pdf
Intel8086_Flags_Addr_Modes_sample_pgms.pdfIntel8086_Flags_Addr_Modes_sample_pgms.pdf
Intel8086_Flags_Addr_Modes_sample_pgms.pdf
 
8086 instruction set (with simulator)
8086 instruction set (with simulator)8086 instruction set (with simulator)
8086 instruction set (with simulator)
 
Microprocessor
MicroprocessorMicroprocessor
Microprocessor
 
Amp
AmpAmp
Amp
 
Microprocessors-based systems (under graduate course) Lecture 3 of 9
Microprocessors-based systems (under graduate course) Lecture 3 of 9 Microprocessors-based systems (under graduate course) Lecture 3 of 9
Microprocessors-based systems (under graduate course) Lecture 3 of 9
 
8086 microprocessor-architecture-120207111857-phpapp01
8086 microprocessor-architecture-120207111857-phpapp018086 microprocessor-architecture-120207111857-phpapp01
8086 microprocessor-architecture-120207111857-phpapp01
 
8086 microprocessor-architecture-120207111857-phpapp01
8086 microprocessor-architecture-120207111857-phpapp018086 microprocessor-architecture-120207111857-phpapp01
8086 microprocessor-architecture-120207111857-phpapp01
 
Introduction of 8086 micro processor .
Introduction of 8086 micro processor .Introduction of 8086 micro processor .
Introduction of 8086 micro processor .
 
INTEL 8086 MICROPROCESSOR
INTEL 8086 MICROPROCESSORINTEL 8086 MICROPROCESSOR
INTEL 8086 MICROPROCESSOR
 
Assembly language.pptx
Assembly language.pptxAssembly language.pptx
Assembly language.pptx
 
8086-microprocessor-architecture.ppt
8086-microprocessor-architecture.ppt8086-microprocessor-architecture.ppt
8086-microprocessor-architecture.ppt
 
8086 Architecture ppt.pdf
8086 Architecture ppt.pdf8086 Architecture ppt.pdf
8086 Architecture ppt.pdf
 

More from misgina Mengesha (13)

Lecture6
Lecture6Lecture6
Lecture6
 
Lecture5
Lecture5Lecture5
Lecture5
 
Lecture5(1)
Lecture5(1)Lecture5(1)
Lecture5(1)
 
Lecture3
Lecture3Lecture3
Lecture3
 
Sprabq8
Sprabq8Sprabq8
Sprabq8
 
Sensors2006
Sensors2006Sensors2006
Sensors2006
 
Sensors31
Sensors31Sensors31
Sensors31
 
Sensing for robotics and control s set13
Sensing for robotics and control s set13Sensing for robotics and control s set13
Sensing for robotics and control s set13
 
Introduction to sensors
Introduction to sensorsIntroduction to sensors
Introduction to sensors
 
Cn3 sensors and transducers-12
Cn3 sensors and transducers-12Cn3 sensors and transducers-12
Cn3 sensors and transducers-12
 
Cn3 sensors and transducers-1
Cn3 sensors and transducers-1Cn3 sensors and transducers-1
Cn3 sensors and transducers-1
 
480 sensors
480 sensors480 sensors
480 sensors
 
Wwwwww
WwwwwwWwwwww
Wwwwww
 

Lecture4

  • 1. Lecture 4 8086 Instruction Set 1Zelalem Birhanu, AAiT
  • 2. In this lecture • Introduction • 8086 Instruction Types • 8086 Addressing Modes 2Zelalem Birhanu, AAiT
  • 3. Introduction – recap • There are three language levels that can be used to write a program for a microcomputer Machine language Assembly Language High-Level Language 3Zelalem Birhanu, AAiT
  • 4. Introduction – recap…cntd Machine Language • These are the binary codes for the instructions you want the microcomputer to execute • It is hard or impossible for a programmer to write code in machine language, because it requires memorizing all the instructions in binary form and soon the program will get out of control! 4Zelalem Birhanu, AAiT 11101001000000000101000
  • 5. Introduction – recap…cntd Assembly Language • Uses two, three, or four letter mnemonics to represent each instruction type • The letters in an assembly language mnemonic are usually initials or a short form of the English word(s) for the operation performed by the instruction e.g., SUB for subtract , XOR for Exclusive OR , etc • Assembly language program has to be translated to machine language so that it can be loaded into memory and run – This is done by the assembler 5Zelalem Birhanu, AAiT
  • 6. Introduction – recap…cntd High-Level Languages • These languages use program statements which are even more English-like than those of assembly language e.g. BASIC, C, C++, Java, ... • Each high-level statement may represent many machine code instructions • An interpreter (compiler) program is used to translate higher- level language statements to machine codes, which can be loaded into memory and executed. 6Zelalem Birhanu, AAiT
  • 7. Introduction – recap…cntd • Elements of an instruction • 8086 has variable-length instructions (8 bits to 40 bits) 7Zelalem Birhanu, AAiT Operation Code (Opcode) Addresses (operands)
  • 8. 8086 Instruction Types • The 8086 instructions can be grouped in to six categories Data transfer instructions  Arithmetic instructions Bit manipulation instructions String manipulation instructions Control transfer instructions Processor control instructions 8Zelalem Birhanu, AAiT
  • 9. Data Transfer Instructions • Used to transfer data from source operand to destination operand  Memory to register e.g. MOV AX, [0005h] (AX←[0005h])  Register to memory e.g. PUSH AL  Immediate to memory/register e.g. MOV AH, 09h  I/O device to register e.g. IN AX, 4  Register to I/O device e.g. OUT AL, 2 • All the store, move, load, exchange, input and output instructions belong to this category MOV , PUSH, POP , XCHG, XLAT, IN, OUT, LEA, PUSHF, POPF 9Zelalem Birhanu, AAiT
  • 10. Arithmetic instructions • Perform arithmetic operations  Addition e.g. ADD, ADC, INC, AAA,  Subtraction e.g. SUB, SBB, DEC, CMP  Multiplication e.g. MUL, IMUL  Division e.g. DIV, IDIV e.g. ADD AL, 5 (AL←AL+5) MUL BL (AX ←AL*BL) MUL BX (DX:AX ←AX*BX) 10Zelalem Birhanu, AAiT
  • 11. Bit Manipulation Instructions • Logical instructions NOT, AND, OR, XOR • Shift instructions SHL, SHR, SAL, SAR • Rotate instructions ROL, ROR, RCL, RCR e.g. MOV AL, 1Ch (AL←1Ch (00011100b)) ROR AL, 1 (rotate AL one bit to the right) (AL = 00001110b) 11Zelalem Birhanu, AAiT Byte/WordCF Byte/WordCF RCL RCR
  • 12. String Manipulation Instructions • A string is a series of bytes or a series of words in sequential memory locations. It often consists of ASCII character codes e.g. LODSB – Load byte at DS: [SI] into AL. Update SI STOSW – Store word in AX into ES:[DI]. Update DI CMPSB – Compare bytes: ES:[DI] from DS:[SI] 12Zelalem Birhanu, AAiT
  • 13. Control Transfer Instructions • These instructions are used to tell the processor to start fetching instructions from some new address, rather than continuing in sequence  Unconditional transfer instructions e.g. CALL, RET, JMP  Conditional transfer instructions e.g. JE, JG, JGE, JL, JLE, JZ  Iteration control instructions e.g. LOOP, LOOPE, JCXZ  Interrupt instructions e.g. INT, IRET e.g. SUB AX, 32 JZ label … label: MOV BX, 10 13Zelalem Birhanu, AAiT AX=AX-32; If(AX==0) { BX=10; }
  • 14. Processor Control Instructions • Set/clear flags, control the operation of the processor Flag instructions e.g. STC – set carry flag External hardware synchronization instructions e.g. WAIT - Do nothing until signal on the TEST pin is low No operation instructions e.g. NOP 14Zelalem Birhanu, AAiT
  • 15. Addressing Modes • Describe the types of operands and the way they are accessed for executing an instruction • 8086 addressing modes:  Immediate  Direct  Register  Register Indirect  Indexed  Register Relative  Based Indexed  Relative Based Indexed 15Zelalem Birhanu, AAiT
  • 16. Immediate Addressing • Immediate data is a part of instruction, and appears in the form of successive byte(s) e.g. MOV AX, 0005H (AX←0005H) Here, 0005H is the immediate data. The immediate data may be 8-bit or 16-bit in size. 16Zelalem Birhanu, AAiT
  • 17. Direct Addressing • In the direct addressing mode, a 16-bit memory address (offset) is directly specified in the instruction e.g. MOV AX, [5000H ] (AX←[DS:5000H]) Here, data resides in a memory location in the data segment, whose effective address may be computed using 5000H as the offset address and content of DS as segment address. 17Zelalem Birhanu, AAiT
  • 18. Register Addressing • In register addressing mode, the data is stored in a register and it is referred using the particular register • All the registers, except IP, may be used in this mode e.g. MOV AX, BX (AX←BX) Here, data is transferred from register BX to register AX 18Zelalem Birhanu, AAiT
  • 19. Register Indirect Addressing • Sometimes, the address of the memory location, which contains data or operand, is determined in an indirect way, using the offset registers • The offset address of data is in either BX, SI or DI registers. The default segment is either DS or ES. e.g. MOV AX, [BX ] (AX←[DS:BX]) Here, data is present in a memory location in DS whose offset address is in BX. 19Zelalem Birhanu, AAiT
  • 20. Indexed Addressing • Offset of the operand is stored in one of the index registers (SI and DI). DS and ES are the default segments for SI and DI respectively • This mode is a special case of register indirect addressing mode e.g. MOV AX, [SI ] (AX←[DS:SI]) Here, data is present in a memory location in DS whose offset address is in SI. 20Zelalem Birhanu, AAiT
  • 21. Register Relative Addressing • 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 registers BX, BP, SI and DI in the default segment (DS or ES) e.g. MOV AX, 50H[BX ] (AX←[DS:BX+50H]) 21Zelalem Birhanu, AAiT
  • 22. Based Indexed Addressing • The effective address of data is formed by adding content of a base register (BX or BP) to the content of an index register (SI or DI) e.g. MOV AX, [BX ][SI] (AX←[DS:BX+SI]) 22Zelalem Birhanu, AAiT
  • 23. Relative Based Indexed Addressing • The effective address is formed by adding an 8 or 16-bit displacement with the sum of contents of any one of the base registers (BX or BP) and any one of the index registers (SI or DI), in a default segment e.g. MOV AX, 50H[BX ][SI] (AX←[DS:BX+SI+50]) 23Zelalem Birhanu, AAiT
  • 24. Emu8086 • Assembler (flat assembler)+ emulator (MS-DOS system) 24Zelalem Birhanu, AAiT
  • 25. More Readings 1. Dr. Manoj’s Handouts, Chapter 2 2. 8086 datasheet 3. emu8086 documentation 25Zelalem Birhanu, AAiT