Professional Documents
Culture Documents
MPMC (Unit 02) Part 01
MPMC (Unit 02) Part 01
Microcontrollers (ECE3004)
8086 Microprocessor
8086 Microprocessor:
2
3
Comparison with 8085
World Length:
8085 is 8 bit microprocessor whereas 8086 is 16 bit microprocessor.
Address Bus:
8085 has 16 bit address bus and 8086 has 20 bit address bus.
Memory:
8085 can access up to KB of memory whereas 8086 can access up to MB of memory.
Instruction Queue:
8085 doesn't have an instruction queue whereas 8086 has instruction queue.
Pipelining:
8085 does not support pipelined architecture whereas 8086 supports pipelined
architecture
4
Comparison with 8085
Multiprocessing Support:
8085 does not support multiprocessing support whereas 8086 supports.
I/O:
8085 can address I/O's and 8086 can access I/O’s
Arithmetic Support:
8085 only supports integer and decimal whereas 8086 supports integer, decimal and
ASCII arithmetic.
Flag:
8085 - 5 flags (Sign Flag, Zero Flag, Auxiliary Carry Flag, Parity Flag, Carry Flag ).
8086 - 9 flags (Overflow Flag, Direction Flag, Interrupt Flag, Trap Flag, Sign Flag, Zero Flag,
Auxiliary Carry Flag, Parity Flag, Carry Flag).
5
Comparison with 8085
Multiplication and Division:
8085 doesn't support whereas 8086 supports.
Operating Modes:
8085 supports only single operating mode whereas 8086 operates in two modes.
External Hardware:
8085 requires less external hardware whereas 8086 requires more external hardware.
Cost:
The cost of 8085 is low and 8086 is high.
Memory Segmentation:
In 8085, memory space is not segmented but in 8086, memory space is segmented.
8085 vs 8086
6
7
Register Organization of 8086
What’s a Register?
• A Register is a circuit consisting of Flip-Flops which can store more than one-bit data.
The register is nothing but a sequential logic circuit in digital electronics.
• Register is very fast and efficient than other memories like RAM, ROM or external
memory.
• This is why registers occupied the top position in memory hierarchy model.
Registers of 8086
• The 8086 microprocessor has a total of fourteen registers
that are accessible to the programmer.
a) General registers
b) Segment registers
c) Index registers
d) Pointer registers
e) Status Register
a) General Purpose Registers
• The general purpose registers are used to perform arithmetic and logical operations. These registers
are used by the program to code the microprocessor.
• These all general registers can be used as either 8-bit or 16-bit registers.
AX (Accumulator Register)
BX (Base Register)
CX (Counter Register)
DX (Data Register)
a) General Purpose Registers
i. AX (Accumulator Register):
AX is used as 16-bit accumulator. The lower 8-bits of AX are designated to use as AL and
higher 8-bits as AH. AL can be used as an 8-bit accumulator for 8-bit operation.
This Accumulator used in arithmetic, logic and data transfer operations. For manipulation and
division operations, one of the numbers must be placed in AX or AL.
AL in this case contains the low order byte of the word, and AH contains the high order byte.
a) General Purpose Registers
ii. BX (Base Register):
consists of two 8-bit registers BL and BH, which can be combined together and used as a 16-
bit register BX. BL in this case contains the low order byte of the word, and BH contains the
high order byte.
This is the only general purpose register whose contents can be used for addressing the 8086
memory.
The register BX is used as address register to form physical address in case of certain
addressing modes (ex: indexed and register indirect).
a) General Purpose Registers
iii. CX (Counter Register):
consists of two 8-bit registers CL and CH, which can be combined together and used as a 16-
bit register CX. CL in this case contains the low order byte of the word, and CH contains the
high order byte.
The register CX is used default counter in case of string and loop instructions. Count register
can also be used as a counter in string manipulation and shift/rotate instruction.
Ex:
The instruction LOOP START automatically decrements CX by 1 without affecting the flags
and checks if [CX] = 0.
If it is zero, 8086 executes the next instruction; otherwise the 8086 branches to the label
START.
a) General Purpose Registers
iv. DX (Data Register):
consists of two 8-bit registers DL and DH, which can be combined together and used as a 16-
bit register DX. DL in this case contains the low order byte of the word, and DH contains the
high order byte.
It is used with AX to hold 32-bit values during multiplication and division operation (holds
the remainder of the result).
• This 1 megabyte of memory is divided into 16 logical segments. Each segment contains 64 Kbytes
of memory.
Code segment (CS) is a 16-bit register that is used for addressing memory location in the code
segment of the memory (64Kb), where the executable program is stored.
CS register cannot be changed directly. The CS register is automatically updated during far
jump, far call and far return instructions.
Stack Segment (SS) is a 16-bit register that used for addressing stack segment of the memory
(64kb) where stack data is stored.
Data Segment (DS) is a 16-bit register that points the data segment of the memory (64kb)
where the program data is stored.
Extra Segment (ES) is a 16-bit register that also points the data segment of the memory
(64kb) where the program data is stored.
SI is a 16-bit register. This register is used to store the offset of source data in data segment. In
other words the Source Index Register is used to point the memory locations in the data
segment.
DI is a 16-bit register. This is destination index register performs the same function as SI.
There is a class of instructions called string operations that use DI to access the memory
locations in Data or Extra Segment.
d) Pointer Registers
• Pointer Registers contains the offset of data(variables, labels) and instructions from their base
segments (default segments). 8086 microprocessor contains three pointer registers.
The Instruction Pointer is a register that holds the address of the next instruction to be fetched
from memory.
It contains the offset of the next word of instruction code instead of its actual address
d) Pointer Registers
ii. SP (Stack Pointer Register):
It hold the offset address of the top of the stack. Stack is a set of memory locations operating
in LIFO (Last In First Out) manner.
Base Pointer register also points the same stack segment. Unlike SP, we can use BP to access
random locations in stack memory.
e) Status Register
• The status register also called as flag register. The 8086 flag register contents indicate the results
of computation in the ALU. It also contains some flag bits to control the CPU operations.
8086 P Architecture
8086 Architecture
Architecture:
• The total architecture can be divided into two parts:
Ex:
CS = 1000H
IP = 2345H
Why?
• The 8086 can address memory. Thus it has 20-bit address bus. Registers available in can hold 16-bit of
data, thus require 2 registers to form 20-bit address.
More on BIU
• ALU
It handles all arithmetic and logical operations, like +, −, ×, /, OR, AND, NOT operations.
• Flag Register
It is a 16-bit register that behaves like a flip-flop, i.e. it changes its status according to the
result stored in the accumulator. It has 9 flags and they are divided into 2 groups −
Conditional Flags and Control Flags.
EU: Execution Unit
• Ex:
Convert
Decode Transfer of control
ADD BL, CL Opcode Control Section
Assembler signal to various units
Every segment has one segment register and one offset register. However, stack ….
segment has two offset registers: …
SP (Stack Pointer): Points to the top of the stack.
BP (Base Pointer): Can move anywhere between stack.
Suppose we have 20 data; that is pushed. The address stars decrementing and pushesFig: 8086: Stack Operation:
the values as shown in Fig. Change in address location
Now, SP(old) changes at every push and the current location will be the top of the during each PUSH
instruction.
stack as indicated by SP(new).
Suppose, by mistake the second number i.e. pushed () is wrong. you can't directly
access the memory location, randomly. However, you can pop all the 18 data from to
to get back the and change. This is impractical.
Therefore, we have another offset address called BP. It can move anywhere in stack
segment.
Memory Segmentation 00000 𝐻 XXXX H
00001 𝐻 XXXX H
40 XXXX H
iii. Data Segment 00002 𝐻 .
.
Data is stored randomly and in unstructured .
way. 0000 𝐹 𝐻 XXXX H
.
Can be stored in upward directions. .
Can be stored in downward directions. 0 XXXX H
Advantages:
It prevents overwriting.
It creates or provides lots of memory locations to store data/code.
Memory Segmentation
41
The maximum size of segment memory is
64KB. As 8086 have only 16-bit register (which
are used to form Physical Address), it can
address at a time memory. Minimum size of a
segment can be 16 bytes.
Adder
AD0-AD7 carries low order byte data and AD8-AD15 carries higher order byte data.
Address remain on the pins for ‘’ state, while data is available on the data bus during , , and states
(These are clock cycle states).
These lines are active high and floats to a tristate during interrupt acknowledgement and local bus
acknowledgement cycle.
Pin Diagram
• A19/S6, A18/S5, A17/S4, A16/S3: (Higher Address Lines and Status Signal) (35-38)
During state these are most significant address line for memory operation.
During , , and states, these lines are available for status information of I/O or memory operation.
If microprocessor is requested for interrupt and is ready to serve the interrupt, then ‘S5’ flag bit is
set. S5 = interrupt enable flag.
The ‘S3’ and ‘S4’ together indicates which segment is presently used for memory access: [Refer
Table]
0 0 Alternate Data
0 1 Stack
1 0 Code or None
1 1 Data
Pin Diagram
• /S7: (Bus High Enable and Status Signal) (34)
The is an active low pin; used to indicate transfer of higher byte data (-)over the data bus, if the pin
is selected low.
It is also used to drive chip select for odd-address memory bank or peripherals in combination with
‘A0’ bit of address.
The status information (S7) is available during , , and states. The signal is active low and is tristate
during ‘Hold’.
A0 Indication
• Ready (22)
It is available at pin 22. It is an acknowledgement signal from I/O devices that data is transferred. It is an
active high signal. When it is high, it indicates that the device is ready to transfer data. When it is low, it
indicates wait state.
• RESET (21)
It is available at pin 21 and is used to restart the execution. It causes the processor to immediately
terminate its present activity. This signal is active high for the first 4 clock cycles to RESET the
microprocessor.
• GND (20)
Ground connection for circuit.
Pin Diagram
• INTR (18)
It is available at pin 18. It is an interrupt request signal, which is sampled during the last clock cycle of
each instruction to determine if the processor considered this as an interrupt or not.
• NMI (17)
It stands for non-maskable interrupt and is available at pin 17. It is an edge triggered input, which causes
an interrupt request to the microprocessor.
• TEST (23)
This signal is like wait state and is available at pin 23. When this signal is high, then the processor has to
wait for IDLE state, else the execution continues.
• MN/MX (33)
It stands for Minimum/Maximum and is available at pin 33. It indicates what mode the processor is
to operate in; when it is high, it works in the minimum mode and vice-versa.
Pin Diagram [Minimum mode operation]
• M/ (Memory/Input Output) (28)
When it is high, it indicates memory operation and when it is low indicates the I/O operation.
The line become active in previous ‘T4’ state and remain active for current ‘T4’ cycle.
It is tri-stated during local bus “hold Acknowledgement”.
• ALE (25)
It stands for address enable latch and is available at pin 25.
A positive pulse is generated each time the processor begins any operation. This signal indicates the
availability of a valid address on the address/data lines.
Pin Diagram [Minimum mode operation]
• DT/ (27)
It stands for Data Transmit/Receive signal and is available at pin 27. It decides the direction of data
flow through the trans-receiver.
Active High: Sends data from the processor.
Active Low: Receives data into processor.
Tristate during ‘Hold acknowledgement’
Indication
0 0 0 Interrupt Ack.
0 1 1 Halt
1 0 0 Code Access
1 0 1 Read Memory
1 1 0 Write Memory
1 1 1 Passive
Pin Diagram [Maximum mode operation]
• (29)
Low on this pin prevents the master to use system bus.
Output Signal; Lock instruction is used to indicate the master that
the processor is preventing to access the system bus.
Operation Code Field: It indicates Operand Field: The CPU executes the
the type of operation to be instruction using the information that
performed by CPU. resides in these field
• Ex:
MOV AL, BL ; Instruction only consists of Opcode
MOV AL, 20H ; Instruction consists both opcode and operand
; MOV AL : Opcode
; 20H : Operand
ADD AX, BX
ADD AL, FFH
XCHG BX, AX
Addressing Mode
67
• The 8086 processors let you access memory in many different ways. The 8086
memory addressing modes provide flexible access to memory, allowing you to
easily access variables, arrays, records, pointers, and other complex data types.
• Ex:
If you want to add two numbers the; how you are going to tell the processor
to work with the operand.
68
Addressing Mode
69
1. Register Addressing
Group I : Addressing modes for register
2. Immediate Addressing and immediate data
3. Direct Addressing
5. Based Addressing
Group II : Addressing modes for memory
6. Indexed Addressing data
7. Based Index Addressing
8. String Addressing
• Ex:
MOV AL, BL ; copy the data of BL register to AL
MOV CX, BX ; copy the data of BX register to CX
INC BX ; BX := BX + 1
Addressing Mode
Immediate Addressing Mode
71
• In this, an 8 bit or 16 bit data is specified as part of the instruction
• Here, CPU doesn’t need to search for the data as data is directly given in the
instruction. Thus the operation is carried out immediately.
Example:
(DL) 08H
(AX) 0A9FH
Addressing Mode
Direct Addressing Mode
72
• The effective address of memory location at which the data operand is stored is given.
• The instruction consists of a register and an offset address (indicated by square bracket). To compute
physical address, shift left the DS register and add the offset address into it.
Example:
MOV CL, [2000H] ; Copy the content of memory location: ‘PA = (DS*10H) + 2000H’
MOV CX, [2000H] ; Copy the content of memory location: CL ‘PA = (DS*10H) + 2000H’
; Copy the content of memory location: CH ‘PA = (DS*10H) + 2001H’
73
74
75
Addressing Mode
• Effective Address and Registers:
76 The offset of a memory operand is called the operand’s effective address (EA).
It is an unsigned 16 bit no. That expresses the operands distance in byte from the
Indirect Addressing Mode
• The sum of offset address and the DS value shifted by one position generates a
physical address.
• If BX, SI or DI is used as base register then DS will be used as segment register.
• If BP is used then by default it will work on stack segment (SS).
Example:
• MOV [BX+5], DX
Addressing Mode
Base Indexed Addressing Mode
79• The effective address of the data is formed by adding content of the base register
(BX or BP) to the content of an index register (SI or DI). The default segment for
data may be DS or ES.
Indirect Addressing Mode
• MOV CL, [BP+SI]; [Operation will be carried out in Stack segment]: Copy the content of memory location
SS*10H + [BP] + [SI] in CL.
Relative Base Indexed Addressing Mode Addressing Mode
80• The effective address of the data is formed by adding content of the base register
(BX or BP), the content of an index register (SI or DI) and an 8-bit or 16-bit
displacement. The default segment for data may be DS or ES.
Indirect Addressing Mode
• MOV CL, [BP+SI+20]; [Operation will be carried out in Stack segment]: Copy the content of memory
location SS*10H + [BP] + [SI] + 20 in CL.
81
Addressing Mode
82
Implied Addressing Mode
• Instructions using this mode has no operands.
• The instruction itself will specify the data to be operated by the instruction.
83
I/O Addressing Mode
• Used to access date from standard I/O mapped devices or ports.
• In direct addressing, an 8-bit port address is directly specified in the instruction.
Example: IN AL, [09H] ;Content of port with address 09H is moved to AL register.
• In indirect port addressing mode, the instruction will specify the name of the
register which holds the port address. In 8086, the 16-bit port address is stored in
DX register.
Example: OUT [DX], AX ;Content of AX is moved to port with address specified by DX register.
84
• These instructions are used to transfer the data from the source operand to the destination
operand.
• MOV − Used to copy the byte or word from the provided source to the provided destination.
• POP − Used to get a word from the top of the stack to the provided location.
• 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.
Instruction Set
Instructions of 8086
2. Arithmetic and logical Instructions
• IDIV − Used to divide the signed word by byte or signed double word by word.
• CBW − Used to fill the upper byte of the word with the copies of sign bit of the lower
byte.
• CWD − Used to fill the upper word of the double word with the sign bit of the lower
word.
Instruction Set
Instructions of 8086
2. Arithmetic and logical Instructions
• These instructions are used to perform operations where data bits are
involved, i.e. operations like logical also called as Bit Manipulation
instructions.
• STI − Used to set the interrupt enable flag to 1, i.e., enable INTR input.
• CLI − Used to clear the interrupt enable flag to 0, i.e., disable INTR input.
Instruction Set
Instructions of 8086
7. Machine Control Instructions
• These instructions are used to control the machine status.
• Wait − Wait for the test input pin to go low.
• ESC − Escape to external device like numeric coprocessor. Bus control will be given to other
processors
• LOCK − Bus lock instruction prefix.
Instruction Set
Instructions of 8086
8. String Manipulation Instruction
• String is a group of bytes/words and their memory is always allocated in a sequential
order.
REP − Used to repeat the given instruction till CX ≠ 0.
REPE/REPZ − Used to repeat the given instruction until CX = 0 or zero flag ZF = 1.
REPNE/REPNZ − Used to repeat the given instruction until CX = 0 or zero flag ZF = 1.
MOVS/MOVSB/MOVSW − Used to move the byte/word from one string to another.
COMS/COMPSB/COMPSW − Used to compare two string bytes/words.
INS/INSB/INSW − Used as an input string/byte/word from the I/O port to the provided memory
location.
OUTS/OUTSB/OUTSW − Used as an output string/byte/word from the provided memory location to
the I/O port.
SCAS/SCASB/SCASW − Used to scan a string and compare its byte with a byte in AL or string word
with a word in AX.
LODS/LODSB/LODSW − Used to store the string byte into AL or string word into AX.
100
8086 P: Introduction to
Programming