8086 Microprocessor Notes v3.0
8086 Microprocessor Notes v3.0
➢ General Diagram of
Microcomputer and CPU
➢ Architecture and Features
of 8086
➢ Memory Addressing
➢ Assembly Instruction Set of
8086
8086
➢ Buffering
➢ Memory Interface
➢ I/O Interface
MICROPROCESSOR
➢ Subroutines
➢ Delay Time
➢ Sheet 1
[NOTES] - VERSION
➢ Sheet 2
➢ 1st Term Midterm 3.0
2017/2018
➢ Sheet 3
➢ Sheet 4 Helwan University
➢ Sheet 5
Faculty of Engineering - Helwan Branch
➢ Sheet 6
3rd Computer Engineering
➢ 2nd Term Midterm
2017/2018
Version Updates
References
Table of Contents
Version Updates ........................................................................................................................................... 1
Table of Contents ......................................................................................................................................... 3
General Diagram of Microcomputer and CPU............................................................................................. 5
Architecture and Features of 8086 .............................................................................................................. 7
❖ Architecture of 8086......................................................................................................................... 7
❖ Features ............................................................................................................................................ 7
❖ General-Purpose Registers Vs Special-Purpose Registers............................................................... 8
❖ Functional Units of 8086 .................................................................................................................. 8
❖ Execution Unit (EU) ...................................................................................................................... 8
❖ Bus Interface Unit (BIU) ............................................................................................................... 9
Memory Addressing ................................................................................................................................... 11
❖ Addressing Modes .......................................................................................................................... 11
➢ Direct Addressing Mode............................................................................................................. 11
➢ Register Indirect Addressing Mode ........................................................................................... 11
➢ Based Addressing Mode ............................................................................................................. 11
➢ Indexed Addressing Mode ......................................................................................................... 11
➢ Base-Indexed Addressing Mode ................................................................................................ 11
➢ Base-Indexed with Displacement Addressing Mode ................................................................ 11
Assembly Instruction set of 8086 .............................................................................................................. 12
➢ Data Transfer Instructions: (MOV, PUSH, PUSHF, POP, POPF) ..................................................... 12
➢ Arithmetic Instructions: (ADD, ADC, SUB, SBB, CMP, INC, DEC, MUL, DIV) ................................. 12
➢ Logical Instructions: (AND, OR, XOR, NOT) ................................................................................... 13
➢ Execution Transfer Instructions: (JMP, CALL, RET, RETF) .............................................................. 14
➢ Iteration Instructions: (LOOP) ........................................................................................................ 15
➢ I/O Port Transfer Instructions: (IN, OUT) ...................................................................................... 15
➢ Shift Operations Instructions: (SAR, SAL, SHR, SHL) ..................................................................... 15
➢ Rotate Operations Instructions: (ROR, ROL, RCR, RCL) ................................................................. 16
❖ General Assembly Instructions Notes: (Due to Dr. Maher Mansour) .......................................... 17
Buffering ..................................................................................................................................................... 18
❖ Latch................................................................................................................................................ 18
❖ Buffers............................................................................................................................................. 18
➢ Normal Buffer (Single Input) ...................................................................................................... 18
❖ Memory locations:
Memory locations are actually 8-bits in width. So whenever 16-bit data is
accessed two consecutive 8-bit memory location. Using concept of Little-
Endian format.
• Little-Endian format: The least significant byte is always stored in the
lowest-numbered memory location, and the most significant byte is stored
in the highest.
❖ I/O Ports:
Like Memory, I/O ports are actually 8-bits in width. So whenever 16-bit port is
accessed two consecutive 8-bit ports are actually addressed.
❖ Features
• Data Bus (Size): (16-bit Internal/External) Microprocessor.
• Address Bus: 20-bit.
• Memory: can access up to 1 MByte of memory.
General laws:
Memory Space(Size) = (2^Address Bus) [unit of memory location width(capacity)]
Memory Capacity = Memory Space * Memory Location Capacity [bit]
= (2^Address Bus) * Memory Location Capacity [bit]
• I/O: can access (2^16 = 64K) I/O’s.
• Pipelining: supports pipelined architecture, it uses 2 stages of pipelining
Fetch Stage and Execute Stage.
▪ Pipelining means fetching the next instruction while the current is
executed.
▪ Fetch Stage can prefetch up to 6 bytes of instructions and store them in
the queue (cache).
• General-Purpose(Multipurpose) Registers:
Include AX, BX, CX, DX, BP, DI, and SI.
These registers hold various data sizes (bytes or words) and are used for
almost any purpose, as dictated by a program.
For some instructions maybe, a multipurpose register has a special
purpose, but is generally considered to be a multipurpose register.
• Special-Purpose Registers:
Include IP, SP, and FLAGS, and the segment registers include CS, DS, SS,
and ES.
These registers are used for a certain purpose only.
• ES (Extra Segment): for memory locations that deals with extra destination
data (Arrays, Strings). Works with [SI, DI].
▪ Calculating the absolute (actual) address:
SegmentRegisterValue:RegisterValue(OffsetAddressValue)
EX:
89AB:F012 ->89AB*10 -> 89AB0 (SegmentRegisterValue * 10Hex)
F012 -> 0F012
----- +
98AC2 (The Absolute Address [20-bit])
✓ Before we get into the Assembly Instruction set let’s first know how
we can using and write address in our Instructions.
-----------------------------------------------------------------------------------------------
Memory Addressing
▪ To access the content of a memory location having its address we write
the instruction operand like that: [address]
▪ The address can be only consisting of any combination from (BX, BP, SI, DI,
or a direct displacement 8-bit/16-bit)
➢ Note we can’t use (BX) and (BP) together.
➢ Note we can’t use (SI) and (DI) together.
✓ Note: memory location is 8-bit so when we store or read a 16-bit data it use
two sequential locations the first for the lowest 8-bit and the second for the
highest 8-bit.
❖ Addressing Modes
➢ Direct Addressing Mode
• [displacement] like [1111H]
➢ Register Indirect Addressing Mode
• [BX] or [BP] or [SI] or [DI]
➢ Based Addressing Mode
• [BX/BP + displacement 8-bit/16-bit] like [BX + 082H]
➢ Indexed Addressing Mode
• [SI/DI + displacement 8-bit/16-bit] like [BX + 0082H]
➢ Base-Indexed Addressing Mode
• [BX/BP + SI/DI]
➢ Base-Indexed with Displacement Addressing Mode
• [BX/BP + SI/DI + displacement 8-bit/16-bit] like [BX + SI + 04H]
➢ Arithmetic Instructions: (ADD, ADC, SUB, SBB, CMP, INC, DEC, MUL, DIV)
• ADD operand1, operand2 ~ operand1 = operand1 + operand2
• ADC operand1, operand2 ~ operand1 = operand1 + operand2 + CF
• SUB operand1, operand2 ~ operand1 = operand1 - operand2
• SBB operand1, operand2 ~ operand1 = operand1 - operand2 - CF
• CMP operand1, operand2 ~ operand1 - operand2 (update flags only)
Conditional Flags changed (C, Z, S, O, P, A)
Operand1 and Operand2 may be:
Created By: M. El-Moughazy 12 |
Page
8086 Microprocessor [Notes] - Version 3.0
REG, memory
memory, REG
REG, REG
REG, immediate
memory, immediate
• INC operand1 ~ operand1 = operand1 + 1
• DEC operand1 ~ operand1 = operand1 – 1
Conditional Flags changed (Z, S, O, P, A)
Conditional Flags unchanged (C)
Operand1 may be:
REG
memory
• MUL operand1
(Unsigned Multiply)
If operand1 refer to 8-bit ~ AX = AL * operand1
If operand1 refer to 16-bit ~ (DXAX) = AX * operand1
Conditional Flags changed (C, O) CF=OF=0 if high section of result is zero.
Conditional Flags unchanged (Z, S, P, A)
Operand1 may be:
REG
memory
• DIV operand1
(Unsigned Divide)
If operand1 refer to 8-bit ~ AL = AX / operand1
AH = reminder
If operand1 refer to 16-bit ~ AX = (DXAX) / operand1
DX = reminder
Conditional Flags unchanged (C, Z, S, O, P, A)
Operand1 may be:
REG
memory
memory, CL
REG, CL
❖ General Assembly Instructions Notes: (Due to Dr. Maher Mansour)
• If an instruction that we know in 8086 needs two operands. It
may be given with only one operand and the other operand will
be Al or AX.
EX:
AND Al,05H ~ AND 05H
AND Ax,0506H ~ AND 0506H
• It’s preferred to write the immediate value of a port number like:
(immediate) instate of immediate
EX:
IN AL, (00H)
OUT (00H), AL
Buffering
❖ Latch
Latch is an electronics component that works on coping the data form the
input at a certain moment and hold it on the output. Like: D-Flip Flop
LE Q
1 D
0 Q(t-1)
❖ Buffers
Buffer is an electronics component that works on coping the data form the
input and represent it on the output with isolation between I/P and O/P.
➢ Tri-State Buffer
has two inputs as a data input and a control input.
This control line controls the buffer to work on buffering the input data or to
make the O/P high impedance.
➢ Bi-Directional Buffer
Using two Tri-State Buffers constructing one bi-directional buffer and
control the direction using a control line
Like Active High Non-Inverting Bi-directional Buffer:
DIR(AB/BA) OE
0 0 A&B High Impedance
0 1 A = B, (A B)
1 0 A&B High Impedance
1 1 B = A, (B A)
So, depending on the type of the two Tri-State buffers can construct:
Active High Non-Inverting Bi-directional Buffer
Active High Inverting Bi-directional Buffer
Active Low Non-Inverting Bi-directional Buffer
Active Low Inverting Bi-directional Buffer
▪ Latched Uni-Directional Buffer: the latch use to hold (save) last value and the
buffer to avoid short circuit on buses and to provide additional power to the
value transferred.
Has two pins:
- OE (O/P Enable): is active low allow the buffer to transfer the value else
its O/P will be high impedance.
- LE (Latch Enable): is active high allow the latch to get a new value to hold
it.
Created By: M. El-Moughazy 21 |
Page
8086 Microprocessor [Notes] - Version 3.0
▪ Bio-Directional Buffer: this buffer allows the value to transfer in two directions
using “DIR” pin to choose which direction will be active.
Has two pins:
- OE (O/P Enable): is active low allow the buffer to transfer the value else
its O/P will be high impedance.
- DIR (Direction): choose the direction for which the buffer works
according to its value.
▪ There is a time multiplexing between Data and Address buses (AD0 – AD15)
▪ DEN (Data Enable): is active low pin indicates that the multiplexing lines have
data at that moment.
▪ DT/R (Data Transmit/Receive): high value indicates that the data is
transmitting from the micro, low value indicates that the data is receiving to
the micro.
▪ ALE (Address Latch Enable): is active high indicates that the multiplexing lines
have address at that moment.
▪ BHE (Byte High Enable): is active low indicates that the higher byte of data
bus is used.
▪ A0 (Least Bit of Address Bus): is active low to indicates that the least byte
of data bus is used.
▪ IO (Input Out): is active low indicates that the Data bus is dealing with the IO
devices at that moment.
▪ RD (Read): is active low indicates the current operation is reading using data
bus.
▪ WR (Read): is active low indicates the current operation is writing using data
bus.
▪ Control Bus: (all are active low)
o MW: Memory write
o MR: Memory Read
o IOW: IO write
o IOR: IO read
Memory Interface
❖ Memory Types
RAM ROM
Random Access Memory Random Only Memory
Volatile Non-Volatile
SRAM DRAM ROM PROM EPROM EEPROM UVEPROM
Static RAM Dynamic Programable Erasable Electrical Ultra-Violet
RAM ROM PROM EPROM EPROM
fabricated fabricated
using using
Latches Capacitors
Don’t need Need
Refreshment Refreshment
Circuit Circuit
I/O Interface
Like Memory, I/O ports are actually 8-bits in width. So whenever 16-bit port is
accessed two consecutive 8-bit ports are actually addressed. And divided into
Even and Odd banks.
❖ I/P Port
❖ O/P Port
❖ PPI
Refer to Peripheral Programmable Interface
❖ Mapping
Subroutines
A subroutine is a special program perform a specific task that can be
called for execution from any point in a program.
Proper Subroutine:
Elements of subroutine:
Example:
; Main
MOV AL,05H
.
CALL XX
HLT
XX: PUSH AX
MOV AL, 04H
.
POP AX
RET
We can use nested subroutines but must be careful about going into
infinite loop of calls.
Delay Time
Subroutines can be used to perform software delay function.
Example:
; Main:
.
CALL DELAY ; 19 CLK
.
HLT
DELAY:
MOV CX, Immediate ; 4 CLK
LOOP0:
NOP ; 3 CLK
LOOP LOOP0 ; 17/5 CLK
RET ; 16 CLK
3. What is the relation between Number of address lines in the Address Bus and
Memory Space?
- Memory Space = (2^ Number of Address lines)
4. The 8086 CPU has 20-bit Address Bus, what is the maximum Memory capacity
that can be connected to the 8086 CPU?
- According to General laws:
(as we know that each memory location in 8086 is only 1 Byte)
Memory capacity = (2^Address Bus) * Memory Location Capacity
Memory capacity = (2^20) * 8 = 8 Mbit
5. How many address lines we need to address the whole range of the following
memories?
Created By: M. El-Moughazy 32 |
Page
8086 Microprocessor [Notes] - Version 3.0
a. 2 KB (KB: Kbytes).
- 2^ Number of Address lines = 2 * 1024 = 2^ 11
Number of Address lines = 11 line
b. 64 KB.
- 2^ Number of Address lines = 64 * 1024 = 2^ 16
Number of Address lines = 16 line
c. 1 MB.
a. IP.
- IP (Instruction Pointer register): point to the next instruction in a section
of memory defined as a code segment. That will be fetched to be executed
by the EU.
b. SP.
c. FR.
8. What are the Indexing Registers, and what are they used for?
- SI (Source Index register), DI (Destination Index register), BX (Base Index
register)
a. CF (Carry Flag).
- CF = 0 if the result doesn’t send a carry
CF = 1 if the result sends a carry
b. PF (Parity Flag).
- PF = 0 if the result lowest 8-bit contains odd number of 1’s
PF = 1 if the result lowest 8-bit contains even number of 1’s
c. ZF (Zero Flag).
- ZF = 0 if the result doesn’t = 0
ZF = 1 if the result = 0
d. SF (Sign Flag).
- SF = 0 if the result is (+)
SF = 1 if the result is (-)
e. OF (Overflow Flag).
10. State names of the Segmentation Registers available in the 8086 CPU.
- CS (Code Segment), DS (Data Segment), SS (Stack Segment), ES (Extra Segment)
11. Find the actual memory addresses of the instructions having the following
CS:IP combinations:
a. CS = 1000H, IP = 2000H.
Created By: M. El-Moughazy 34 |
Page
8086 Microprocessor [Notes] - Version 3.0
b. CS = 1A00H, IP = B000H.
12. Find the actual memory addresses for these register values, Given that, CS =
0200H, DS = 1544H, SS = 5000H:
a. IP = 2350H.
- CS:IP → 0200H:2350H → 02000H + 2350H = 04350H
b. BX = 1300H.
- DS:BX → 1544H: 1300H → 15440H + 1300H = 16740H
c. SP = FFF0H.
- SS:SP → 5000H: FFF0H → 50000H + FFF0H = 5FFF0H
2. Write an 8086 assembly program to add the value 05H to the contents of each
of the registers BL, CL, DL. Assuming BL=11H, CL=22H, DL=33H.
- MOV BL,11H
MOV CL,22H
MOV DL,33H
ADD BL,05H
ADD CL,05H
ADD DL,05H
RET
MOV [BX],CL
DEC BX
DEC CL
JGE L
RET
4. Write an 8086 assembly program to add the two numbers 23F9H and 9A35H,
and save the result at memory locations 7100H, 7101H, and 7102H.
- MOV AX,23F9H
ADD AX,9A35H
MOV [7100H], AX; SAVING THE MAIN VALUE 16-BIT IN 7100H&7101H
MOV AX,0000H
ADC AX,0000H
MOV [7102H], AL; SAVING CARRY BECAUSE WE HAVE ONE EXTRE MEMORY “7102H”
RET
5. Write an 8086 assembly program to add the two numbers F3A56BH and
78B6A9H, and save the result at memory locations 7100H, 7101H, 7102H, and
7103H. *
- MOV AX, 0A56BH; SPLIT THE 24-BIT NUMBER ON TO (BLAX)
MOV BL,0F3H
ADD AX,0B6A9H
ADC BL,78H
MOV [7100H], AX; SAVING THE FIRST 16-BIT OF THE ANSWER TO 7100H&7101H
MOV [7102H], BL; SAVING THE NEXT 8-BIT OF THE ANSWER TO 7102H
MOV BL,00H
ADC BL,00H
MOV [7103H],BL ; SAVING CARRY BECAUSE WE HAVE ONE EXTRE MEMORY “7103H”
RET
in memory locations 710AH to 710EH, then save the results in memory locations
7110H to 7114H, respectively. *
- MOV BX,0004H
L:
MOV AL,[BX+7101H]
ADD AL,[BX+710AH]
MOV [BX+7110H],AL
DEC BX
JGE L
RET
11. Draw a flowchart and write an 8086 assembly program to divide the contents
of register BL by the contents of register BH, save the result in AL, and the
remainder in AH. Don’t use the “DIV” instruction. (Assume that BL > BH, BH≠ 0)
- ;IF YOU NEED TO UNDERSTAND THE CONSEPT SEE :
; [Link]
; Assume that BL > BH, BH != 0
MOV AL,00H ; INTIAL RESULT = 0
MOV AH,BL ; INITIAL REMINDER = ALL THE BIG NUMBER
L:
SUB AH,BH
INC AL
CMP AH,BH ; IF THE REMINTER STILL CONTAIN VALUE MOR THAN THE LOW NUMBER
JGE L
RET
12. Write an 8086 assembly program to calculate the factorial of an integer in the
accumulator, assuming that the result can reside in one byte register. Send the
result to register BX.
- MOV CX,AX
MOV AX,01H
L:
MUL CL
LOOP L
MOV BX,AX
RET
Created By: M. El-Moughazy 40 |
Page
8086 Microprocessor [Notes] - Version 3.0
13. Within the address range 1900H 191FH. Determine the content of BL, BH,
and DL registers in which: BL = Number of Positive values. BH = Number of
Negative values. DL = Number of Zero values.
- MOV BL, 00H ; INITIALIZE THE COUNTER
MOV BH, 00H ; INITIALIZE THE COUNTER
MOV DL, 00H ; INITIALIZE THE COUNTER
MOV SI,191FH
L:
CMP [SI],00H
JZ LZERO
JS LNEGATIVE
INC BL ; IT’S POSITIVE
LX:
DEC SI
CMP SI,1900H
JGE L
RET
LZERO:
INC DL
JMP LX
LNEGATIVE:
INC BH
JMP LX
RET
14. Write an 8086 assembly program to always check the content of the input
port 35H. If the content is positive, put it in memory location 7200H. While if
negative, put it on output port 03H.
- L:
IN AL,(35H)
CMP AL,00H
JG LPOSITIVE
JS LNEGATIVE
JMP L
RET
Created By: M. El-Moughazy 41 |
Page
8086 Microprocessor [Notes] - Version 3.0
LPOSITIVE:
MOV [7200H],AL
JMP L
LNEGATIVE:
OUT )03H(,AL
JMP L
RET
15. On a production line system of one factory the products are conveyed using
moving belts. At the end of the belt, product packaging takes place. Each package
contains 12 products. There is a photo cell near the end of the belt (connected to
bit7 of port 55H) that generates a positive logic signal when a product passes in
front of it. Write an 8086 assembly program to control the belt-motor (bit 0 of
port 00H) so as to stop it when product count reaches 12 to allow for the packing
process. When packaging is completed a worker may restart the belt-motor
manually through a switch (connected to bit1 of port 00H).
- ; FIRST SOLUTIOUN (LIKE THE IDEA OF N.16-FIRST SOLUTION)
; USE (BL) TO STORE THE LAST READ OF I/P SENSOR
; USE (CL) AS OUR COUNTER
START:
MOV AL,01H
OUT )00H(,AL ; RUN THE BELT-MOTOR
MOV CL,00H
MOV BL,00H
L:
IN AL,(55H)
AND AL,80H
ROL AL,01H ; ROTATE TO AVOID THE OVERFLOW IN CALCULATION (signed numbers)
CMP AL,BL
MOV BL,AL
JNL L ; THE LAST ARITMATIC OPERATION WAS “CMP”
INC CL
CMP CL,0CH
JL L
MOV AL,00H
OUT (00H),AL
LSWITCH:
IN AL,(00H)
AND AL,02H
CMP AL,00H
JZ LSWITCH
JMP START
RET
- ; SECOND SOLUTIOUN
; USE (CL) AS OUR COUNTER
START:
MOV AL,01H
OUT (00H),AL ; RUN THE BELT-MOTOR
MOV CL,00H
L:
IN AL,(55H)
SHL AL,01H
JNC L
STILLINPULSE:
IN AL,(55H)
SHL AL,01H
JC STILLINPULSE
INC CL
CMP CL,0CH
JL L
MOV AL,00H
OUT (00H),AL ; STOP THE BELT-MOTOR
LSWITCH:
IN AL,(00H)
AND AL,02H
CMP AL,00H
JZ LSWITCH
JMP START
RET
16. In mid-town there is a garage that can hold a maximum capacity of 200 cars.
There are two photo-cells, one at the entrance and the other at the exit point,
each of which generates a positive pulse signal when a car passes in-front of it.
Write an 8086 assembly program to control one big red light to show the driver
whether there is an empty place for his car, or the garage is full. Assuming that: -
Entrance photo-cell is connected to bit0 of input port 00H. - Exit photo-cell is
connected to bit1 of input port 00H. - The Red (Full) Light is connected to bit0 of
output port 00H.
- ; USE (CL) AS OUR COUNTER
; USE (BL) AND (BH) TO STORE THE CURRENT READ OF I/P SENSORS
; USE (DL) AND (DH) TO STORE THE LAST READ OF I/P SENSORS
;(AT THE PULSE END "CURRENT READ < LAST READ" )
Created By: M. El-Moughazy 43 |
Page
8086 Microprocessor [Notes] - Version 3.0
MOV CL,00H
MOV BX,00H
MOV DX,00H
MOV AL,00H
OUT (00H),AL
L:
MOV DL,BL
MOV DH,BH
IN AL,(00H)
MOV BL,AL
AND BL,01H
MOV BH,AL
AND BH,02H
CMP BL,DL
JL LENTRANCE
LENTRANCERET:
CMP BH,DH
JL LEXIT
JMP L
RET
LENTRANCE:
INC CL
CMP CL,0C8H
JZ LFULL
JMP LENTRANCERET
LFULL:
MOV AL,01H
OUT (00H),AL
JMP LENTRANCERET
LEXIT:
DEC CL
MOV AL,00H
OUT (00H),AL
JMP L
RET
- ;THE SECOND SOLUTION
; USE (CL) AS OUR COUNTER
; USE (BL) TO STORE THE LAST READ STATE OF I/P SENSORS
; LAST --> CURRENT
; 00 --> ** 0 --> * ~ ------
; 01 --> 00 1 --> 0 ~ IN
; 01 --> 10 1 --> 2 ~ IN
; 01 --> 11 1 --> 3 ~ ------
INC CL
CMP CL,0C8H
JZ LFULL
JMP L
LFULL:
MOV AL,01H
OUT (00H),AL
JMP L
LEXIT:
DEC CL
MOV AL,00H
OUT (00H),AL
JMP L
RET
17. Draw the schematic diagram and write an 8086 assembly program to
continuously read 8 input switches and control 8 output LEDs. So that if a switch
is LOW, then its corresponding LED is OFF, and if the switch is HIGH, then its
corresponding LED is ON, and so on. The 8 switches are on input port 00H The 8
LEDs are on output port 05H
- L:
IN AL,(00H)
OUT (05H),AL
JMP L
RET
Task [8086]
1. In the range 1900H to 1A00H, Find the Max. & Min. Numbers and their
address. Store Min. value at AL and its address at SI, Max. value at AH and its
address at DI.
- MOV BX,1900H
MOV SI,1900H
MOV DI,1900H
MOV AL, [SI]
MOV AH, [DI]
L:
INC BX
CMP [BX], AL
JL MINFOUND
MINFOUNDRET:
CMP [BX], AH
JG MAXFOUND
MAXFOUNDRET:
CMP BX,1A00H
JL L
RET
MINFOUND:
MOV AL, [BX]
MOV SI, BX
JMP MINFOUNDRET
MAXFOUND:
MOV AH, [BX]
MOV DI, BX
JMP L MAXFOUNDRET
RET
2.
a. Write an assembly program:
I. To always invert the most two bits in the input port 25H.
- L:
IN AL,(25H)
XOR AL,11000000B
JMP L
RET
II. To put the maximum value of the data stored in memory locations
A2BC to A3AE in the output port 37H.
- MOV BX,0A2BCH
MOV AL,[BX]
L:
INC BX
CMP AL,[BX]
JL MAXFOUND
MAXFOUNDRET:
CMP BX,0A3AEH
JL L
OUT (37H),AL
RET
MAXFOUND:
MOV AL,[BX]
JMP MAXFOUNDRET
RET
7. Draw a complete block diagram to show how the Intel 8086 CPU buffering is
done to prepare its buses for interfacing.
8. Fill each empty field in the following table with the number of times the
corresponding control line in its column is asserted (activated) during
execution cycle.
Control Line MEMR MEMW IOR IOW BHE
Instruction
MOV AL, 89H 1 1 1 1 1
MOV [0E100H], AL 1 0 1 1 1
MOV AX, [E100H] 0 1 1 1 0
IN AL, (00H) 1 1 0 1 1
OUT (00H), AL 1 1 1 0 1
9. What is meant by time multiplexing between data and address buses in the
intel 8086 microprocessor? And why?
- There are 16 shared lines between Data and Address buses (AD0:AD15)
using time multiplexing and controlled by (ALE and DEN) to indicate the
lines carry data or address.
- To Minimize the number of pins and chip area.
10. What is the control line that the intel 8086 microprocessor provides to
isolate address and data buses from each other? Draw a block diagram to
show how this control line is used for this purpose.
- Address Latch Enable (ALE): Active High,
Data Enable (DEN): Active Low.
Diagram included in Question No.7 Answer
2. Show how to connect 64 KB EEPROM to the Intel 8086 CPU using memory
chips of 2 KB.
- Solution using Memory Partial Decoding Approach
64 KB / 2 KB = 32 Chips (16 Even and 16 Odd)
64 KB = 216 B → Total Used Address Lines = 16 Line (A15-A0)
2 KB = 211 B → 11 Address Lines (A1:A11) for each chip
Chips A19-A16 A15-A12 A11-A8 A7-A4 A3-A0 Address (HEX)
X 0 0 0 0 X0000
64 KB X F F F F XFFFF
EEPROM
3. Show how to connect 128 KB EEPROM to the Intel 8086 CPU using memory
chips of 4 KB. - Solution using Memory Partial Decoding Approach
4. Show how to connect 256 KB memory to the intel 8086 CPU by using
memory chips of 2 KB and 4 blocks.
- Solution using Memory Partial Decoding Approach
Block Size = 256 KB/4 Blocks = 64 KB/Block
5. Show how to connect 16 KB EEPROM and 16 KB RAM to the intel 8086 CPU,
using 8KB EEPROM chips and 8KB RAM chips. And draw the corresponding
memory map. - Solution using Memory Partial Decoding Approach
- 16 KB/8 KB = 2 Chips (1 Even and 1 Odd)
8 KB = 213 B → 13 Address Lines (A1:A13) for each chip
(16 KB + 16 KB) = 215 B → Total Used Address Lines = 15 Line (A14-A0)
Chips A19-A16 A15-A12 A11-A8 A7-A4 A3-A0 Address (BIN)
X (X000) bin 0 0 0 XXXXX000000000000000
6. Show how to connect 16 KB EEPROM and 4 KB RAM to the intel 8086 CPU,
using 8KB EEPROM chips and 2KB RAM chips. And draw the corresponding
memory map.
- Solution using Memory Partial Decoding Approach
EEPROM:
16 KB/8 KB = 2 Chips (1 Even and 1 Odd)
8 KB = 213 B → 13 Address Lines (A1:A13) for each chip
RAM:
4 KB/2 KB = 2 Chips (1 Even and 1 Odd)
2 KB = 211 B → 11 Address Lines (A1:A11) for each chip
USE A14 to separate between EEPROM and RAM
(16 KB + 4KB) <= 215 B → Total Used Address Lines = 15 Line (A14-A0)
Chips A19-A16 A15-A12 A11-A8 A7-A4 A3-A0 Address (BIN)
16 KB X (X000) bin 0 0 0 XXXXX000000000000000
EEPROM X (X011) bin F F F XXXXX011111111111111
4 KB X (X100) bin 0 0 0 XXXXX100000000000000
RAM X (X100) bin F F F XXXXX100111111111111
2. Show how to connect the intel 8086 CPU with the following:
a. 2KB EEPROM.
b. 2KB RAM.
c. I/P port (F3H).
d. I/P port (E6H).
Created By: M. El-Moughazy 64 |
Page
8086 Microprocessor [Notes] - Version 3.0
3. Show how to connect the intel 8086 CPU with the following:
a. 4KB EEPROM.
b. 4KB RAM.
c. I/P port (A327H), using I/O mapped approach.
d. O/P port (05H).
- Solution using Memory Partial Decoding Approach
4 KB EPPROM (2 KB Even and 2 KB Odd)
4 KB RAM (2 KB Even and 2 KB Odd)
2 KB = 211 B → 11 Address Lines (A1:A11) for each chip
(4 KB + 4 KB) = 213 B → Total Used Address Lines = 13 Line (A12-A0)
I/P Port (A327H) → (1010001100100111) BIN
O/P Port (05H) → (0101) BIN
Chips A19-A16 A15-A12 A11-A8 A7-A4 A3-A0 Address (BIN)
4 KB X (XXX0) bin 0 0 0 XXXXXXX0000000000000
EEPROM X (XXX0) bin F F F XXXXXXX0111111111111
4 KB X (XXX1) bin 0 0 0 XXXXXXX1000000000000
RAM X (XXX1) bin F F F XXXXXXX1111111111111
4. Show how to connect the intel 8086 CPU with the following:
a. 4KB EEPROM.
b. 2KB RAM.
c. I/P port (1222H), using memory mapped approach.
d. O/P port (1223H), using memory mapped approach.
- 1st Solution using Memory Partial Decoding Approach
EEPROM:
4 KB (2 KB Even and 2KB Odd)
2 KB = 211 B → 11 Address Lines (A1:A11) for each chip
RAM:
2 KB (1 KB Even and 1 KB Odd)
1 KB = 210 B → 10 Address Lines (A1:A10) for each chip
USE A12 to separate between EEPROM and RAM
(4 KB + 2 KB) <= 213 B → Total Used Address Lines = 13 Line (A12-A0)
I/P Port (1222H) → (0001 0010 0010 0010) BIN
O/P Port (1223H) → (0001001000100011) BIN
USE A13 to separate between Memory and I/O Ports
Chips A19-A16 A15-A12 A11-A8 A7-A4 A3-A0 Address (BIN)
4 KB X (XX10) bin 0 0 0 XXXXXX10000000000000
EEPROM X (XX10) bin F F F XXXXXX10111111111111
2 KB X (XX11) bin 0 0 0 XXXXXX11000000000000
RAM X (XX11) bin F F F XXXXXX11111111111111
5. Show how to connect the intel 8086 CPU with the following:
a. 4KB EEPROM.
b. 4KB RAM.
c. PPI chip at base addresses 30H.
- Solution using Memory Partial Decoding Approach
4 KB EEPROM (2 KB Even and 2 KB Odd)
4 KB RAM (2 KB Even and 2 KB Odd)
2 KB = 211 B → 11 Address Lines (A1:A11) for each chip
USE A12 to separate between EEPROM and RAM
(4 KB + 4 KB) = 213 B → Total Used Address Lines = 13 Line (A12-A0)
Chips A19-A16 A15-A12 A11-A8 A7-A4 A3-A0 Address (BIN)
4 KB X (XXX0) bin 0 0 0 XXXXXXX0000000000000
EEPROM X (XXX0) bin F F F XXXXXXX0111111111111
4 KB X (XXX1) bin 0 0 0 XXXXXXX1000000000000
RAM X (XXX1) bin F F F XXXXXXX1111111111111
PPI:
Base Address (30H) → (00110000) BIN
PPI-A1 → A2 PPI-A0 → A1 Address (Hex)
Port A 0 0 30
Port B 0 1 32
Port C 1 0 34
CWR 1 1 36
6. Show how to connect the intel 8086 CPU with the following:
a. 4KB EEPROM.
b. 4KB RAM.
c. Two PPI chips:
i. One PPI at base addresses 50H
ii. One PPI and base address 2100H, using memory mapped approach.
st
- 1 Solution using Memory Partial Decoding Approach
4 KB EEPROM (2 KB Even and 2 KB Odd)
4 KB RAM (2 KB Even and 2 KB Odd)
2 KB = 211 B → 11 Address Lines (A1:A11) for each chip
USE A12 to separate between EEPROM and RAM
(4 KB + 4 KB) = 213 B → Total Used Address Lines = 13 Line (A12-A0)
USE A13 to separate between Memory and I/O Ports
Chips A19-A16 A15-A12 A11-A8 A7-A4 A3-A0 Address (BIN)
4 KB X (XX00) bin 0 0 0 XXXXXX00000000000000
EEPROM X (XX00) bin F F F XXXXXX00111111111111
4 KB X (XX01) bin 0 0 0 XXXXXX01000000000000
RAM X (XX01) bin F F F XXXXXX01111111111111
1st PPI:
Base Address (50H) → (01010000) BIN
PPI-A1 → A2 PPI-A0 → A1 Address (Hex)
Port A 0 0 50
Port B 0 1 52
Port C 1 0 54
CWR 1 1 56
2nd PPI:
Base Address (2100H) → (0010000100000000) BIN
PPI-A1 → A2 PPI-A0 → A1 Address (Hex)
Port A 0 0 2100
Port B 0 1 2102
Port C 1 0 2104
CWR 1 1 2106
1st PPI:
Base Address (50H) → (01010000) BIN
PPI-A1 → A2 PPI-A0 → A1 Address (Hex)
Port A 0 0 50
Port B 0 1 52
Port C 1 0 54
CWR 1 1 56
nd
2 PPI:
Base Address (2100H) → (0010000100000000) BIN
PPI-A1 → A2 PPI-A0 → A1 Address (Hex)
Port A 0 0 2100
Port B 0 1 2102
Port C 1 0 2104
CWR 1 1 2106
2.
a. Design a microcomputer has the following:
i. Intel 8086 CPU.
ii. 2KB EEPROM.
iii. 2KB RAM.
iv. PPI chip at base address 70H.
b. Write an intel 8086 assembly program to configure the PPI chip in part (a)
such that port A is input, while ports B and C are output. Then read port A forty
[40] times and check its content. If the content is odd, put it in port B. if the
content is even, put it in port C.
- Solution using Memory Partial Decoding Approach
2 KB EPPROM (1 KB Even and 1 KB Odd)
2 KB RAM (1 KB Even and 1 KB Odd)
1 KB = 210 B → 10 Address Lines (A1:A10) for each chip
Use A11 to separate between EEPROM and RAM
(2 KB + 2 KB) = 212 B → Total Used Address Lines = 12 Line (A11-A0)
Chips A19-A16 A15-A12 A11-A8 A7-A4 A3-A0 Address
(HEX)
2 KB X X (0000) bin 0 0 XX000
EEPROM X X (0111) bin F F XX7FF
2 KB X X (1000) bin 0 0 XX800
RAM X X (1111) bin F F XXFFF
PPI:
Base Address (70H) → (01110000) BIN
PPI-A1 → A2 PPI-A0 → A1 Address (Hex)
Port A 0 0 70
Port B 0 1 72
Port C 1 0 74
CWR 1 1 76
Program:
START:
MOV AL, 90H; CWR → (10010000) BIN
OUT (76H), AL
MOV CX, 028H; 28H → 40 DEC
STARTOFLOOP:
IN AL, (70H)
MOV AH, AL
SHR AH, 01H
JNC EVEN
ODD:
OUT (72H), AL
EVEN:
OUT (74H), AL
LOOP STARTOFLOOP
RET
3.
a. Design a microcomputer has the following:
i. Intel 8086 CPU.
ii. 2KB EEPROM.
iii. 2KB RAM.
iv. PPI chip at base address BF20H.
b. Write an intel 8086 assembly program to configurated the PPI chip in part
(a) such that ports A and B are inputs, while port C is output. Then read the two
ports A and B and send the larger value to port C, while the smaller value to
memory location 2100H.
- Solution using Memory Partial Decoding Approach
2 KB EPPROM (1 KB Even and 1 KB Odd)
2 KB RAM (1 KB Even and 1 KB Odd)
1 KB = 210 B → 10 Address Lines (A1:A10) for each chip
Use A11 to separate between EEPROM and RAM
(2 KB + 2 KB) = 212 B → Total Used Address Lines = 12 Line (A11-A0)
PPI:
Base Address (0BF20H) → (1011111100100000) BIN
PPI-A1 → A2 PPI-A0 → A1 Address (Hex)
Port A 0 0 BF20
Port B 0 1 BF22
Port C 1 0 BF24
CWR 1 1 BF26
Program:
START:
MOV AL, 92H; CWR → (10010010) BIN
MOV DX, 0BF26H; LOAD CWR ADDRESS
OUT DX, AL
MOV DX, 0BF22H; LOAD PORT B ADDRESS
IN AL, DX
MOV BL, AL; PORT B READ IN BL
MOV DX, 0BF20H; LOAD PORT A ADDRESS
IN AL, DX; PORT A READ IN AL
MOV DX, 0BF24H; LOAD PORT C ADDRESS
CMP AL, BL
JGE ALARGER
BLARGER:
MOV [2100H], AL
MOV AL, BL
OUT DX, AL
RET
ALARGER:
OUT DX, AL
MOV [2100H], BL
RET
NOTE: TO SOLVE USING MEMORY MAPPED USE A12 TO SEPARATE BETWWEN MEMORY AND
I/O as Memory Partial Decoding Approach OR USE Memory Full Decoding Approach.
3. Compare between:
• Microprocessor and Microcontroller
Microprocessor Microcontroller
Chip contains only the processor Chip contains processor and all the
components of a computer (Memory,
I/o, ...)
Need other components to make Stand alone
working system
More Flexibility Less Flexibility
More components count in system Less components count is system