00_Briefly Note Microprocessor 8086
00_Briefly Note Microprocessor 8086
Contents
Contents...........................................................................................................................1
7.1 Memory locations:..............................................................................................2
7.1 I/O Ports:............................................................................................................3
2. Architecture Type......................................................................................................3
3. Architecture and Features of 8086............................................................................3
7.1 Features 8086....................................................................................................3
4. General-Purpose Registers & Special-Purpose Registers........................................4
7.1 General-Purpose (Multipurpose) Registers:......................................................4
7.1 Special-Purpose Registers:...............................................................................4
5. Functional Units of 8086...........................................................................................4
7.1 Execution Unit (EU)........................................................................................... 4
7.1 Bus Interface Unit (BIU).....................................................................................5
6. Memory Addressing..................................................................................................6
7. Instructions Set......................................................................................................... 7
7.1 Data Transfer Instructions: (MOV, PUSH, PUSHF, POP, POPF)......................7
8. Generating a Memory Address.................................................................................9
7.1 Memory and I/O Ports Locations:....................................................................10
7.1 Memory Types and Simple Interfacing............................................................10
9. 8086........................................................................................................................ 11
1
Briefly Note Microprocessor 8086
1. General Diagram of Microcomputer and CPU
Block diagram of any computer system:
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.
2
Briefly Note Microprocessor 8086
1.2 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.
2. Architecture Type
In Von Neumann architecture, programs and data are stored in the same memory
and managed by the same information-handling subsystem.
In Harvard architecture, programs and data are stored and handled by different
subsystems.
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]
Created By: Dr. Aljshamee
3
Briefly Note Microprocessor 8086
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)
4
Briefly Note Microprocessor 8086
o CF (Carry flag)
o AF (Auxiliary flag): (half-carry) carry given by D3 to D4 is AF flag.
o ZF (Zero flag)
o SF (Sign flag)
o PF (Parity flag): when the lowest 8-bit contains even number of 1’s the flag
is set. else the flag is reset.
o OF (Overflow flag): system capacity is exceeded.
Control Flags:
o IF (Interrupt flag): interrupt enable/disable flag.
o TF (Trap flag): used for single step control allows to execute one instruction
at time for debugging.
o DF (Direction Flag): used in string operation. When it is set the string bytes
are accessed from the higher memory address to the lower and vice-a-versa.
(selects either the increment or decrement mode for the DI and/or SI
registers during string instructions)
5.2 Bus Interface Unit (BIU)
It takes care of all data and address transfers on buses for EU like
writing/reading data, fetching instructions and sending address.
Instructions Queue (Cache): store up to 6 bytes of prefetched next instructions.
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.
Segment registers (CS, DS, SS, ES): used by the microprocessor to access
memory locations. [Note: our registers are 16-bit, but the address bus is 20- bit,
so we have used segmentations]
o CS (Code Segment): for memory locations where the executable program is
stored. Works with [IP].
o DS (Data Segment): for memory locations that deal with data. Works with
[BX, SI, DI].
o SS (Stack Segment): for memory locations that related to the stack. Works
with [SP, BP].
o ES (Extra Segment): for memory locations that deals with extra destination
data (Arrays, Strings). Works with [SI, DI].
Calculating the absolute (actual) address:
Physical address = [Segment address] x 10h + Offset address
0110 1000 1000 0111 0000 Segment, 16 bits, shifted 4 bits left, (or multiplied by10H)
+ 1011 0100 1010 1001 Offset, 16 bits
6. Memory Addressing
To access the content of a memory location having its address we write the
Created By: Dr. Aljshamee
5
Briefly Note Microprocessor 8086
instruction operand like that: [address]
The address can only consist of any combination from (BX, BP, SI, DI, or a direct
displacement 8-bit/16-bit)
Note:
o we can’t use (BX) and (BP) together.
o we can’t use (SI) and (DI) together.
o memory location is 8-bit so when we store or read a 16-bit data it uses two
sequential locations the first for the lowest 8-bit and the second for the highest 8-
bit.
7. Instructions Set
The 8086 microprocessor supports 8 types of instructions −
6
Briefly Note Microprocessor 8086
Data Transfer Instructions
Arithmetic Instructions
Bit Manipulation Instructions
String Instructions
Program Execution Transfer Instructions (Branch & Loop Instructions)
Processor Control Instructions
Iteration Control Instructions
Interrupt Instructions
Operand1, Operand2
REG, memory
SREG, memory
memory, REG
memory, SREG
REG, REG
REG, SREG
SREG, REG
memory, immediate
REG, immediate
o PUSH operand1
SP = SP – 2, SS:[SP] = operand (Push 16-bit into stack)
o POP operand1
operand = SS:[SP], SP = SP + 2 (Pop 16-bit from stack)
Operand1:
REG
SREG
Memory
o PUSHF NO Operand
Push the flag register to stack
o POPF NO operand
Pop the flag register from stack
7.2 Arithmetic Instructions: (ADD, ADC, SUB, SBB, INC, DEC, MUL, DIV)
7
Briefly Note Microprocessor 8086
operand1 = operand1 + operand2
o INC operand1
operand1 = operand1 + 1
o DEC operand1
operand1 = operand1 – 1
Operand1:
REG
memory
Conditional Flags changed (C, O) CF=OF=0 if the high section of result is zero. and the
Flags (Z, S, P, A) unchanged.
Operand1:
REG
memory
Operand:
REG
memory
7.3 Execution Transfer Instructions: (CMP, JMP, LOOP, CALL, RET)
CMP operand1, operand2
Created By: Dr. Aljshamee
8
Briefly Note Microprocessor 8086
operand1 - operand2 (update flags only) Conditional Flags changed (C, Z, S, O, P, A)
Operand1, Operand2:
REG, memory
memory, REG
REG, REG
REG, immediate
memory, immediate
JMP operand1
jump to label/address(operand1) (Unconditional Jump)
Operand1 is:
Label, immediate 4-byte address segment:offset
JFlag/JCondition operand1
Operand1 is:
Label, immediate 4-byte address segment:offset (conditional Jump)
CALL operand1 ~ Push IP into stack then transfer to the called address If it's a far call,
then code segment is pushed to stack as well. Operand1 may be:
label
immediate 4-byte address segment:offset
procedure name
RET No operand ~ Pop IP from stack and use to return for caller
9
Briefly Note Microprocessor 8086
The essential difference between these two architectures:
Von-Neumann Architecture Harvard Architecture
This model not a modern one This model used with modern computer
Same memory addresses are used for Separate memory addresses are used for
both data and instructions data and instructions.
When execute one instruction, required One clock cycle is enough for executing
at least two clock cycles one instruction
Cost is less to create this model Costly than Von Neumann model
CPU cannot access instructions and CPU can access instructions and
read/write data at same time read/write data at same time
This model mostly uses in signal
This model most suitable for small
processing and microcontrollers;
computers and personal computers
however, used with specific applications.
(DF, IF and TF) into (bit9-bit11) provide an control signal. Flag register exposed in figure
below:
10
Briefly Note Microprocessor 8086
The physical address is a 20-Bit address that is actually put on (address pins) of
microprocessor.
The offset address is a location within a 64K Byte segment range.
The logical address consists of a segment value and an offset address i.e., CS:IP.
The value of segment register is shifted left by four-bit positions, with its LSBs filled with
zeros. This gives a segment address. Then added a 0000 into LSBs to shift value. The
outcome of this addition is 20-Bit, as demonstrated in figure below:
The address can be only consisting of any combination from (BX, BP, SI, DI).
Therefore, 8086 has a segment register and offset register combination as illustrations
in table below:
Segment Reg. Offset Reg.
CS IP
SS SB, BP
11
Briefly Note Microprocessor 8086
DS SI, DI, BX
ES DI, SI, BX
I/O Ports: Like Memory access, the I/O ports are actually 8-Bits in width. So, whenever
16-Bit port is accessed two consecutives of 8-Bit ports are actually addressed to certain
port.
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.
Big-endian format: keeps the most significant byte of a word at the smallest memory
location and the least significant byte at the largest.
8.2 Memory Types and Simple Interfacing
There are two basic operations inside memory unit which are READ (R) or WRITE (W).
During READ operation, the data is retrieved from memory. While, in WRITE operation
a new data is saved into memory, there are two types of memory:
RAM ROM
Random Access Memory Random Only Memory
Volatile Non-Volatile
The address space is physically connected to a 16-Bit data bus by dividing the address
space into two 8-Bit banks 512K Byte of each, to configure a 1M Byte.
Created By: Dr. Aljshamee
12
Briefly Note Microprocessor 8086
Even Bank: is connected to the lower half of the 16-Bit data bus (D0 – D7) and contains
even address bytes. when A0 bit is low, the bank is selected.
Odd Bank: is connected to the upper half of the 16-Bit data bus (D8 – D15) and
contains odd address bytes. when BHE (Byte High Enable) is low, the bank is selected.
The 8086 Data can be accessed from the memory in four different ways. They are:
9. 8086
13