Professional Documents
Culture Documents
TEXT BOOK:
Advanced Microprocessors and Peripherals - A.K. Ray and K.M. Bhurchandi, TMH, 3rd
Edition, 2012, ISBN 978-1-25-900613-5.
REFERENCE BOOKS:
1. Microprocessor and Interfacing- Douglas V Hall, SSSP Rao, 3rd edition TMH, 2012.
2. Microcomputer systems-The 8086 / 8088 Family – Y.C. Liu and A. Gibson, 2nd edition,
PHI -2003.
Unit 1
• 8086 Processor
• Historical background, 8086 CPU Architecture.
Addressing modes, Machine language
instruction formats.
• Instruction Set of 8086:
• Data transfer and arithmetic instructions.,
Illustration of these instructions with example
programs
Unit 1
• 8086 Processor
• Historical background, 8086 CPU Architecture.
Addressing modes, Machine language instruction
formats.
• Instruction Set of 8086:
• Data transfer and arithmetic instructions.,
Illustration of these instructions with example
programs
Historical Background
• The Mechanical Age
• The Electrical Age
• The Microprocessor Age
• The Intel Age – The Modern Microprocessor
– 1970s
– 1980s
– 1990s
– 2000s
The Mechanical Age
Dream: calculating with a machine
•The idea of computing system existed long before
modern electrical and electronics devices were
developed.
•The idea of calculating with a machine dates to 500 BC
when the Babylonians invented the abacus, the first
mechanical calculator, Abacus-string of beads used to
perform calculations.
The Electrical Age
• First electronic (digital ) computer- ENIAC-(Electronic
numerical integrator calculator)
• Designed and developed at the U. of Pennsylvania,
1946
• contained over 18,000 vacuum tubes, weighed more
than 30 tons, and required 1500 square feet of floor
space and over 500 miles of wires
• It was programmed by setting up to 6000 switches and
connecting cables between the various units of the
computer.
• first modern (general-purpose, programmable)
electronic computer performing about 100,000
operations per second
• programmed by rewiring its circuits
The Microprocessor Age
• Before the invention of microprocessors, most digital
design problems were solved using the same set of
tools.
• Combinational circuits were derived from Boolean
logic equations, truth tables, and Karnaugh maps.
• Sequential designs utilized flip-flop excitation tables
and state diagrams.
• Designers then chose “off the shelf” logic
components —typically 7400 family integrated
circuits—to implement these equations in hardware.
• If the design specifications changed, the process was
repeated and the hardware was modified or rebuilt.
The Microprocessor Age cotd..
• Release of a new logic component called the
microprocessor in the early 1970s changed all of this.
• The POP instruction copies a word from the stack location pointed to
by the stack pointer to a destination specified in the instruction.
• The destination can be a general-purpose register, a segment
• register or a memory location.
• The data in the stack is not changed. After the word is copied to
• the specified destination, the stack pointer is automatically
• incremented by 2 to point to the next word on the stack.
AL <--- [AL+BX]
Execution unit
• Executes instructions from the instruction system
byte queue.
• If you want to divide a byte by a byte, you must first put the dividend
byte in AL and fill AH with all 0’s.
• Likewise, if you want to divide a word by another word, then put the
dividend word in AX and fill DX with all 0’s.
• DIV SCALE [BX] ; (DX and AX) / (word at effective address SCALE[BX] if
SCALE[BX] is of type word
INC – INC Destination
• The INC instruction adds 1 to a specified register or to a memory location.
• AF, OF, PF, SF, and ZF are updated, but CF is not affected.
• This means that if an 8-bit destination containing FFH or a 16-bit destination
containing FFFFH is incremented, the result will be all 0’s with no carry.
• INC BL ; Add 1 to content of BL register
• INC CX ;Add 1 to content of CX register
• INC BYTE PTR [BX] ;Increment byte in data segment at offset contained in BX.
• INC WORD PTR [BX] ;Increment the word at offset of [BX] and [BX + 1] in the data
segment.
DEC – DEC Destination
• This instruction subtracts 1 from the destination word or byte.
• The destination can be a register or a memory location.
• AF, OF, SF, PF, and ZF are updated, but CF is not affected.
• If an 8-bit destination containing 00H or a 16-bit destination
containing 0000H is decremented, the result will be FFH or FFFFH
with no carry (borrow).
Subtract 1 from byte or word named COUNT in DS.
DEC CL Subtract 1 from content of CL register
DEC BP Subtract 1 from content of BP register
DEC BYTE PTR [BX] Subtract 1 from byte at offset [BX] in DS.
DEC WORD PTR [BP] Subtract 1 from a word at offset [BP] in SS.
DAA (DECIMAL ADJUST AFTER BCD ADDITION)
• This instruction is used to make sure the result of adding two packed BCD
numbers is adjusted to be a BCD number.
• The result of the addition must be in AL for DAA to work correctly.
• If the lower nibble in AL after an addition is greater than 9 or AF was set by the
addition, then the DAA instruction will add 6 to the lower nibble in AL.
• If the result in the upper nibble of AL in now greater than 9 or if the carry flag
was set by the addition or correction, then the DAA instruction will add 60H to
AL.
• Let AL = 59 BCD, and BL = 35 BCD
• ADD AL, BL AL = 8EH; lower nibble > 9, add 06H to AL
• DAA AL = 94 BCD, CF = 0
• Let AL = 88 BCD, and BL = 49 BCD
• ADD AL, BL AL = D1H; AF = 1, add 06H to AL
• DAA AL = D7H; upper nibble > 9, add 60H to AL
• AL = 37 BCD, CF = 1
• The DAA instruction updates AF, CF, SF, PF, and ZF; but OF is undefined
DAS (DECIMAL ADJUST AFTER BCD SUBTRACTION)
• This instruction is used after subtracting one packed BCD number
from another packed BCD number, to make sure the result is correct
packed BCD.
• The result of the subtraction must be in AL for DAS to work correctly.
• If the lower nibble in AL after a subtraction is greater than 9 or the AF
was set by the subtraction, then the DAS instruction will subtract 6
from the lower nibble AL.
• If the result in the upper nibble is now greater than 9 or if the carry
flag was set, the DAS instruction will subtract 60 from AL.
• Let AL = 86 BCD, and BH = 57 BCD
• SUB AL, BH ; AL = 2FH; lower nibble > 9, subtract 06H from AL
• AL = 29 BCD, CF = 0
Example 2
• Let AL = 49 BCD, and BH = 72 BCD
• SUB AL, BH AL = D7H; upper nibble > 9, subtract 60H from AL
• DAS AL = 77 BCD, CF = 1 (borrow is needed)
• The DAS instruction updates AF, CF, SF, PF, and ZF; but OF is undefined
Flag Register ( 4 )
• MOV DX, CX
• MOV AL, AH REGISTER BX REGISTER AX
• MOV CL, AH
• MOV SI,DI
• MOV SP,BP
Immediate addressing
• Instruction itself specifies the data
• Data appears in the memory location immediately
after the opcode
• Operates on word or byte
• Instruction format
Ex: MOV CH, 3Ah
00000-1048575d
Memory Segmentation
Memory Segmentation
Physical address generation in 8086
• The 20-bit physical address is generated by adding 16-bit contents
of a segment register with a 16-bit offset value (also called
Effective address) which is stored in corresponding default register
(IP, BX, SI, DI, BP or SP)
• Different segments have different default register for offset
• Ex: IP is default register for code segment
• BIU always appends 4 zeros automatically to the 16-bit address of
the segment register (to make it 20 bit) because it knows that the
starting address of the segment always ends with 4 zeros.
Physical Address Calculation
Physical address generation for CS
Physical address generation for DS
Physical address generation for SS
Calculation of Physical address-examples
• MOV [BX+SI+10h], AX
Instruction Format
• The 8086 instruction sizes vary from one to six bytes.
Depending on the type of coding, an instruction may
have more than one Hexcode
Instruction Format
• The OP code field occupies 6-bits.It defines the operation to
be carried out by the instruction.
• Register Direct bit (D) occupies one bit. It defines whether the
register operand in byte 2 is the source or destination
operand.
• D=1 Specifies that the register operand is the destination
operand.
• D=0 indicates that the register is a source operand.
• Data size bit (W) defines whether the operation to be
performed is an 8 bit or 16 bit data
• W=0 indicates 8 bit operation
• W=1 indicates 16 bit operation
Instruction set
MOD Function
00 No displacement
01 8 bit sign extended displacement
10 16 bit displacement
11 R/M is a register
Register assignments for the REG field and R/M field (MOD=11)
REG W=0 W=1
000 AL AX
001 CL CX
010 DL DX
011 BL BX
100 AH SP
101 CH BP
110 DH SL
111 BH DI
R/M Memory addressing
R/M MOD=00 MOD=01 MOD=10
000 (BX)+(SI) (BX)+(SI)+D8 (BX)+(SI)+D16
001 (BX)+(DI) (BX)+(DI)+D8 (BX)+(DI)+D16
010 (BP)+(SI) (BP)+(SI)+D8 (BP)+(SI)+D16
011 (BP)+(DI) (BP)+(DI)+D8 (BP)+(DI)+D16
100 (SI) (SI)+D8 (SI)+D16
101 (DI) (DI)+D8 (DI)+D16
110 DIRECT ADDRESS (BP)+D8 (BP)+D16