DLD&MP Unit-IV & V Notes
DLD&MP Unit-IV & V Notes
FUNDAMENTAL OF MICROPROCESSORS
INTRODUCTION TO MICROPROCESSORS:
A Microprocessor is an important part of a computer architecture without which you will not be
able to perform anything on your computer. It is a programmable device that takes in input performs some
arithmetic and logical operations over it and produces the desired output. In simple words, a Microprocessor is
a digital device on a chip that can fetch instructions from memory, decode and execute them and give results.
Basics of Microprocessor:
A Microprocessor takes a bunch of instructions in machine language and executes them, telling the
processor what it has to do. Microprocessor performs three basic things while executing the instruction:
1. It performs some basic operations like addition, subtraction, multiplication, division, and some
logical operations using its Arithmetic and Logical Unit (ALU). New Microprocessors also perform
operations on floating-point numbers also.
3. It has a Program Counter (PC) register that stores the address of the next instruction based on the
value of the PC, Microprocessor jumps from one location to another and takes decisions.
80386
Parameters 8085 Microprocessor 8086 Microprocessor Microprocessor
Year of
1977 1978 1985
Introduction
It is an 8-bit It is a 32-bit
It is a 16-bit microprocessor that
microprocessor that has microprocessor that has
Basic has the ability to function 16-bit
the ability to function 8- the ability to function 32-
data.
bit data. bit data.
Arithmetic logic 8085 contains an 8-bit 8086 contains a 16-bit ALU 80386 contains a 32-bit
unit (ALU) size ALU size. size. ALU size.
It holds 216 bytes or
It holds 220 bytes or 1MB as the
Accessible 64kb as the highest It holds 4GB as the highest
highest accessible memory
memory Scope accessible memory accessible memory scope
scope.
scope.
8086 contains 5MHz, 8MHz, 80386 contains 12MHz to
Frequency of 8085 contains 3MHz of
and 10MHz as three versions of 40MHz of clock
clock an on-chip oscillator.
clock frequency. frequency.
8085 has an 8-bit address 8086 has a 16-bit address bus 80386 has a 32-bit address
Address bus
bus size. size. bus size.
This microprocessor The 80386 microprocessor
The 8086 microprocessor
Pipelining doesn’t support supports pipelining
supports pipelining architecture.
pipelining architecture. architecture.
The 8085 The 8086 microprocessor The 80386 microprocessor
microprocessor supports supports two modes of supports three modes of
Operation mode
a single mode of operations, i.e. minimum and operations, i.e. real,
operation. maximum mode. protected, virtual mode.
Digital Logic Design and Microprocessor Notes (CSE) Page | 3
It contains 6,500 It contains 2,75,000
Transistors It contains 29,000 transistors.
transistors. transistors.
The operations like
addition, decrement, All the procedures of
subtraction, increment, All the procedures of microprocessors with
comparison, AND, shift, microprocessors with division division and
Operations
OR, and X-OR, can be and multiplication can be multiplication can be
completed by 8085. But, functioned by this processor. functioned by this
it can’t function division processor.
and multiplication
It includes 9 flags. .(sign flag,
It includes 5 flags.(sign
zero flag, auxiliary carry flag,
flag, zero flag, auxiliary
Flags parity flag, carry It includes 4 flags. ().
carry flag, parity flag and
flag,overflow,direction,interrupt
carry flag)
and trap)
Memory It doesn’t allow memory It allows memory
It allows memory segmentation.
Segmentation segmentation. Segmentation.
Architecture of 8086:
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.
U U U U OF DF IF TF SF ZF U AF U PF U CF
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.
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.
BP (Base Pointer): Base pointer is used to store the base address of the memory or stack.
SI (Source Index): Source Index is used to hold the index value of source operand for string instructions.
DI (Destination Index): DI is used to hold the index value of destination operand for string instructions.
General purpose registers are used for holding data, intermediate results, counters, mode of addressing and also
for storing effective address.
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.
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.
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.
Power supply and frequency signals: It uses 5V DC supply at VCC pin 40, and uses ground
at VSS pin 1 and 20 for its operation.
Clock signal: 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.
Address/data bus: AD0-AD15. 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.
DEN: It stands for Data Enable and is available at pin 26. It is used to enable Trans receiver
8286. The trans receiver 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 Trans receiver. 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.
RQ/GT1 and RQ/GT0: These are the Request/Grant signals used by the other processors
requesting the CPU to release the system bus. When the signal is received by CPU, then it
sends acknowledgment. RQ/GT0 has a higher priority than RQ/GT1.
In the 8086 microprocessor, there are two modes of operation: minimum mode and
maximum mode.
Maximum mode is used when the 8086 microprocessor is operating with one or more
external coprocessors or support chips. In this mode, the 8086 uses a multiplexed bus for data and
instructions, and a 20-bit address bus. The maximum mode requires additional support chips, such
as a bus controller, a clock generator, and a data buffer.
1. Minimum Mode:
When MN/MX’ = 1, the 8086 microprocessor runs in the minimum mode. All the control signals
required for memory operations and I/O interfaces are provided by the system’s only processor
running in minimum mode, the 8086, alone. The circuit in this case is simple, but it does not permit
multiprocessing.
In this mode, the microprocessor chip itself transmits all control signals. The system’s latches,
transceiver, clock generator, memory, and I/O devices make up the remaining parts.
When 8086 is used as more than just a processor to perform calculations that is when 8086 is
operating in maximum mode. The MN/MX pin is connected to the ground to operate the 8086 in
maximum mode. The system’s components are identical to those in the minimum mode system.
4 Multiprocessing cannot be
Multiprocessing can be performed.
performed.
6 The 8086 generates INTA for The 8288 Bus Controller generates the interrupt
interrupt acknowledgment. acknowledgment signal (INTA).
7 The 8086 itself provides an ALE for Because there are several processors, the 8288 bus
the latch. controller provides ALE for the latch.
Central Processing Unit (CPU): The Central Processing Unit (CPU) is the primary
component responsible for executing instructions and performing calculations. The CPU
serves as the brain of the microprocessor and is a key element in any computer or digital device.
Here are the main functions and components of a CPU within a microprocessor:
The Arithmetic and Logic Unit (ALU) is a critical component within a microprocessor responsible
for performing arithmetic and logic operations on binary data. It is an essential part of the Central
Processing Unit (CPU) and plays a key role in executing instructions and manipulating data.
Here are the main functions and features of the Arithmetic and Logic Unit (ALU) in a
microprocessor:
1. Arithmetic Operations:
Addition: The ALU can perform binary addition, adding two binary numbers
together. It takes two binary inputs and produces a sum.
Subtraction: Subtraction is often implemented using two's complement
representation. The ALU performs binary subtraction, producing a difference.
Multiplication: Some ALUs can perform multiplication, usually through a series
of shifts and additions.
Division: Division is also a complex operation, often implemented through
iterative subtraction and shifting.
2. Logic Operations:
AND Operation: The ALU performs the bitwise AND operation, where each bit
of the output is the result of the AND operation on the corresponding bits of the
input operands.
OR Operation: The ALU performs the bitwise OR operation, producing an output
where each bit is the result of the OR operation on the corresponding bits of the
input operands.
The 8086 has distinct buses for addressing, data, and control. Here's a brief overview of these
buses in the context of the 8086:
The coordination of these buses allows the 8086 microprocessor to fetch instructions and data from
memory, execute operations, and communicate with peripherals. The segmentation approach used
by the 8086, where a 20-bit physical address is formed by combining a 16-bit segment address
with a 16-bit offset address, allowed it to address a larger memory space than the actual 16-bit
address bus might suggest.
Working Registers: The 8086 microprocessor has a set of sixteen 16-bit registers, which can
be used for a variety of purposes. These registers are categorized into different groups based
on their functions. Here's an overview of the working registers in the 8086:
The working registers play a crucial role in the execution of instructions and data manipulation.
For example, during arithmetic and logic operations, data is often loaded into the AX register, and
the result is stored back in AX or another register as needed. The BX register is commonly used
for base addressing, and the SI and DI registers are often used for string operations.
In the 8086 microprocessor, clock and reset circuits play crucial roles in the proper functioning of
the processor. Let's discuss these aspects:
Clock Circuit:
The 8086 microprocessor requires a clock signal to synchronize its internal operations. The clock
signal ensures that different parts of the processor operate in harmony and at the correct timing.
The clock signal is provided by an external oscillator circuit connected to the CLK pin of the 8086.
1. Clock Frequency: The 8086 supports a variable clock frequency. The minimum and
maximum frequencies are specified in the datasheet. The clock frequency determines the
execution speed of instructions.
2. Oscillator Circuit: The external clock is usually generated by an oscillator circuit
connected to the CLK pin. The oscillator generates a stable and precise clock signal.
3. Bus Cycle Timing: The clock signal determines the timing of bus cycles. The 8086
operates on a system of bus cycles, where each instruction or operation takes a certain
number of clock cycles to complete.
Reset Circuit:
The reset circuit is responsible for initializing the microprocessor when power is applied or when
a reset signal is activated. The 8086 has two types of resets:
1. Power-On Reset (POR): This occurs when power is first applied to the microprocessor.
The power-on reset circuit ensures that the processor starts in a known state. It initializes
the internal registers and clears memory to predefined values.
2. External Reset: This can be initiated by an external signal applied to the RESET pin of
the 8086. External resets are used to restart the microprocessor during system operation.
Reset Signal: A low signal on the RESET pin indicates that a reset is active.
Initialization: During a reset, the microprocessor initializes its internal registers,
instruction pointer, flags, etc.
Memory State: The reset may also affect the state of external memory and other
peripherals.
The stack is a region of memory used for temporary storage of data during program execution. It
operates on a Last In, First Out (LIFO) basis, meaning that the last item placed onto the stack is
Stack in 8086:
1. Stack Operations:
Push: Data is placed onto the stack. The SP is decremented, and the data is stored
at the new location pointed to by SS: SP.
Pop: Data is retrieved from the stack. The data at the location pointed to by SS: SP
is used, and then SP is incremented.
2. Stack Growth:
In the 8086, the stack grows downward in memory. This means that when data is
pushed onto the stack, the SP is decremented.
3. Stack Size:
The size of the stack is determined by the size of the stack segment (SS). For
example, in real mode, where each segment can be up to 64 KB, the stack can
potentially grow up to 64 KB.
4. Instructions:
The 8086 provides instructions like PUSH and POP to facilitate stack operations.
For example, PUSH AX pushes the contents of the AX register onto the stack, and
POP BX retrieves the top of the stack into the BX register.
1. Size:
The IP register is 16 bits wide, allowing it to hold a 16-bit memory address. The
8086 is a 16-bit microprocessor, and its architecture is based on 16-bit data and
addresses.
2. Role in Instruction Fetch:
During the fetch-execute cycle, the IP is used to determine the memory address of
the next instruction. The instruction at this address is then fetched from memory for
execution.
3. Automatic Increment:
After fetching an instruction, the IP is automatically incremented to point to the
next memory location. The amount of increment depends on the size of the
instruction. For example, if the instruction is two bytes long, the IP is incremented
by 2.
4. Branching and Control Transfer:
Branch instructions, such as jumps and calls, can modify the content of the IP,
causing control to transfer to a different part of the program.
5. IP in Conjunction with CS:
The CS (Code Segment) register works in conjunction with the IP to form the
complete address of the next instruction. The physical address of the instruction is
given by the formula: CS * 16 + IP.
6. Initialization:
At the start of a program or after a reset, the IP is typically initialized to the address
of the first instruction to be executed.
In this example, at the beginning of the program, the IP is set to 1000H (the origin address). The
instructions at memory addresses 1000H and 1002H are fetched and executed sequentially. After
the execution of each instruction, the IP is automatically incremented to point to the next
instruction.
Interrupts are signals or events that can temporarily suspend the normal program execution and
transfer control to a specific interrupt service routine (ISR).There are two types of interrupts in the
8086: hardware interrupts and software interrupts.
The 8086 microprocessor has a total of 256 interrupt vectors, numbered from 0 to 255. These
vectors are addresses in memory where the interrupt service routines (ISRs) are located. The
hardware interrupts are classified into two types: maskable and non-maskable.
Software interrupts are triggered by specific instructions in the program, and they are also known
as software traps. The INT instruction is used to generate a software interrupt. When a software
interrupt occurs, control is transferred to the specified interrupt vector.
INT- Interrupt instruction with type number: It is 2-byte instruction. First byte provides
the op-code and the second byte provides the interrupt type number. There are 256 interrupt
types under this group.
The starting address for type0 interrupt is 000000H, for type1 interrupt is 00004H similarly for
type2 is 00008H and ……so on. The first five pointers are dedicated interrupt pointers. i.e. −
The interrupts from Type 5 to Type 31 are reserved for other advanced microprocessors, and
interrupts from 32 to Type 255 are available for hardware and software interrupts.
INT 3-Break Point Interrupt Instruction: It is a 1-byte instruction having op-code is CCH.
These instructions are inserted into the program so that when the processor reaches there, then
it stops the normal execution of program and follows the break-point procedure.
INTO-Interrupt on overflow instruction: It is a 1-byte instruction and their
mnemonic INTO. The op-code for this instruction is CEH. As the name suggests it is a
conditional interrupt instruction, i.e. it is active only when the overflow flag is set to 1 and
branches to the interrupt handler whose interrupt type number is 4. If the overflow flag is reset
then, the execution continues to the next instruction.
Segmentation is the process in which the main memory of the computer is logically divided into
different segments and each segment has its own base address. It is basically used to enhance the
speed of execution of the computer system, so that the processor is able to fetch and execute the
data from the memory easily and fast. Memory is organized into segments, and it uses a segmented
memory model. Each segment is 64 kilobytes (64 KB) in size, and the processor has the capability
to address up to 1 megabyte (MB) of physical memory. The memory is divided into two main
types: data memory and program memory.
1. Data Memory:
The data memory in the 8086 is used for storing variables, arrays, and other data used by the
program. The primary data segments in the 8086 are:
Data Segment (DS): This segment is used to point to the segment containing data used by
the program. The DS register is often used as an index to access data in memory.
Extra Segment (ES): The ES register is an additional segment register that can be used
for certain string operations and accessing extra data segments.
Stack Segment (SS): The SS register points to the segment containing the stack. The stack
is used for storing temporary data, local variables, and return addresses for procedure calls.
2. Program Memory:
The program memory in the 8086 is used for storing executable code. The primary code segment
is:
Code Segment (CS): This segment holds the base address of the segment containing the
executable code. The IP (Instruction Pointer) register, combined with CS, points to the current
instruction being executed.
When the processor fetches an instruction, it calculates the physical address of the instruction using
the CS register and IP register:
The 8086 uses a 16-bit addressing scheme, and the combination of CS and IP forms a 20-bit
physical address.
Introduction of Addressing Mode: Addressing modes in the context of a microprocessor refer to the
methods or techniques used to specify the operand of an instruction. The 8086 microprocessor, part of
the x86 family, supports various addressing modes, providing flexibility for programmers to access and
manipulate data in different ways. These addressing modes play a crucial role in assembly language
programming.
Addressing Modes Of 8086: Different addressing modes provide flexibility in programming and allow
efficient manipulation of data. Here are some of the addressing modes supported by the 8086:
1. Immediate Addressing Mode:
The operand is a constant data value specified directly in the instruction.
Example: MOV AX, 1234H (Move the immediate value 1234H to the AX register).
2. Register Addressing Mode:
The operand is a register.
Example: MOV CX, BX (Move the contents of register BX to register CX).
3. Direct Addressing Mode:
The operand is specified by a memory address.
Example: MOV AL, [1234H] (Move the byte at memory address 1234H to register AL).
4. Register Indirect Addressing Mode:
The operand is stored at the address contained in a register.
Example: MOV DL, [SI] (Move the byte at the address in the SI register to register DL).
5. Base-Register Addressing Mode:
The operand is located at an address formed by adding a constant displacement to the contents of a base
register (BX or BP).
Example: MOV AL, [BX+10] (Move the byte at the address BX+10 to register AL).
6. Index-Register Addressing Mode:
The operand is located at an address formed by adding a constant displacement to the contents of an
index register (SI or DI).
Example: MOV AX, [SI+20] (Move the word at the address SI+20 to register AX).
7. Base-Register with Index Addressing Mode:
The operand is located at an address formed by adding a constant displacement to the sum of the
contents of a base register and an index register.
Example: MOV AX, [BX+SI+30] (Move the word at the address BX+SI+30 to register AX).
8. Base-Register with Index and Displacement Addressing Mode:
Similar to the base-register with index addressing mode, but with an additional constant displacement.
Example: MOV CX, [BX+SI+10] (Move the word at the address BX+SI+10 to register CX).
9. Relative Addressing Mode:
Used with branch instructions, where the operand is a signed byte or word that specifies a displacement
relative to the address of the next instruction.
Example: JMP SHORT Label (Jump to the instruction at the specified label).
Data types:
Data types used in programming for the 8086 microprocessor:
1. Byte (8 bits):
Digital Logic Design and Microprocessor Notes (CSE) Page | 27
A single byte is the smallest addressable unit of memory.
Example: BYTE_VAR DB 65
2. Word (16 bits):
A word consists of two bytes or 16 bits.
Example: WORD_VAR DW 1234H
3. Double word (32 bits):
While the 8086 is a 16-bit processor, programmers can still work with 32-bit values by using two
consecutive words.
Example: DWORD_VAR DD 12345678H
4. String:
A series of consecutive bytes representing characters or data.
Example: STRING_VAR DB 'Hello'
5. Integer:
Typically a 16-bit signed or unsigned integer.
Example: INTEGER_VAR DW 32767
6. Floating Point:
Floating-point representation is not native to the 8086, but it can be emulated using software or
dedicated co-processors.
Example (using software emulation):
Assembly Copy code
FLOAT_VAR DD 3.14
7. Packed BCD (Binary Coded Decimal):
Each decimal digit is packed into a nibble (4 bits).
Example: BCD_VAR DB 09H (represents the decimal value 9)
8. ASCII Character:
A single byte representing an ASCII character.
Example: CHAR_VAR DB 'A'
9. Pointer:
A 16-bit value representing a memory address.
Example: PTR_VAR DW 1234H
10. Segment:
A 16-bit value representing a segment address.
Example: SEGMENT_VAR DW 0000H
These data types are declared in assembly language using directives such as DB (Define Byte), DW (Define
Word), DD (Define Double word), etc. The choice of data type depends on the nature of the data being
represented and the requirements of the program.