Professional Documents
Culture Documents
8086 MIC - Unit 1 - Notes
8086 MIC - Unit 1 - Notes
Patil
Chapter 1
8086-16 Bit Microprocessor
1. Introduction
8086 Microprocessor is an enhanced version of 8085 Microprocessor that
was designed by Intel in 1978. It is a 16-bit Microprocessor having 20
address lines and16 data lines that provides up to 1MB storage. It consists
of powerful instruction set, which provides operations like multiplication
and division easily.
It supports two modes of operation, i.e. Maximum mode and Minimum
mode. Maximum mode is suitable for system having multiple processors
and Minimum mode is suitable for system having a single processor.
8086 was the first 16-bit microprocessor available in 40-pin DIP (Dual
Inline Package) chip. Let us now discuss in detail the pin configuration of a
8086 Microprocessor.
INTR
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
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.
$\overline{TEST}$
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/$\overline{MX}$
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-aversa.
INTA
It is an interrupt acknowledgement signal and id available at pin 24. When
the microprocessor receives this signal, it acknowledges the interrupt.
ALE
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.
DEN
It stands for Data Enable and is available at pin 26. It is used to enable
Transreceiver 8286. The transreceiver is a device used to separate data
from the address/data bus.
DT/R
It stands for Data Transmit/Receive signal and is available at pin 27. It
decides the direction of data flow through the transreceiver. When it is
high, data is transmitted out and vice-a-versa.
M/IO
This signal is used to distinguish between memory and I/O operations.
When it is high, it indicates I/O operation and when it is low indicates the
memory operation. It is available at pin 28.
WR
It stands for write signal and is available at pin 29. It is used to write the
data into the memory or the output device depending on the status of M/IO
signal.
HLDA
It stands for Hold Acknowledgement signal and is available at pin 30. This
signal acknowledges the HOLD signal.
HOLD
This signal indicates to the processor that external devices are requesting
to access the address/data buses. It is available at pin 31.
QS1 and QS0
These are queue status signals and are available at pin 24 and 25. These
signals provide the status of instruction queue. Their conditions are shown
in the following table −
0 0 No operation
S0, S1, S2
These are the status signals that provide the status of operation, which is
used by the Bus Controller 8288 to generate memory & I/O control signals.
These are available at pin 26, 27, and 28. Following is the table showing
their status −
S2 S1 S0 Status
0 0 0 Interrupt acknowledgement
0 0 1 I/O Read
0 1 0 I/O Write
0 1 1 Halt
1 0 0 Opcode fetch
1 0 1 Memory read
1 1 0 Memory write
1 1 1 Passive
LOCK
When this signal is active, it indicates to the other processors not to ask
the CPU to leave the system bus. It is activated using the LOCK prefix on
any instruction and is available at pin 29.
EU (Execution Unit)
Execution unit gives instructions to BIU stating from where to fetch the
data and then decode and execute those instructions. Its function is to
control operations on data using the instruction decoder & ALU. EU has no
direct connection with system buses as shown in the above figure, it
performs operations over data through BIU.
Let us now discuss the functional parts of 8086 microprocessors.
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.
Conditional Flags
It represents the result of the last arithmetic or logical instruction executed.
Following is the list of conditional flags −
Carry flag − This flag indicates an overflow condition for arithmetic
operations.
Auxiliary flag − When an operation is performed at ALU, it results in
a carry/barrow from lower nibble (i.e. D0 – D3) to upper nibble (i.e.
D4 – D7), then this flag is set, i.e. carry given by D3 bit to D4 is AF
flag. The processor uses this flag to perform binary to BCD
conversion.
Parity flag − This flag is used to indicate the parity of the result, i.e.
when the lower order 8-bits of the result contains even number of
1’s, then the Parity Flag is set. For odd number of 1’s, the Parity Flag
is reset.
Zero flag − This flag is set to 1 when the result of arithmetic or
logical operation is zero else it is set to 0.
Sign flag − This flag holds the sign of the result, i.e. when the result
of the operation is negative, then the sign flag is set to 1 else set to
0.
Overflow flag − This flag represents the result when the system
capacity is exceeded.
Control Flags
Control flags controls the operations of the execution unit. Following is the
list of control flags −
Trap flag − It is used for single step control and allows the user to
execute one instruction at a time for debugging. If it is set, then the
program can be run in a single step mode.
Interrupt flag − It is an interrupt enable/disable flag, i.e. used to
allow/prohibit the interruption of a program. It is set to 1 for interrupt
enabled condition and set to 0 for interrupt disabled condition.
Direction flag − It is used in string operation. As the name suggests
when it is set then string bytes are accessed from the higher memory
address to the lower memory address and vice-a-versa.
General purpose register
There are 8 general purpose registers, i.e., AH, AL, BH, BL, CH, CL, DH,
and DL. These registers can be used individually to store 8-bit data and
can be used in pairs to store 16bit data. The valid register pairs are AH
and AL, BH and BL, CH and CL, and DH and DL. It is referred to the AX,
BX, CX, and DX respectively.
AX register − It is also known as accumulator register. It is used to
store operands for arithmetic operations.
BX register − It is used as a base register. It is used to store the
starting base address of the memory area within the data segment.
CX register − It is referred to as counter. It is used in loop instruction
to store the loop counter.
DX register − This register is used to hold I/O port address for I/O
instruction.
BIU takes care of all data and addresses transfers on the buses for the EU
like sending addresses, fetching instructions from the memory, reading
data from the ports and the memory as well as writing data to the ports
and the memory. EU has no direction connection with System Buses so
this is possible with the BIU. EU and BIU are connected with the Internal
Bus.
It has the following functional parts −
Instruction queue − BIU contains the instruction queue. BIU gets
upto 6 bytes of next instructions and stores them in the instruction
queue. When EU executes instructions and is ready for its next
instruction, then it simply reads the instruction from this instruction
queue resulting in increased execution speed.
Fetching the next instruction while the current instruction executes is
called pipelining.
Segment register − BIU has 4 segment buses, i.e. CS, DS, SS&
ES. It holds the addresses of instructions and data in memory, which
are used by the processor to access memory locations. It also
contains 1 pointer register IP, which holds the address of the next
instruction to executed by the EU.
o CS − It stands for Code Segment. It is used for addressing a
memory location in the code segment of the memory, where
the executable program is stored.
o DS − It stands for Data Segment. It consists of data used by
the program and is accessed in the data segment by an offset
address or the content of other register that holds the offset
address.
o SS − It stands for Stack Segment. It handles memory to store
data and addresses during execution.
5. 8086-Flag Register
The Flag register is a Special Purpose Register. Depending upon the
value of result after any arithmetic and logical operation the flag bits
become set (1) or reset (0).
There are total 9 flags in 8086 and the flag register is divided into two
types:
1. Sign Flag (S) – After any operation if the MSB (B(7)) of the result is
1, it indicates the number is negative and the sign flag becomes set,
i.e. 1. If the MSB is 0, it indicates the number is positive and the sign
flag becomes reset i.e. 0.
from 00H to 7F, sign flag is 0
from 80H to FF, sign flag is 1
1- MSB is 1 (negative)
0- MSB is 0 (positive)
Example:
MVI A 30 (load 30H in register A)
MVI B 40 (load 40H in register B)
SUB B (A = A – B)
These set of instructions will set the sign flag to 1 as 30 – 40 is a
negative number.
MVI A 40 (load 40H in register A)
MVI B 30 (load 30H in register B)
SUB B (A = A – B)
These set of instructions will reset the sign flag to 0 as 40 – 30 is a
positive number.
2. Zero Flag (Z) – After any arithmetical or logical operation if the result
is 0 (00)H, the zero flag becomes set i.e. 1, otherwise it becomes
reset i.e. 0.
00H zero flag is 1.
from 01H to FFH zero flag is 0
1- zero result
0- non-zero result
Example:
MVI A 10 (load 10H in register A)
SUB A (A = A – A)
These set of instructions will set the zero flag to 1 as 10H – 10H is
00H
3. Auxiliary Carry Flag (AC) – This flag is used in BCD number
system(0-9). If after any arithmetic or logical operation D(3) generates
any carry and passes on to B(4) this flag becomes set i.e. 1,
otherwise it becomes reset i.e. 0. This is the only flag register which
is not accessible by the programmer
1-carry out from bit 3 on addition or borrow into bit 3 on subtraction
0-otherwise
Example:
MOV A 2B (load 2BH in register A)
MOV B 39 (load 39H in register B)
ADD B (A = A + B)
These set of instructions will set the auxiliary carry flag to 1, as on
adding 2B and 39, addition of lower order nibbles B and 9 will
generate a carry.
4. Parity Flag (P) – If after any arithmetic or logical operation the result
has even parity, an even number of 1 bits, the parity register
becomes set i.e. 1, otherwise it becomes reset i.e. 0.
1-accumulator has even number of 1 bits
0-accumulator has odd parity
Example:
MVI A 05 (load 05H in register A)
This instruction will set the parity flag to 1 as the BCD code of 05H is
00000101, which contains even number of one’s i.e. 2.
5. Carry Flag (CY) – Carry is generated when performing n bit
operations and the result is more than n bits, then this flag becomes
set i.e. 1, otherwise it becomes reset i.e. 0.
During subtraction (A-B), if A>B it becomes reset and if (A<B) it
becomes set.
Carry flag is also called borrow flag.
1-carry out from MSB bit on addition or borrow into MSB bit on
subtraction
0-no carry out or borrow into MSB bit
Example:
MVI A 30 (load 30H in register A)
MVI B 40 (load 40H in register B)
SUB B (A = A – B)
These set of instructions will set the carry flag to 1 as 30 – 40
generates a carry/borrow.
MVI A 40 (load 40H in register A)
MVI B 30 (load 30H in register B)
SUB B (A = A – B)
These set of instructions will reset the sign flag to 0 as 40 – 30 does
not generate any carry/borrow.
6. Overflow Flag (O) – This flag will be set (1) if the result of a signed
operation is too large to fit in the number of bits available to represent
it, otherwise reset (0). After any operation, if D[6] generates any carry
and passes to D[7] OR if D[6] does not generates carry but D[7]
generates, overflow flag becomes set, i.e., 1. If D[6] and D[7] both
generate carry or both do not generate any carry, then overflow flag
becomes reset, i.e., 0.
3. Trap Flag (T) – This flag is used for on-chip debugging. Setting trap
flag puts the microprocessor into single step mode for debugging. In
single stepping, the microprocessor executes a instruction and enters
into single step ISR.
If trap flag is set (1), the CPU automatically generates an internal
interrupt after each instruction, allowing a program to be inspected as
it executes instruction by instruction.
If trap flag is reset (0), no function is performed.
6.8086-Interrupts-Hardware Interrupts
An interrupt to the microprocessor is defined as that which disturbs the
normal execution of a program .
Interrupt Types:
Hardware interrupts:
The 8086 has two hardware interrupt pins namely NMI and INTR.
In the two, the NMI is a non-maskable interrupt and the INTR interrupt
request is a maskable interrupt which has lower priority .
The third pin associated with the hardware interrupts are the INTA called
interrupt acknowledge.
NMI:
INTR:
The 8086 provides a single interrupt request input (INTR) which can be
masked internally by software with the resetting of the interrupt enable
FLAG status bit.
The interrupt request signal is level triggered.
7. 8086-Software Interrupt
An interrupt to the microprocessor is defined as that which disturbs the
normal execution of a program.
Software Interrupt:
8086 can generate 256 interrupt types through the instruction INT n.
To store the starting address of the each ISS , four bytes of memory
space is required.
Two bytes are for storing CS value and two bytes for IP value.
The starting address of an ISS stored in 1kB of memory space is called
Interrupt pointer or Interrupt vector.
The 1kB memory space acts as a table and it is called Interrupt Vector
Table (IVT).
The starting address of the ISS for type0 interrupt is 000000H.For type1
interrupt is 00004H similarly for type2 is 00008H ……
In the IVT the first five pointers are dedicated interrupt pointers. They are
:
The Interrupts from Type 5 to Type 31 are reserved for other advanced
microprocessors, and from 32 to Type 255 are available for hardware and
software interrupts.
Memory organization:
The memory is logically divided into code, data, extra data, and stack
segments of up to 64K bytes each, with each segment falling on 16-byte
boundaries. (See Figure 1.2.)
All memory references are made relative to base addresses contained in
high speed segment registers.
The segment types were chosen based on the addressing needs of
programs.
The segment register to be selected is automatically chosen according to
the rules of the following table.
All information in one segment type share the same logical attributes
(e.g. code or data).
By structuring memory into relocatable areas of similar characteristics
and by automatically selecting segment registers, programs are shorter,
faster, and more structured.
Word (16-bit) operands can be located on even or odd address
boundaries and are thus not constrained to even boundaries as is the
case in many 16-bit computers.
For address and data operands, the least significant byte of the word is
stored in the lower valued address location and the most significant byte
in the next higher address location.
The BIU automatically performs the proper number of memory accesses,
one if the word operand is on an even byte boundary and two if it is on an
odd byte boundary.
Except for the performance penalty, this double access is transparent to
the software.
This performance penalty does not occur for instruction fetches, only
word operands.
Physically, the memory is organized as a high bank (D15±D8) and a low
bank (D7±D0) of 512K 8-bit bytes addressed in parallel by the
processor's address lines A19±A1.
Byte data with even addresses is transferred on the D7±D0 bus lines
while odd addressed byte data (A0 HIGH) is transferred on the D15±D8
bus lines.
The processor provides two enable signals, BHE and A0, to selectively
allow reading from or writing into either an odd byte location, even byte
location, or both.
The instruction stream is fetched from memory as words and is
addressed internally by the processor to the byte level as necessary.
of memory. The high-order byte or most significant byte is 07 and the low-
order byte is 25.
The processor stores data in reverse-byte sequence, i.e., a low-order byte
is stored in a low memory address and a high-order byte in high memory
address. So, if the processor brings the value 0725H from register to
memory, it will transfer 25 first to the lower memory address and 07 to the
next memory address.
x: memory address
When the processor gets the numeric data from memory to register, it
again reverses the bytes. There are two kinds of memory addresses −
Absolute address - a direct reference of specific location.
Segment address (or offset) - starting address of a memory segment
with the offset value.
Example:
Suppose that the register contents of some of the 8086/8088 registers are
as follows:
b) MOV LIST[DI],AL
d) PUSH SI
Solution:
8086 has 20bit address line. So the maximum value of address that can be
addressed by 8086 is 2^20 = 1MB. So 8086 can address the locations
ranging between 00000 H to FFFFF H. This 1MB memory is divided into 16
logical segments, each with a memory of 64KB.
To locate any adress in the memory bank, it needs the Physical address of
that memory location. It cannot get the 20-bit Physical adress using the
8086 Address Line or 16-bit Segment Registers alone.
Suppose the Data Segment holds the Base Aaddress as 1000h and the
data you need is present in the 0020h memory location (Offset) of the Data
Segment. The calculation of the actual address is done as follows.
1. Left shift the 16-bit address present in the segment register by 4-bits
--------------------------------------
At any point of time we can change the base address of the segment
registers and use the memory locations in those segments using the offset.
Q1) The value of Code Segment (CS) Register is 4042H and the value of
different offsets is as follows:
BX: 2025H , IP: 0580H , DI: 4247H
Calculate the effective address of the memory location pointed by the CS
register.
Ans:
Ans:
Both SP and BP are the offsets for Stack Register (SS). The address
calculated when BP is taken as the offset gives the starting address of the
stack. The address when SP is taken as the offset denotes the memory
location where the top of the stack lies.
Q3) The value of the DS register is 3032H. And the BX register contains a
16 bit value which is equal to 3032H. 0008H is added to BX.
ADD BX, 0008H
The register AX contains some value which needs to be stored at a location
as follows:
MOV [BX], AX
Calculate the address at which the value of the AX will be stored.
Ans:
The BX register is an offset of the Data Segment (DS) register. So, the
location at which the value of the AX register will be stored is calculated as
follows:
Advantages of pipelining:
The execution unit always reads the next instruction byte from the
queue in BIU. This is faster than sending out an address to the
memory and waiting for the next instruction byte to come.
In short pipelining eliminates the waiting time of EU and speeds up
the processing. -The 8086 BIU will not initiate a fetch unless and until
there are two empty bytes in its queue. 8086 BIU normally obtains
two instruction bytes per fetch.
Significance of Queue:
When MN/MX (bar) is low 8086 is in When MN/MX (bar) is high 8086 is in
maximum mode. minimum mode.
So clearly there are multiple processes There is only one processor in the system
in the system. minimum mode.