Professional Documents
Culture Documents
Abes Engineering College, Ghaziabad: Department of Electronics & Communication Engineering
Abes Engineering College, Ghaziabad: Department of Electronics & Communication Engineering
COURSE MATERIAL
Features of 8086
• It is a 16-bit Microprocessor. It’s ALU, internal registers work with 16-bit binary words.
• 8086 has a 20-bit address bus that can access up to 220= 1 MB memory locations.
• 8086 has a 16-bit data bus. It can read or write data to a memory/port either 16bits or 8 bits
at a time.
• It can support up to 64K I/O ports.
• It provides 14, 16 -bit registers.
• Frequency range of 8086 is 6-10 MHz
• It has multiplexed address and data bus AD0- AD15 and A16 – A19.
• It requires a single-phase clock with a 33% duty cycle to provide internal timing.
• It can prefetch up to 6 instruction bytes from memory and queues to up instruction
execution.
• It requires a +5V power supply.
• A 40-pin dual in-line package.
• 8086 is designed to operate in two modes, Minimum mode, and Maximum mode.
o The minimum mode is selected by applying logic 1 to the MN / MX input pin. This
is a single microprocessor configuration.
o The maximum mode is selected by applying logic 0 to the MN / MX input pin. This
is a multi-microprocessors configuration.
8086 Microprocessor is divided into two functional units, i.e., EU (Execution Unit) and BIU (Bus Interface
Unit).
EU (Execution Unit)
The 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.
ALU
It handles all arithmetic and logical operations, like +, −, ×, /, OR, AND, NOT operations.
Fig 3.1 8086 architecture
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.
• 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 an even number of 1’s, then the Parity Flag is set. For an odd
number of 1’s, the Parity Flag is reset.
• Zero flag − This flag is set to 1 when the result of an 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 control 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.
• 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-versa.
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 as the AX, BX, CX, and
DX respectively.
• AX register − It is also known as the 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 the I/O port addresses for I/O instruction.
Stack Pointer register
It is a 16-bit register, which holds the address from the start of the segment to the memory location, where a
word was most recently stored on the stack.
• 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 registers
that holds the offset address.
o SS − It stands for Stack Segment. It handles memory to store data and addresses
during execution.
o ES − It stands for Extra Segment. ES is an additional data segment, which is
used by the string to hold the extra destination data.
• Instruction pointer − It is a 16-bit register used to hold the address of the next instruction to
be executed.
Memory segmentation is nothing which is the method where the whole memory is divided into smaller parts.
In 8086 microprocessor memory is divided into four parts which is known as segments. These segments are
data segment, code segment, the stack segment and extra segment.
The total memory size is divided into segments of various sizes. A segment is just an area in memory. The
process of dividing memory this way is called Segmentation.
In memory, data is stored as bytes. Each byte has a specific address. Intel 8086 has 20 lines address bus.
With 20 address lines, the memory that can be addressed is 220 bytes. 220= 1,048,576 bytes (1 MB). 8086
can access memory with address ranges from 00000 H t o FFFFFH
Each of these segments is addressed by an address stored in the corresponding segment register. These
registers of 16-bit in size. Each register stores the base address (starting address) of the corresponding
segment. Because the segment registers cannot store 20 bits, they only store the upper 16 bits.
How is a 20-bit address obtained if there are only 16- bit registers? The 20-bit address of a byte is called
its physical Address. But it is specified as a Logical Address. The logical address is in the form of Base
Address: Offset is the displacement of the memory location from the starting location of the segment.
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:
No, the effective address of the DS register cannot be calculated from the given values because none of the
given offset is an offset of the DS Register. This can be done only in the case of segment override prefix, but
as it is not mentioned here, we will not follow that.
There are 20 address lines in the 8086 microprocessor. This gives us 220 different memory locations. Hence
the total size is 220 Bytes (as each memory location is Byte Addressable, i.e. one byte of data can be stored at
every single location), which is equal to 1MB.
Even the memory is byte-addressable, yet the 8086 microprocessor an easily handle up to 16 bits of data at a
time through its 16 data lines. So, to organize the memory efficiently, the entire memory in 8086 is divided
into two memory banks: odd bank and the even bank.
The way in which data is read or written is decided by the value of BHE, and the last address bit, that is the
A0 line. It is done in the following way:
To read or write 8 bits of data, it would require only 1 CPU cycle, no matter the data is stored in any of the
memory banks, but to read or write 16 bits of data, the BIU of the 8086 may require either 1 or 2 memory
cycles depending upon whether the lower byte of word is located at even or odd memory address.
1. If the lower byte of the word is stored at even memory bank and the upper byte is stored at odd
memory bank then the CPU will require only 1 memory cycle. So, it is better to store data in this way.
2. If the lower byte of the word is located at an odd memory address, then the CPU will require 2
memory cycles. The first memory cycle is required for accessing the lower byte of the word through
the higher data bus, i.e. D15 to D8, and the second memory cycle is required for accessing the upper
byte of the word through the lower data bus, i.e. D7 to D0.
AD15 – AD0 These are 16 address/data bus. AD0-AD7 carries low order byte data and
AD8AD15 carries higher order byte data. During the first clock cycle, it carries
16-bit address and after that it carries 16-bit data.
A16 – A19 These are the 4 address/status buses. During the first clock cycle, it carries 4-
bit address and later it carries status signals.
Clock Clock signal is provided through Pin-19. It provides timing to the processor for
operations. Its frequency is different for different versions, i.e. 5MHz, 8MHz
and 10MHz.
S7/BHE BHE stands for Bus High Enable. It is available at pin 34 and used to indicate
the transfer of data using data bus D8-D15. This signal is low during the first
clock cycle, thereafter it is active.
Read (RD) It is available at pin 32 and is used to read signal for Read operation.
𝐑𝐞𝐚𝐝𝐲 It is available at pin 32. 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 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.
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.
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/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-versa.
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
Pins Function
DEN It stands for Data Enable and is available at pin 26. It is used to enable
Transceiver 8286. The transceiver 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 transceiver. When it is high, data is
transmitted out and vice-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 indicating 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 pins 24 and 25. These
signals provide the status of the instruction queue.
S0, S1, S2 These are the status signals that provide the status of the operation, which is
used by the Bus Controller 8288 to generate memory & I/O control signals.
These are available at Pins 26, 27, and 28.
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.
RQ/GT1 and These are the Request/Grant signals used by the other processors requesting the
RQ/GT0 CPU to release the system bus. When the signal is received by the CPU, then it
sends an acknowledgment. RQ/GT0 has a higher priority than RQ/GT1.
There are some conditions for QS0 and QS1. These conditions are as follows.
0 0 No operation
The S2, S1 and S0 are the status signals. Here is a list of status and their bit patterns.
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
The way of specifying data to be operated by an instruction is known as addressing modes. This
specifies that the given data is immediate data or an address. It also specifies whether the given operand
is register or register pair.
Types of addressing modes:
1. Register mode – In this type of addressing mode both the operands are registers.
Example:
MOV AX, BX
XOR AX, DX
ADD AL, BL
2. Immediate mode – In this type of addressing mode the source operand is a 8 bit or 16 bit
data. Destination operand can never be immediate data.
Example:
MOV AX, 2000
MOV CL, 0A
ADD AL, 45
AND AX, 0000
Note that to initialize the value of segment register an register is required.
MOV AX, 2000
MOV CS, AX
3. Displacement or direct mode – In this type of addressing mode the effective address is
directly given in the instruction as displacement.
Example:
MOV AX, [DISP]
MOV AX, [0500]
4. Register indirect mode – In this addressing mode the effective address is in SI, DI or BX.
Example:
Physical Address = Segment Address + Effective Address
MOV AX, [DI]
ADD AL, [BX]
MOV AX, [SI]
5. Based indexed mode – In this the effective address is sum of base register and index
register.
Base register: BX, BP
Index register: SI, DI
The physical memory address is calculated according to the base register.
Example:
MOV AL, [BP+SI]
MOV AX, [BX+DI]
6. Indexed mode – In this type of addressing mode the effective address is sum of index
register and displacement.
Example:
MOV AX, [SI+2000]
MOV AL, [DI+3000]
7. Based mode – In this the effective address is the sum of base register and displacement.
Example:
MOV AL, [BP+ 0100]
8. Based indexed displacement mode – In this type of addressing mode the effective address
is the sum of index register, base register and displacement.
Example:
MOV AL, [SI+BP+2000]
9. String mode – This addressing mode is related to string instructions. In this, the value of
SI and DI are auto incremented and decremented depending upon the value of directional
flag.
Example:
MOVS B
MOVS W
10. Input/Output mode – This addressing mode is related with input output operations.
Example:
IN A, 45
OUT A, 50
11. Relative mode –
In this the effective address is calculated with reference to instruction pointer.
Example:
JNZ 8 bit address
IP=IP+8 bit address
Two-mark questions
Q-1. What do you mean by instruction queue of 8086?
Q-2. What do you mean by pipelining?
Q-3. Draw the block diagram of EU.
Five-mark questions
Q-4. What are the features of the Intel 8086 Microprocessor?
Q-5. Differentiate between 8085 and 8086 Microprocessors?
Ten-mark questions
Q-6. Explain the architecture of 8086. Draw and explain the architecture of the 8086 microprocessors.
Q-7. With a neat diagram, describe the Bus Interface Unit and Execution Unit of 8086. State the
function of each block.
Q-8. Explain the addressing modes of 8086.
3.1 PERIPHERAL DEVICES
Functional Description:
The 8259 A has eight interrupt request inputs, IR0- IR7.The 8259 A uses its INT output to
interrupt the 8085A via INTR pin.The 8259Areceives interrupt acknowledge pulses from the at
its input.Vector address used by the 8085 A to transfer control to the service subroutine of the
interrupting device, is provided by the 8259 A on the data bus.
The 8259A is a programmable device that must be initialized by command words sent by the.
After initialization the 8259A mode of operation can be changed by operation command words.
The descriptions of various blocks are,
Data bus buffer:
This 3- state, bidirectional 8-bit buffer is used to interface the 8259Ato the system data bus.
Control words and status information are transferred through the data bus buffer.
Read/Write & control logic:
The function of this block is to accept OUTPUT commands from the CPU. It contains the
initialization command word (ICW) register and operation command word OCW) register which
store the various control formats for device operation. This function block also allows the status
of 8259A to be transferred to the data bus.
Interrupt request register (IRR):
IRR stores all the interrupt inputs that are requesting service.It keeps track of which interrupt
inputs are asking for service. If an interrupt input is unmasked, and has an interrupt signal on it,
then the corresponding bit in the IRR will be set.
Interrupt mask register (IMR):
The IMR is used to disable (Mask) or enable (Unmask) individual interrupt inputs.Each bit in
this register corresponds to the interrupt input with the same number. The IMR operation on the
IRR. Masking of higher priority input will not affect the interrupt request lines of lower
priority.To unmask any interrupt the corresponding bit is set „0‟.
M7 M6 M5 M4 M3 M2 M1 M0
The Intel 8253 and 8254 are Programmable Interval Timers (PITs), which perform timing and
counting functions and has the same pinout.
8253 8254
Reads and Writes of the same counter cannot be Reads and Writes of the same counter can be
interleaved. interleaved.
BLOCK DIAGRAM OF INTEL 8253/8254
The timer has three counters.or timers which are named as "Counter 0", "Counter 1" and
"Counter 2".Each counter has 2 input pins – "CLK" (clock input) and "GATE" – and 1-pin,
"OUT", for data output. The 3 counters are 16-bit down counters independent of each other, and
can be easily read by the CPU. The first counter is used to generate atimekeeping interrupt.The
second counter is used to trigger the refresh of DRAM memory. The last counter is used to
generate tones via the PC speaker.
Data/Bus Buffer:
This block contains the logic to buffer the data bus to / from the microprocessor, and to the
internal registers. It has 8 input pins, usually labelled as D7..D0, where D7 is the MSB.
Read/Write Logic:
D7 D6 D5 D4 D3 D2 D1 D0
D3 D2 D1
M2 M1 M0 Mode
0 0 0 Mode0
0 0 1 Mode1
X 1 0 Mode2
X 1 1 Mode3
1 0 0 Mode4
1 0 1 Mode5
D5 D4
D7 D6
0 0 Select Counter 0
0 1 Select Counter 1
1 0 Select Counter 2
1 1 Illegal
D7 D6 D5 D4 D3 D2 D1 D0
= Select Counter 2
D2 – 1 = Select Counter 1
D1 – 1 = Select Counter 0
Operation Modes
Mode 0 : Interrupt on Terminal Count
Mode 0 is used for the generation of accurate time delay under software control. In this mode, the
counter will start counting from the initial COUNT value loaded into it, down
to 0. Counting rate is equal to the input clock frequency. The OUT pin is set low after the
Control Word is written, and counting starts one clock cycle after the COUNT programmed.
OUT remains low until the counter reaches 0, at which point OUT will be set high until the
counter is reloaded or the Control Word is written. The Gate signal should remain active high for
normal counting. If Gate goes low counting, gets terminated and current count is latched till Gate
pulse goes high again.
Mode 1 : Programmable One Shot
In this mode 8253 can be used as Monostable Multivibrator. GATE input is used as trigger input.
OUT will be initially high. OUT will go low on the CLK pulse following a trigger to begin the
one-shot pulse and will remain low until the Counter reaches zero. OUT will then go high and
remain high until the CLK pulse after the next trigger.
Mode 2: Rate Generator
In this mode, the device acts as a divide-by-n counter, which is commonly used to generate a
real-time clock interrupt. Counting process will start the next clock cycle after the COUNT is
sent. OUT will then remain high until the counter reaches 1, and will go low for one clock pulse.
OUT will then go high again, and the whole process repeats itself.
READY:
This signal can be used to extend the memory read and write pulses from the 82C37A to
accommodate slow memories or I/O devices.
HLDA: HOLD ACKNOWLEDGE:
The active high Hold Acknowledge from the CPU indicates that it has relinquished control of the
system busses.
IOR: READ:
I/O Read is a bidirectional active low three-state line. In the Idle cycle, it is an input
control signal used by the CPU to read the control registers. In the active cycle, it is an output
control signal used by the 82C37A to access data from the peripheral during a DMAWrite
transfer.
IOW: WRITE:
I/O Write is a bidirectional active low three-state line.
In the Idle cycle, it is an input control signal used by the CPU to load information into the
82C37A. In the active cycle, it is an output control signal used by the 82C37A to load data to
the peripheral during a DMA
Read transfer.
A0-A3: ADDRESS: The four least significant address lines are bidirectional three-state signals.
In the Idle cycle, they are inputs and are used by the 82C37A to address the control register to
be loaded or read. In the Active cycle, they are outputs and provide the lower 4-bits of the
output
address.
A4-A7: ADDRESS: The four most significant address lines are three-state outputs and provide 4-
bits of address. These lines are enabled only during the DMA service.
HRQ: HOLD REQUEST: The Hold Request (HRQ) output is used to request control of the
system bus. When a DREQ occurs and the corresponding mask bit is clear, or a software DMA
request is made, the 82C37A issues HRQ. The HLDA signal then informs the controller when
access to the system busses is permitted. For stand-alone operation where the 82C37A always
controls the busses, HRQ may be tied to HLDA. This will result in one S0 state before the
transfer.
NC: NO CONNECT: Pin 5 is open and should not be tested for continuity.
Functional Description
The 82C37A direct memory access controller is designed to improve the data transfer
rate in systems which must transfer data from an I/O device to memory, or move a block of
memory to an I/O device. It will also perform memory-to-memory block moves, or fill a block
of memory with data from a single location. Operating modes are provided to handle single
byte transfers as well as discontinuous data streams, which allows the 82C37A to control data
movement.Memory-to-memory operations require temporary internal storage of the data byte
between generation of the source and destination addresses, so memory-to-memory
transferstake place at less than half the rate of I/O operations, but still much faster than with
centralprocessor techniques. The block diagram of the 82C37A consists of timing and control
block, priority block, and internal registers are the main components. The timing and control
block derives internal timing from clock input, and generates external control signals. The
Priority Encoder block resolves priority contention between DMA channels requesting service
simultaneously.
DMA Operation:
In a system, the 82C37A address and control outputs and data bus pins are basically connected in
parallel with the system busses. An external latch is required for the upper address byte. While
inactive, the controller‟s outputs are in a high impedance state. When activated by a DMArequest
and bus control is relinquished by the host, the 82C37A drives the busses and generates the
control signals to perform the data transfer.The operation performed by activating one of the four
DMA request inputs has previously been programmed into the controller via the
Command,Mode, Address, and Word Count registers.For example, if a block of data is to be
transferredfrom RAM to an I/O device, the starting address of the data is loaded into the 82C37A
Current and Base Address registers for a particular channel, and the length of the block is loaded
into the channel‟s Word Count register. The corresponding Mode register is programmed for a
memory to-I/O operation (read transfer), and various options are selected by the Command
register and the other Mode register bits.The channel‟s mask bit is cleared to
enable recognition of a DMArequest (DREQ). The DREQ can either be a hardware
signal or a software command. Once initiated, the block DMA transfer will proceed as
the controller outputs the data address,simultaneous MEMR and IOW pulses, and
selects an I/O device via the DMA acknowledge(DACK) outputs.The data byte flows
directly from the RAM to the I/O device. After each byte is transferred, the address is
automatically incremented (or decremented) and the word count is decremented.The
operation is then repeated for the next byte. The controller stops transferring data
when the Word Count register underflows, or an external EOP is applied.
Eight data lines (D0 - D7) are available to read/write data into the ports or control register. The RD
and WR pin, are active low signals for read and write operations.
The address lines A1 and A0 allow to successively access any one of the ports or the control
register. The control signal chip selects CS is used to enable the 8255 chips. when CS = '0', the
8255 is enabled. The RESET input is connected to the RESET pin of 8085. When the system is
reset, all the ports are initialized as input lines.
The control register or the command word register is an 8-bit register used to select the modes of
operation and input/output designation of the ports.
A1 A0 Port Selected
0 0 Port A
0 1 Port B
1 0 Port C
D7 D6 D5 D4 D3 D2 D1 D0
0 * * * B2 B1 B0 S/R
INPUT/OUTPUT MODE
This mode is selected when D7 bit of the Control Word Register is 1. There are
D7 D6 D5 D4 D3 D2 D1 D0
Ten-mark questions
Q-9. Explain architecture of 8259. Show the connection diagram of 8259 with 8085. List out the
sequence of operation performed by 8259 after an interrupt request occurs.
Q-10.Explain architecture and modes of operation of DMA controller (8237). Also explain its
interfacing with microprocessor.
Q-11.Explain the architecture and different modes of operation of 8255. Also explain its
interfacing with microprocessor.
Q-12.What is the basic difference between 8253 and 8254 timer counters? How 10 KHz square
wave can be generated with 1 MHz frequency connected to counter-0?
Q-13.Write a note on 8254. Explain programming and modes available.
Q-14.Explain the architecture of 8251 USART?
GATE questions
Ans - MODE 2