Microprocessor and Microcontroller Syllabus
Microprocessor and Microcontroller Syllabus
FOR WOMEN,UTHANGARAI
PAPER CODE:23UCS03
SUBJECT INCHARGE:[Link]
SYLLABUS
UNIT CONTENTS
UNIT I
Section No Topic
Unit Objectives
1.1 Digital Computers
1.1.1 Key Characteristics Of Digital Computers
1.1.2 Functional Components Of A Digital Computer
1.1.3 Basic Operation Of A Digital Computer
1.2 Microcomputer Organization
1.2.1 Introduction And Architecture Of Microcomputers
1.2.2 Microcomputer Architecture
1.3 Computer Languages
1.3.1 Machine Language
1.3.2 Assembly Language
1.3.3 High-Level Language
1.4 Microprocessor Architecture And Its Operations
1.4.1 Key Components Of 8085 Architecture
1.5 Microprocessor Initiated Operations And 8085 Bus
Organization
1.5.1 8085 Microprocessor Initiated Operations
1.5.2 8085 Bus Organization
1.6 Internal Data Operations And 8085 Registers
1.6.1 Internal Data Operations In 8085 Microprocessor
1.6.2 8085 Microprocessor Registers
1.7 Peripheral Or External Initiated Operations
1.7.1 Interrupt Handling
1.7.2 Direct Memory Access (DMA)
1.7.3 Input/Output Operations
1.7.4 Serial Communication
[Link] Computer Science – SEMESTER -III
A digital computer is an electronic device that processes data using binary digits (0s and 1s).
It performs a wide range of tasks by executing instructions from software programs, making
it capable of handling complex calculations, data storage, and information retrieval.
1.1.1 KEY CHARACTERISTICS OF DIGITAL COMPUTERS:
Binary System - Digital computers use the binary number system (0s and 1s) for data
representation, simplifying circuit design and ensuring reliable data processing.
High Speed and Accuracy - They perform billions of operations per second with high
precision, limited only by the hardware and software's inherent limitations.
Programmability - These computers can execute a wide range of software applications,
allowing them to perform diverse tasks and making them highly versatile.
Large Storage Capacity - Digital computers offer significant storage capabilities, enabling
the handling and processing of large volumes of data in both primary and secondary storage.
Automation - Once programmed, digital computers can perform tasks automatically without
human intervention, executing complex instruction sequences to achieve specific objectives.
1.1.2 FUNCTIONAL COMPONENTS OF A DIGITAL COMPUTER:
[Link] Central Processing Unit (CPU)
The brain of the computer, responsible for executing instructions and processing data
through its Arithmetic Logic Unit (ALU) and Control Unit (CU).
[Link] Memory and Storage
Memory (RAM and ROM): RAM provides temporary storage for active data and
instructions, while ROM stores permanent firmware essential for booting and basic
operations.
Storage Devices: Hard drives and SSDs provide long-term data storage, retaining
information even when the computer is powered off.
[Link] Input and Output Devices
Input Devices: Tools like keyboards, mice, and scanners that allow users to enter
data and commands into the computer.
Output Devices: Devices such as monitors, printers, and speakers that present
processed data to the user in visual, printed, or audio formats.
[Link] Motherboard and Bus System
Motherboard: The main circuit board that houses the CPU, memory, and other
components, providing connectivity and communication between them.
Bus System: A communication system that transfers data between
components inside the computer, including data, address, and control buses.
[Link] Power Supply and Network Interface
Power Supply Unit (PSU): Converts electrical power from an outlet into usable power
[Link] Computer Science – SEMESTER -III
for the computer’s internal components, ensuring stable and reliable operation.
Network Interface Card (NIC): Allows the computer to connect to a network,
enabling data exchange with other computers and internet connectivity.
1.1.3 BASIC OPERATION OF A DIGITAL COMPUTER:
Input: Receiving data and instructions from input devices like keyboards, mice, and scanners
for processing.
Processing: Executing instructions and performing calculations using the CPU to
transform input data into meaningful output.
Storage: Saving data and instructions in memory (RAM) for quick access or in storage devices
(HDD, SSD) for long-term retention.
Output: Presenting processed data to the user through output devices like monitors, printers,
and speakers in visual, printed, or audio formats.
Control: Managing and coordinating the operations of all computer components through
the Control Unit (CU) to ensure efficient processing and communication.
Let us sum up:
Digital Computers
1. Definition: Digital computers are electronic devices that process data in binary
form (0s and 1s) and perform computations based on predefined instructions.
2. Applications: They are used in various fields, including business, science,
engineering, healthcare, and entertainment, for tasks such as data processing,
calculations, and automation.
Key Characteristics of Digital Computers
1. Central Processing Unit (CPU): The CPU is the brain of the computer,
responsible for executing instructions and managing operations.
2. Memory: This includes both primary memory (RAM) for temporary data storage and
secondary storage (e.g., hard drives) for long-term data retention.
3. Input Devices: Devices like keyboards, mice, and scanners that allow users to enter
data into the computer.
[Link] Computer Science – SEMESTER -III
Historical Background
The concept of microcomputers emerged in the 1970s with the development of the
microprocessor, which integrated the CPU on a single chip. This innovation led to the
creation of the first personal computers like the Altair 8800 and the Apple I. Since then,
microcomputers have undergone rapid advancement, with improvements in processing power,
memory capacity, and connectivity.
Examples of Microcomputers
Microcomputers come in various forms, including desktop PCs, laptops, tablets, and
embedded systems in appliances and vehicles. They are distinguished by their ability to
perform tasks ranging from basic computing operations to complex calculations and
multimedia processing. Today's microcomputers are essential tools in education, business,
scientific research, entertainment, and everyday life.
Microcomputer Architecture
1. Central Processing Unit (CPU): Comprises the arithmetic logic unit (ALU),
[Link] Computer Science – SEMESTER -III
control unit (CU), and registers that handle data processing and instruction
execution.
2. Memory Organization:
o Primary Memory: RAM for temporary data storage and fast access.
o Secondary Memory: Hard drives, SSDs, and other storage devices for long-
term data retention.
3. Bus Structure:
o Data Bus: Transfers data between the CPU, memory, and I/O devices.
o Address Bus: Carries the address of the data to be accessed in memory.
o Control Bus: Transmits control signals to coordinate the operations of the
microcomputer components.
4. I/O System: Manages communication between the microcomputer and
peripheral devices, facilitating data input and output operations.
Answer: A) RAM
A) Mainframe B) Supercomputer
C) Microprocessor D) Minicomputer
Answer: C) Microprocessor
5. Which part of the architecture interfaces with external devices like printers?
[Link] Computer Science – SEMESTER -III
High-level languages provide a greater level of abstraction from the hardware, making
programming easier and more efficient. They are designed to be easy to read and write,
resembling natural languages or mathematical notation.
Assembly Language
High-Level Language
Answer: b) Assembler
[Link] Computer Science – SEMESTER -III
Answer: c) Assembly
3. What does an interpreter translate?
Answer: d) Python
1. Arithmetic and Logic Unit (ALU): The ALU performs arithmetic operations
(addition, subtraction) and logical operations (AND, OR, NOT, XOR). It works on 8-
bit data and sets the flags according to the result of operations.
2. Registers: The 8085 has several registers, including:
o Accumulator (A): An 8-bit register used in arithmetic and logical operations.
o General Purpose Registers (B, C, D, E, H, L): These six 8-bit registers can be
used individually or in pairs (BC, DE, HL) to hold 16-bit data.
o Program Counter (PC): A 16-bit register that holds the address of the next
instruction to be executed.
o Stack Pointer (SP): A 16-bit register that points to the top of the stack.
o Temporary Register: Used internally by the ALU for intermediate results.
o Instruction Register and Decoder: Holds the current instruction and decodes
[Link] Computer Science – SEMESTER -III
o Memory-Mapped I/O: The same address space is used for both memory
and I/O devices, allowing for flexible addressing and control.
6. Clock Generator:
o Provides the timing signals necessary for synchronizing the operations of the
microprocessor and coordinating data transfers.
1. Which unit in the 8085 microprocessor performs arithmetic and logical
operations?
a) Control Unit b) Program Counter c) ALU d) Stack Pointer
Answer: c) ALU
2. Which register is used to hold the address of the next instruction to be executed?
a) Accumulator b) Stack Pointer
1. Control Signals
Control signals are used by the microprocessor to manage data flow between itself and
external devices. The primary control signals in the 8085 microprocessor are:
[Link] Computer Science – SEMESTER -III
RD (Read): This signal indicates that the microprocessor is reading data from
memory or an I/O device. It is active low.
WR (Write): This signal indicates that the microprocessor is writing data to memory
or an I/O device. It is active low.
ALE (Address Latch Enable): This signal is used to latch the lower byte of the
address into an external latch during the first clock cycle of a machine cycle. It is
active high.
IO/M: This signal distinguishes between memory operations (when low) and I/O
operations (when high).
2. Status Signals
Status signals provide information about the current state of the microprocessor. They help in
coordinating operations with external devices. The primary status signals are:
S0 and S1: These signals indicate the status of the microprocessor and are used to
differentiate between various machine cycles.
READY: This signal is used to synchronize slower peripheral devices with the
microprocessor. When READY is low, the microprocessor enters a wait state until it
goes high.
3. Machine Cycles
The 8085 microprocessor executes instructions through a series of machine cycles, each
comprising several clock cycles. The main types of machine cycles are:
Opcode Fetch Cycle: This cycle is used to fetch the opcode of an instruction from
memory.
Memory Read/Write Cycle: These cycles are used to read data from or write data to
memory.
I/O Read/Write Cycle: These cycles are used to read data from or write data to an
I/O device.
Interrupt Acknowledge Cycle: This cycle is used to acknowledge an interrupt request
and transfer control to the interrupt service routine.
1.5.2 8085 BUS ORGANIZATION
Fig 3. Bus Organization
[Link] Computer Science – SEMESTER -III
The bus organization of the 8085 microprocessor is a critical aspect of its architecture,
enabling communication between the microprocessor and peripheral devices, memory,
and I/O ports. The 8085 microprocessor has three main types of buses: Address Bus,
Data Bus, and Control Bus.
1. Address Bus
The address bus is used to specify the address of the memory location or I/O port that the
microprocessor intends to read from or write to. Key characteristics include:
Width: The address bus is 16 bits wide, allowing the 8085 to address up to 64KB
(2^16) of memory.
Unidirectional: The address bus is unidirectional, meaning that the address flows
only from the microprocessor to the memory or I/O device.
The address bus consists of two parts:
Higher Order Address Bus (A8-A15): These are the higher 8 bits of the address.
Lower Order Address/Data Bus (AD0-AD7): These multiplexed lines serve as the
lower 8 bits of the address and data bus.
2. Data Bus
The data bus is used for transferring data between the microprocessor, memory, and I/O
devices. Key characteristics include:
Width: The data bus is 8 bits wide, allowing the transfer of 8-bit data.
Bidirectional: The data bus is bidirectional, meaning data can flow both to and from
the microprocessor.
3. Control Bus
The control bus carries control signals from the microprocessor to coordinate and manage the
operations of the system. Key control signals include:
RD (Read): Indicates that the microprocessor is reading data from memory or an I/O
port (active low).
WR (Write): Indicates that the microprocessor is writing data to memory or an I/O
port (active low).
ALE (Address Latch Enable): Used to latch the lower 8 bits of the address during
the first clock cycle of a machine cycle (active high).
IO/M: Distinguishes between memory operations (low) and I/O operations (high).
Other control signals include READY, S0/S1 (status signals), and INTA (interrupt
acknowledge).
Microprocessor Initiated Operations
1. Instruction Fetch:
o The microprocessor fetches the instruction from memory using the
Program Counter (PC) to identify the memory address.
o The instruction is loaded into the Instruction Register (IR) for decoding and
execution.
[Link] Computer Science – SEMESTER -III
5. I/O Addressing:
o The 8085 microprocessor supports two I/O addressing modes:
Memory-Mapped I/O and I/O-Mapped I/O.
o In memory-mapped I/O, all devices share the same address space as memory,
while I/O-mapped I/O uses a separate address space for I/O devices.
1. What is the function of the ALE signal in the 8085 microprocessor?
a) Read data from memory b) Write data to I/O port
c) Latch the lower byte of the address d) Acknowledge an interrupt
Answer: c) Latch the lower byte of the address
2. Which signal is used to distinguish between memory and I/O operations?
a) RD b) IO/M c) WR d) S0/S1
Answer: b) IO/M
3. How many bits wide is the address bus of the 8085 microprocessor?
a) 16 bits b) 8 bits c) 32 bits d) 64 bits
Answer: a) 16 bits
4. The address bus in the 8085 microprocessor is:
Answer: b) Unidirectional
5. Which lines in the 8085 microprocessor represent the higher 8 bits of the address
bus?
a) AD0-AD7 b) IO/M c) S0-S1 d) A8-A15
Answer: d) A8-A15
1. Arithmetic Operations
Logical operations involve manipulating the bits of data within the registers. These include
AND, OR, XOR, compare, and rotate operations:
AND (ANA): This instruction performs a bitwise AND operation between the
contents of the accumulator and a specified register or memory location. For example,
ANA B performs a bitwise AND between the accumulator and register B.
OR (ORA): This instruction performs a bitwise OR operation between the contents of
the accumulator and a specified register or memory location. For example, ORA C
performs a bitwise OR between the accumulator and register C.
XOR (XRA): This instruction performs a bitwise XOR operation between the
contents of the accumulator and a specified register or memory location. For example,
XRA D performs a bitwise XOR between the accumulator and register D.
Compare (CMP): Compares the contents of the accumulator with a specified register
or memory location. For example, CMP E compares the accumulator with register E.
Complement (CMA): This instruction complements (inverts) the bits of the
accumulator.
Rotate: These instructions rotate the bits in the accumulator left or right. RLC rotates
bits to the left, and RRC rotates bits to the right.
3. Data Transfer Operations
Data transfer operations move data between registers, between registers and memory,
or between the accumulator and memory. Key instructions include:
[Link] Computer Science – SEMESTER -III
Move (MOV): Transfers data from one register to another. For example, MOV A, B
copies the contents of register B to the accumulator.
Move Immediate (MVI): Transfers an immediate value to a register. For example,
MVI C, 32H moves the immediate value 32H to register C.
Load and Store (LDA, STA): LDA loads data from a specified memory location to the
accumulator. STA stores data from the accumulator to a specified memory location.
Exchange (XCHG): Exchanges the contents of register pairs. For example, XCHG
exchanges the contents of register pairs DE and HL.
4. Branching Operations
Branching operations alter the sequence of instruction execution based on certain conditions.
These include jumps, calls, and returns:
Jump (JMP): Transfers control to a specified memory address. For example, JMP
2000H jumps to address 2000H.
Conditional Jump: Transfers control based on specific conditions (e.g., zero, carry,
parity). For example, JZ 3000H jumps to address 3000H if the zero flag is set.
Call (CALL): Transfers control to a subroutine at a specified address. For example,
CALL 4000H calls the subroutine at address 4000H.
Return (RET): Returns control from a subroutine to the main program.
These internal data operations enable the 8085 microprocessor to perform complex
computational tasks and process data efficiently. Understanding these operations is essential
for programming and optimizing microprocessor-based systems.
1.6.2 8085 MICROPROCESSOR REGISTERS
The 8085 microprocessor, designed by Intel, contains several registers that are used to store
data temporarily during the execution of instructions. Registers are faster to access than
memory and play a crucial role in the microprocessor's operation. The 8085 microprocessor
includes the following types of registers: Accumulator, General
Purpose Registers, Special Purpose Registers (Program Counter, Stack Pointer), and Status
Flags.
1. Accumulator (A)
The Accumulator is an 8-bit register used in arithmetic, logical, and data transfer operations.
It is one of the most important registers in the 8085 microprocessor because:
The 8085 has six general-purpose registers, each of 8 bits, which can be used individually or
as pairs for 16-bit operations. These registers are named B, C, D, E, H, and L.
[Link] Computer Science – SEMESTER -III
B and C: Used individually for 8-bit data or combined as a 16-bit register pair BC.
D and E: Similarly used for 8-bit data or combined as the 16-bit register pair DE.
H and L: Also used individually for 8-bit data or combined as the 16-bit register pair
HL.
The HL pair is particularly important as it is often used to store memory addresses that point to
data in memory.
The Program Counter is a 16-bit register that holds the address of the next
instruction to be executed.
It is automatically incremented after fetching an instruction.
It is used to sequence the execution of the instructions in a program.
If the current instruction is a branching instruction (e.g., JMP, CALL), the
Program Counter is updated to the new address.
The Stack Pointer is a 16-bit register that points to the top of the stack.
The stack is a special area of memory used for temporary storage of data and
addresses during program execution, especially during function calls and interrupts.
The Stack Pointer is decremented or incremented by 2 as data is pushed onto or
popped off the stack.
4. Temporary Registers
The 8085 microprocessor uses several temporary registers that are not accessible to the
programmer but are crucial for its internal operations. These registers are used during the
execution of instructions to hold intermediate results.
5. Status Flags
The 8085 microprocessor has five status flags that indicate the results of arithmetic and
logical operations. These flags are part of the 8-bit flag register, where only five bits are used:
Sign Flag (S): Set if the most significant bit (MSB) of the result is 1, indicating a
negative number in signed operations.
Zero Flag (Z): Set if the result of the operation is zero.
Auxiliary Carry Flag (AC): Set if there is a carry out of the lower nibble (4 bits)
during an arithmetic operation.
Parity Flag (P): Set if the number of 1 bits in the result is even.
Carry Flag (CY): Set if there is a carry out of the most significant bit during an
arithmetic operation or if the result is too large for the register.
[Link] Computer Science – SEMESTER -III
The Instruction Register holds the opcode of the current instruction being
executed.
The Decoder interprets the opcode and generates the necessary control signals to
execute the instruction.
Addition Example:
In this example, the Accumulator (A) is used to store the operand and the result of the
addition operation. Register B holds another operand.
Data Transfer Example:
1. Data Fetching:
o The microprocessor retrieves data from memory or I/O devices based on the
instructions fetched from memory.
o Data is loaded into the registers for processing, enabling efficient
manipulation during operations.
2. Data Processing:
o The Arithmetic Logic Unit (ALU) performs various operations such as
addition, subtraction, logical AND, OR, and NOT on the data stored in
registers.
o Intermediate results are temporarily stored in the accumulator or other
registers as the operations are executed.
3. Data Storage:
o After processing, the final results are written back to memory or stored in
registers for future use.
o This involves sending the data to the specified memory address or
register as dictated by the instruction set.
4. Status Flags:
[Link] Computer Science – SEMESTER -III
1. General-Purpose Registers:
o The 8085 microprocessor contains six 8-bit general-purpose registers: B, C,
D, E, H, and L.
o These registers can be used to hold data, addresses, or intermediate results
during computations.
2. Accumulator (A):
o The accumulator is a special 8-bit register used for arithmetic and
logical operations.
o It is the primary register for storing results from the ALU and is involved in
most instructions.
3. Program Counter (PC):
o The Program Counter is a 16-bit register that holds the address of the next
instruction to be executed.
o It increments automatically after each instruction fetch, ensuring
sequential execution of programs.
4. Stack Pointer (SP):
o The Stack Pointer is a 16-bit register that points to the top of the stack in
memory, facilitating temporary storage of data, return addresses, and
function parameters.
o It is essential for managing function calls and returns during program
execution.
5. Instruction Register (IR):
o The Instruction Register holds the current instruction being executed after it
has been fetched from memory.
o It plays a crucial role in instruction decoding, enabling the control unit to
generate the necessary control signals for execution.
6. Flag Register:
o The Flag Register is an 8-bit register that contains status flags (Zero, Carry,
Sign, Parity, and Auxiliary Carry) that reflect the outcome of arithmetic
and logical operations.
o These flags are used for decision-making in conditional instructions.
[Link] Computer Science – SEMESTER -III
Answer: b) CALL
4. What does the Carry Flag (CY) indicate in the 8085 microprocessor?
Interrupts are signals that temporarily halt the current execution of the microprocessor to
attend to a high-priority task. The 8085 microprocessor supports several types of interrupts,
categorized as hardware and software interrupts.
Hardware Interrupts:
TRAP: A non-maskable interrupt with the highest priority. It cannot be disabled and is
typically used for critical events like power failure.
RST7.5, RST6.5, RST5.5: Maskable vectored interrupts with decreasing priority
from RST7.5 to RST5.5. They can be enabled or disabled using software instructions.
INTR: A non-vectored interrupt with the lowest priority. It requires an external
device to provide the interrupt vector (address of the interrupt service routine).
Software Interrupts:
These are instructions like RST0 to RST7, which cause the microprocessor to jump to
a predefined memory location to execute a subroutine.
Interrupt Process: When an interrupt occurs, the following steps are performed:
DMA allows peripheral devices to transfer data directly to or from memory without involving
the microprocessor, thereby freeing the microprocessor to perform other tasks. The 8085
supports DMA through the HOLD and HLDA signals.
[Link] Computer Science – SEMESTER -III
HOLD: An external device requests the use of the system buses by asserting the
HOLD signal.
HLDA: The microprocessor acknowledges the HOLD request by asserting the HLDA
signal, indicating that it has relinquished control of the buses.
In DMA mode, the external device directly controls the memory address and data buses to
transfer data between memory and the peripheral device.
The 8085 microprocessor communicates with peripheral devices through I/O ports using two
primary methods: I/O-mapped I/O and memory-mapped I/O.
I/O-mapped I/O:
Uses special instructions IN and OUT to transfer data between the accumulator and I/O
ports.
The I/O ports have an 8-bit address space, allowing for 256 distinct I/O ports.
Example:
IN 80H ; Read data from I/O port with address 80H into the accumulator OUT
81H ; Write data from the accumulator to I/O port with address 81H
Memory-mapped I/O:
STA 5000H ; Store the accumulator content at memory location 5000H (which is an
I/O device in memory-mapped I/O)
1.7.4. Serial Communication
The 8085 microprocessor also supports serial communication through the SID (Serial Input
Data) and SOD (Serial Output Data) lines, allowing for bit-by-bit data transfer with external
devices.
SID: Used for receiving serial data. SOD: Used for transmitting serial data.
Example:
SIM ; Set Serial Output Data (SOD) based on accumulator content
[Link] Computer Science – SEMESTER -III
Peripheral or external initiated operations in the 8085 microprocessor are essential for
effective communication with external devices and handling high-priority tasks.
Understanding interrupt handling, DMA, I/O operations, and serial communication enables
the implementation of responsive and efficient microprocessor-based systems. These
capabilities allow the 8085 to interact seamlessly with a wide range of peripherals, making it
suitable for various applications in embedded systems and real-time processing.
1. Interrupt Handling:
o Definition: Interrupts are signals from peripheral devices indicating that they
require attention from the microprocessor, allowing it to pause its current
operations to respond to the event.
o Types of Interrupts: Includes hardware interrupts (triggered by external
devices) and software interrupts (initiated by programs). The 8085
microprocessor supports several interrupt types, such as RST (Restart) and
INTR (Interrupt Request).
o Process: Upon receiving an interrupt, the microprocessor saves the current
execution context, determines the type of interrupt, and executes the
corresponding interrupt service routine (ISR) to address the request before
resuming normal operations.
2. Direct Memory Access (DMA):
o Definition: DMA is a method that allows peripheral devices to transfer data to
and from memory independently of the CPU, improving system performance
by freeing up the processor for other tasks.
o Operation: A DMA controller takes control of the address and data buses,
allowing it to read from or write to memory directly. The microprocessor is
notified once the data transfer is complete, minimizing the need for constant
CPU intervention.
o Advantages: Reduces CPU overhead and increases data transfer efficiency,
making it suitable for high-speed data transfer applications like disk drives and
video processing.
3. Input/Output Operations:
o I/O Interfaces: The 8085 microprocessor interfaces with various peripheral
devices through memory-mapped I/O and I/O-mapped I/O addressing modes,
allowing it to read from and write to devices such as keyboards, displays, and
sensors.
o Control Signals: The microprocessor generates control signals (READ,
WRITE) to manage data flow between itself and I/O devices, coordinating
communication effectively.
[Link] Computer Science – SEMESTER -III
o Polling vs. Interrupts: In polling, the CPU regularly checks the status of I/O
devices, which can be inefficient. In contrast, interrupts allow the CPU to react
only when an I/O device requires attention, improving efficiency.
4. Serial Communication:
o Definition: Serial communication refers to the process of transmitting data
one bit at a time over a single communication channel or wire, making it
suitable for long-distance communication and reducing wiring complexity.
o Protocols: Common serial communication protocols include UART
(Universal Asynchronous Receiver-Transmitter) and SPI (Serial Peripheral
Interface), which define the methods for data transmission, error checking, and
synchronization.
o Application: Used in various applications, including connecting
microprocessors to sensors, data acquisition systems, and communication
between devices in embedded systems.
1. Which interrupt in the 8085 microprocessor has the highest priority and cannot
be disabled?
a) RST7.5 b) INTR c) TRAP d) RST5.5
Answer: c) TRAP
3. How many distinct I/O ports can be addressed using I/O-mapped I/O in the 8085?
a) 128 b) 256 c) 512 d) 1024
Answer: b) 256
8085 Microprocessor – Pinout and Signals – Functional block diagram - 8085 Instruction
Set and Classifications
signals.
Instruction Register (IR): Holds the current instruction being executed.
Timing and Control Unit: Generates timing and control signals for
coordinating operations.
Interrupt Control: Manages interrupt signals from external devices.
Block Diagram Components:
ALU: Performs arithmetic (addition, subtraction) and logical (AND, OR, NOT, XOR)
operations.
Registers (Accumulator, BC, DE, HL, SP, PC): Temporarily stores data and
addresses.
Instruction Decoder: Decodes instructions fetched from memory to produce control
signals.
Timing and Control Unit: Generates timing signals necessary for the
execution of instructions.
Interrupt Control: Manages interrupts from external devices.
2.1.4. Internal Architecture
The internal architecture of the 8085 microprocessor consists of various registers, a control
unit, and an arithmetic and logic unit (ALU).
Registers:
Accumulator (A): Stores the result of most arithmetic and logical operations.
General Purpose Registers (B, C, D, E, H, L): Used for various purposes, such as
storing operands and addresses.
Special Purpose Registers:
Program Counter (PC): Holds the memory address of the next instruction to be
fetched.
Stack Pointer (SP): Points to the top of the stack.
Flag Register: Contains flags that indicate the result of an operation (zero, carry,
etc.).
Control Unit:
Decodes instructions fetched from memory.
Generates control signals to coordinate the activities of the other units.
Arithmetic and Logic Unit (ALU):
Performs arithmetic and logical operations on data.
Uses the data from the registers and stores the result back into the registers.
Timing and Control Signals:
Machine Cycle: The execution of one instruction or operation.
Instruction Cycle: The time taken to complete an instruction.
2.1.5. Instruction Set and Classifications
The instruction set of the 8085 microprocessor consists of 74 instructions, which are
classified based on their functions and addressing modes.
Instruction Categories:
Data Transfer Instructions: MOV, MVI, LXI, LDA, STA, SHLD, LHLD.
Arithmetic Instructions: ADD, SUB, INR, DCR, ADC, SBB.
[Link] Computer Science – SEMESTER III UNIT – II
Educational purposes.
Advantages:
Simple and easy to understand.
Low cost and power consumption.
Suitable for basic control applications.
1. Introduction to Microprocessors
A microprocessor is an integrated circuit (IC) that contains the functions of a central
processing unit (CPU) of a computer.
Performs arithmetic, logic, control, and input/output (I/O) operations.
Acts as the brain of a computer or embedded system.
Key components: Arithmetic Logic Unit (ALU), Control Unit (CU), and Registers.
Examples: Intel 8085, Intel 8086, ARM processors.
2. Pinout and Signals
Pinout refers to the arrangement of pins on the microprocessor, each with a specific
function.
Common signals include:
Power and Ground Pins: For powering the microprocessor (e.g., Vcc, GND).
Data Bus: Carries data between the microprocessor and memory or
peripherals.
Address Bus: Sends the address of memory locations to be accessed.
Control Pins: Controls operations like reading, writing, and interrupt handling (e.g.,
RD, WR, RESET, INTR).
Clock Signal: Synchronizes the microprocessor’s operations (CLK).
3. Functional Block Diagram
A visual representation of the internal structure of the microprocessor.
Main blocks:
ALU: Performs arithmetic and logical operations.
Control Unit: Manages the execution of instructions.
Registers: Temporary storage for data and instructions.
Bus Interface Unit (BIU): Manages data transfer between the processor and
memory/peripherals.
Memory: Stores instructions and data.
4. Internal Architecture
Describes the internal working of the microprocessor.
Key components:
ALU: Performs operations like addition, subtraction, AND, OR.
Control Unit: Directs the operation of the processor by interpreting instructions.
Registers: Small, fast storage locations for immediate data access.
Instruction Decoder: Interprets the instructions fetched from memory.
[Link] Computer Science – SEMESTER III UNIT – II
Stack Pointer and Program Counter: Manage execution flow and memory
addressing.
5. Instruction Set and Classifications
Instruction Set: A group of commands the microprocessor can execute.
Classifications:
Data Transfer Instructions: MOV, IN, OUT, etc.
Arithmetic Instructions: ADD, SUB, MUL, DIV, etc.
Logical Instructions: AND, OR, XOR, NOT, etc.
Control Instructions: JMP, CALL, RET, etc.
Branching Instructions: Conditional (JZ, JNZ) and unconditional (JMP).
CISC (Complex Instruction Set Computing) vs. RISC (Reduced Instruction Set
Computing).
6. Programming Model
Describes how the processor executes instructions and manipulates data.
Components include:
Registers: Program Counter (PC), Stack Pointer (SP), Accumulator (A), Flag Register.
Memory: Program memory and data memory for instruction and data storage.
Flags: Status indicators such as Zero Flag (Z), Carry Flag (CY), etc.
Provides an abstraction for low-level programming.
7. Interrupts and I/O
Interrupts: Signals that temporarily halt the microprocessor’s current task to attend
to high-priority tasks.
Types of Interrupts: Maskable, Non-maskable, Software, and Hardware
interrupts.
Examples: INTR, TRAP, RST in 8085 microprocessors.
I/O (Input/Output): Interface for communication between the microprocessor and
external devices.
Memory-mapped I/O: I/O devices treated as memory locations.
Port-mapped I/O: Special instructions for I/O operations using ports.
8. Applications and Advantages
Applications:
o Embedded systems: Automotive systems, consumer electronics.
o Computing systems: Laptops, desktops, servers.
o Communication systems: Routers, modems.
o Control systems: Industrial automation, robotics.
Advantages:
o Compact size and low power consumption.
o High processing speed and efficiency.
o Versatility: Used in diverse fields from consumer electronics to industrial
systems.
o Programmable for different tasks and applications.
[Link] Computer Science – SEMESTER III UNIT – II
RD is active low during a memory read operation, while WR is active low during a
memory write operation.
IO/M (Input/Output and Memory):
IO/M indicates whether the microprocessor is performing an I/O operation or a
memory operation.
When IO/M is high, the microprocessor performs an I/O operation; when it's low, it
performs a memory operation.
S0, S1, S2 (Status Signals):
These signals provide status information about the current operation of the
microprocessor.
Different combinations of S0, S1, and S2 indicate different machine cycles.
INTA (Interrupt Acknowledge):
INTA is generated by the microprocessor to acknowledge interrupt requests from
external devices.
It indicates that the microprocessor has accepted the interrupt request and is ready to
proceed with the interrupt service routine.
2.2.4. Interrupt Signals:
Let us Sum Up
Indirect Addressing:
LHLD address: Loads H and L registers with data from the memory location
specified by address.
2.4.5. Instruction Classification
Instructions in the 8085 microprocessor are classified into groups based on their
functions and operational characteristics. The classifications include:
Data Transfer Group:
MOV, MVI, LXI, LDA, STA, SHLD, LHLD.
Arithmetic Group:
ADD, ADC, SUB, SBB, INR, DCR, CMP.
Logical Group:
ANA, XRA, ORA, CMP.
Branching Group:
JMP, JC, JNC, JZ, JNZ, CALL, RET.
Control Group:
NOP, HLT, RIM, SIM.
Stack Operations:
PUSH, POP.
2.4.6. Instruction Execution Cycle
The execution cycle of an instruction in the 8085 microprocessor typically involves
three stages:
Fetch: The instruction is fetched from memory into the instruction register (IR).
Decode: The opcode of the instruction is decoded. Execute: The instruction is
executed, and the result is stored back in the appropriate register or memory location.
Let Us Sum Up:
Instruction Format
Structure of instructions: Typically includes the opcode (operation code) and
operands (data or memory addresses involved).
Varying lengths: Instructions can be one-byte, two-byte, or three-byte
depending on the processor architecture and the number of operands.
Instruction Types and Examples
Data transfer instructions: Move data between registers, memory, or I/O
devices (e.g., MOV, LDA).
Arithmetic and logical instructions: Perform operations like addition,
subtraction, AND, OR, and XOR (e.g., ADD, SUB, AND).
Addressing Modes
Immediate addressing: The operand is provided directly within the
instruction (e.g., MVI A, 05H).
Direct, indirect, and register addressing: Specifies the location of operands
either directly, via registers, or through memory addresses (e.g., LDA 2500H,
MOV A, B).
Instruction Classification
[Link] – SEMESTER III UNIT - III
UNIT III
BCD to Binary and Binary to BCD conversions - ASCII to BCD and BCD to ASCII
conversions - Binary to ASCII and ASCII to Binary conversions. BCD Arithmetic - BCD
addition and Subtraction - Multibyte Addition and Subtraction - Multiplication and Division.
1 1 11 1011 21 10101
2 10 12 1100 22 10110
3 11 13 1101 23 10111
4 100 14 1110 24 11000
5 101 15 1111 25 11001
6 110 16 10000 26 11010
7 111 17 10001 27 11011
8 1000 18 10010 28 11100
9 1001 19 10011 29 11101
10 1010 20 10100 30 11110
Binary is the fundamental language of computers and digital systems. All operations
in a computer's hardware are performed using binary arithmetic.
3.1.2 Binary-Coded Decimal Number System
Binary-coded decimal (BCD) is a form of digital encoding where each decimal digit
(0-9) is represented by a fixed binary number. In binary-coded decimal, each individual digit
of a number is converted into a binary number, and then the BCD code is generated by
combining them all. But always remember that a binary-coded decimal is not a binary
representation of a decimal number. BCD notation for the digits 0-9 is listed below.
Number BCD
Number
1 0001
[Link] – SEMESTER III UNIT - III
2 0010
3 0011
4 0100
5 0101
6 0110
7 0111
8 1000
9 1001
Example
[Link] – SEMESTER III UNIT - III
Here are a few ASCII characters and their corresponding binary representations:
Base-2 system: Uses only two digits, 0 and 1, to represent numbers, where each
digit is a bit (binary digit).
Place value: Each bit represents a power of 2, starting from 202^020 on the right.
Example: Binary 1011 is equal to 1×23+0×22+1×21+1×20=111 \times 2^3 + 0
\times 2^2 + 1 \times 2^1 + 1 \times 2^0 = 111×23+0×22+1×21+1×20=11 in
decimal.
Binary-Coded Decimal (BCD) Number System
7-bit encoding: ASCII represents characters (letters, digits, symbols) using 7 bits,
allowing for 128 unique characters. Example: The letter 'A' is represented by 65 in
decimal, or 1000001 in binary.
Standard for text: Widely used for encoding text in computers and
communication systems, making it possible to interchange data between
systems.
1. Which number system uses only two digits, 0 and 1, to represent all
numbers?
A) Decimal
B) Binary
C) Hexadecimal
D) Octal
Answer: B) Binary
2. How many bits are used to represent each decimal digit in Binary-Coded
Decimal (BCD)?
A) 2 bits
B) 3 bits
C) 4 bits
D) 8 bits
Answer: C) 4 bits
3. In the binary number system, what is the decimal equivalent of the binary
number 1011?
A) 9
B) 10
C) 11
D) 13
Answer: C) 11
This code's result is stored in BCD_BIN. The table for BCD code equivalent to Binary code is
shown below.
Example code:
Convert binary 52 (110100) to BCD
Assume binary 52 is in register pair HL (H=00, L=34H)
BINDIV:
MVI D, 00H ; D will count number of subtractions (quotient)
DIVLP:
MOV A, L ; Move lower byte of dividend to A
SUB C ; Subtract lower byte of divisor
MOV L, A ; Store result back in L
MOV A, H ; Move higher byte of dividend to A
[Link] – SEMESTER III UNIT - III
1. Convert each BCD digit to its binary equivalent: Each 4-bit BCD digit (0-9) is
converted to its corresponding binary value. For example, BCD 0101 0011 (which
represents decimal 53) is converted to binary 110101.
2. Combine binary digits: After converting each BCD digit to binary, combine the
binary results to form the final binary number.
Binary to BCD Conversion
1. Divide the binary number: Separate the binary number into its decimal equivalent,
and then convert each decimal digit to a 4-bit BCD representation. For example,
binary 101101 (which equals 45 in decimal) is converted to BCD 0100 0101.
2. Pack into 4-bit groups: Each decimal digit is represented by a 4-bit BCD code,
which is packed together to represent the entire number.
1. In BCD (Binary-Coded Decimal), how many bits are used to represent each
decimal digit?
A) 2 bits
B) 3 bits
C) 4 bits
D) 8 bits
Answer: C) 4 bits
A) 0010 0101
B) 1010 0101
C) 1100 0011
D) 0011 0100
3. Which of the following binary numbers represents the decimal value 13?
A) 1010
B) 1110
C) 1101
D) 1001
Answer: C) 1101
4. When converting the BCD 0110 1001 to binary, what is the resulting binary
number?
A) 101110
B) 110101
C) 100001
D) 1000101
A) 0101 0000
B) 0011 0100
C) 0100 0011
D) 0110 1010
6. How is the binary number 101101 (which equals 45 in decimal) represented in BCD?
A) 0101 1010
B) 1001 1100
C) 0100 0101
D) 1101 0110
RET
RET
HLT ; Halt
1. Convert each BCD digit to its ASCII equivalent: Each BCD digit (4-bit binary) is
converted to its 8-bit ASCII code by adding a fixed value of 0011 0000 (or 30H in
hexadecimal). For example, BCD 0101 (which represents the digit 5) becomes ASCII
0011 0101 (or 35H in hexadecimal).
[Link] – SEMESTER III UNIT - III
1. Remove the ASCII prefix: Convert each ASCII character (which is in the range of
0011 0000 to 0011 1001 for digits 0-9) to BCD by subtracting 0011 0000 (30H). For
example, ASCII 0011 0101 (which represents the character '5') becomes BCD 0101.
2. Pack into 4-bit BCD: After removing the ASCII prefix, the resulting binary is stored
as a 4-bit BCD value representing the original decimal digit.
A) 0011 0011
B) 0011 0001
C) 0010 0011
D) 0011 0100
3. When converting the ASCII character 0011 0101 (which represents the
character '5') to BCD, what is the resulting BCD value?
A) 0101
B) 0011
C) 0000
D) 0010
4. Which of the following is true regarding ASCII values for digits 0-9?
5. What is the BCD equivalent of the ASCII character 0011 1000 (which
represents the character '8')?
A) 0111
B) 1000
C) 0011
D) 1001
To convert ASCII digits to binary in 8085 assembly, load the ASCII character (values
30H to 39H) into the accumulator. Subtract 30H (the ASCII value for '0') to obtain the binary
equivalent, as digits '0' to '9' map to values 0-9.
[Link] – SEMESTER III UNIT - III
1. Group binary bits: Divide the binary input into 8-bit segments, as ASCII characters
are represented by 8 bits. For example, the binary 01000001 corresponds to the ASCII
character 'A'.
2. Convert to ASCII character: Each 8-bit segment is converted to its corresponding
ASCII character based on the ASCII table. For instance, the binary 01101000
translates to the ASCII character 'h'.
ASCII to Binary Conversion
1. Convert each ASCII character to binary: Each character from the ASCII input is
represented by its corresponding 8-bit binary value. For example, the ASCII character
'A' is represented as 01000001.
2. Concatenate binary values: The binary values for each ASCII character are
concatenated together to form a continuous binary string. For example, the ASCII
string "Hi" is converted to binary as 01001000 01101001.
1. How many bits are used to represent each ASCII character?
A) 4 bits
B) 6 bits
C) 8 bits
D) 16 bits
Answer: C) 8 bits
2. What is the ASCII representation of the binary value 01000010?
A) 'A'
B) 'B'
C) 'C'
D) 'D'
Answer: B) 'B' (The binary 01000010 corresponds to the ASCII character 'B')
[Link] – SEMESTER III UNIT - III
3. When converting the ASCII character 'C' (which has a decimal value of 67) to binary,
what is the resulting binary value?
A) 01000010
B) 01000011
C) 01000100
D) 01000101
A) 01001000 01101001
B) 01001000 01101010
C) 01000111 01101001
D) 01001001 01101000
Answer: A) 01001000 01101001 (The ASCII string "Hi" corresponds to the binary values for
'H' and 'i')
5. If the binary sequence 01101000 is converted to ASCII, which character is
represented?
A) 'g'
B) 'h'
C) 'i'
D) 'j'
Answer: B) 'h' (The binary 01101000 corresponds to the ASCII character 'h')
MOV A, BCD1 ; Load the first BCD number into the accumulator
1. Load the BCD Numbers: Load the BCD numbers to be subtracted into registers.
2. Perform Subtraction: Subtract the second BCD number from the first.
3. Adjust Result: Use the DAA (Decimal Adjust Accumulator) instruction to adjust the
result to a valid BCD format.
4. Store the Result: Store the adjusted result in the desired memory location.
[Link] – SEMESTER III UNIT - III
MOV A, BCD1 ; Load the first BCD number into the accumulator
NO_ADJUST:
BCD Addition
1. Add BCD digits: Each pair of BCD digits is added using regular binary addition. The
sum may exceed the maximum BCD digit (9), which is represented as 1001 in binary.
2. Adjust for carry: If the sum of any BCD digit exceeds 9 (or 1001), a correction is
needed. A constant of 0000 1010 (which is 10 in decimal) is added to the result, and
the carry is accounted for in the next digit.
BCD Subtraction
1. Subtract BCD digits: BCD subtraction involves subtracting the BCD digits using
binary subtraction rules. If the result of a subtraction operation is negative, it requires
adjustment.
2. Borrowing and adjustment: If a BCD digit is subtracted from a smaller digit, a
borrowing process occurs, and a correction factor of 0000 1010 (10) is added to the
result to ensure it remains a valid BCD representation.
1. What is the maximum BCD digit?
A) 7
B) 8
C) 9
D) 10
Answer: C) 9
2. In BCD addition, what is the correction factor added if the sum exceeds 9?
A) 0000 0110
B) 0000 1000
C) 0000 1010
D) 0000 1100
3. When performing BCD subtraction, what occurs if the minuend is less than
the subtrahend?
B) A borrow is required
C) The subtraction is invalid
B) 0000 1011
C) 0001 0001
D) 0000 1100
Answer: A) 0001 0011 (The sum is 11 in decimal; since it's a BCD result, a correction
factor is applied)
5. What is the BCD result of subtracting 0100 (4) from 0011 (3)?
A) 0000
B) 0001 0110
C) 0001 0010
D) 0000 1000
Answer: D) 0000 1000 (Since you need to borrow, you effectively get 10 - 4 = 6)
A) 0000 0001
B) 0000 0100
C) 0000 1000
D) 0000 1010
Answer: D) 0000 1010 (This adjustment is made when the result is negative)
MULTIBYTE BCD ADDITION
1. Initialize Carry: Set the carry flag (CY) to 0 before starting the addition.
2. Load the BCD Numbers: Load each BCD number into separate registers or memory
locations.
3. Add the Least Significant Digits (LSDs): Add the LSDs of the BCD numbers,
including the previous carry if any.
4. Adjust for BCD: Use the DAA (Decimal Adjust Accumulator) instruction to
adjust the result.
5. Store the LSD Result: Store the LSD result in memory or a register.
6. Add the Most Significant Digits (MSDs): Add the MSDs of the BCD numbers,
including the carry from the LSD addition.
7. Adjust for BCD: Use DAA to adjust the MSD result.
8. Store the MSD Result: Store the MSD result in memory or a register.
9. Repeat for Remaining Bytes: If there are more bytes to add, repeat steps 3- 8 for
each byte.
10. Handle Overflow: Check for overflow after adding the last byte. If overflow occurs,
handle it appropriately (e.g., flag an error or adjust the result).
ORG 0000H ; Starting address
; Clear carry
MOV A, 00
MOV E, A
ADD_LOOP:
LDAX D ; Load byte from BCD2
ADD M ; Add byte from BCD1
DAA ; Decimal adjust accumulator
MOV M, A ; Store result byte in RESULT
INX H ; Increment pointer for BCD1
INX D ; Increment pointer for BCD2
INX B ; Increment pointer for RESULT
DCR C ; Decrement byte count
JZ DONE ; If byte count is zero, end
MOV A, E ; Move carry to accumulator
JNC NO_CARRY
MVI A, 01 ; Set A to 1 if carry
NO_CARRY:
MOV E, A ; Store carry
JMP ADD_LOOP
DONE:
HLT ; Halt the program
BCD1 DB 25H, 34H, 12H ; Example BCD number 1
BCD2 DB 37H, 45H, 23H ; Example BCD number 2
RESULT DS 3 ; Space for the result (3 bytes)
1. Initialize Borrow: Set the borrow flag (CY) to 0 before starting the subtraction.
2. Load the BCD Numbers: Load each BCD number into separate registers or memory
locations.
3. Subtract the Least Significant Digits (LSDs): Subtract the LSDs of the BCD
numbers, including the previous borrow if any.
4. Adjust for BCD: Use the DAA (Decimal Adjust Accumulator) instruction to
adjust the result.
5. Store the LSD Result: Store the LSD result in memory or a register.
6. Subtract the Most Significant Digits (MSDs): Subtract the MSDs of the BCD
numbers, including the borrow from the LSD subtraction.
7. Adjust for BCD: Use DAA to adjust the MSD result.
8. Store the MSD Result: Store the MSD result in memory or a register.
9. Repeat for Remaining Bytes: If there are more bytes to subtract, repeat steps 3-8 for
each byte.
10. Handle Borrow: Check for borrow after subtracting the last byte. If borrow
occurs, handle it appropriately (e.g., flag an error or adjust the result).
; Clear carry
MOV A, 00
MOV E, A
[Link] – SEMESTER III UNIT - III
ADD_LOOP:
LDAX D ; Load byte from BCD2
ADD M ; Add byte from BCD1
DAA ; Decimal adjust accumulator
MOV M, A ; Store result byte in RESULT
INX H ; Increment pointer for BCD1
INX D ; Increment pointer for BCD2
INX B ; Increment pointer for RESULT
DCR C ; Decrement byte count
JZ DONE ; If byte count is zero, end
MOV A, E ; Move carry to accumulator
JNC NO_CARRY
MVI A, 01 ; Set A to 1 if carry
NO_CARRY:
MOV E, A ; Store carry
JMP ADD_LOOP
DONE:
HLT ; Halt the program
1. Segment the BCD values: Multibyte BCD numbers are divided into individual bytes,
with each byte representing a single BCD digit (4 bits each). For
[Link] – SEMESTER III UNIT - III
example, the BCD number 0011 0001 0100 represents the decimal number 314.
2. Perform byte-wise addition: Add each BCD byte starting from the least significant
byte (LSB) to the most significant byte (MSB), carrying any overflow to the next byte.
If the sum of any byte exceeds 1001, add the correction factor 0000 1010 and carry
over the adjustment to the next byte.
1. Segment the BCD values: Similar to addition, multibyte BCD numbers are divided
into individual bytes for subtraction. Each byte is processed separately.
2. Perform byte-wise subtraction: Subtract each BCD byte starting from the LSB to
the MSB. If a subtraction results in a negative value, borrow from the next higher byte,
and add the correction factor 0000 1010 to maintain a valid BCD representation.
1. When performing multibyte BCD addition, what should you do if the sum of a byte
exceeds 1001?
2. In multibyte BCD subtraction, if a BCD byte results in a negative value, what is the
necessary adjustment?
4. In a multibyte BCD number 0011 0001 0100 (representing 314), how would
you add 0000 0101 (representing 5) to it?
[Link] – SEMESTER III UNIT - III
BCD multiplication can be approached by performing repeated addition. Here, we'll multiply
two 2-byte BCD numbers.
Data:
LXI H, BCD1 ; Point to the start of the first BCD number LXI D,
BCD2 ; Point to the start of the second BCD number LXI
B, RESULT ; Point to the start of the result
MVI C, 04 ; Set byte count for the result (4 bytes)
LXI H, BCD2 ; Point to the start of the second BCD number LXI
D, RESULT ; Point to the start of the result
MUL_LOOP:
[Link] – SEMESTER III UNIT - III
MULTIPLY_BYTE:
MUL_BYTE_LOOP:
RET
DAA
MOV M, A
INX D
RET
BCD division can be approached by repeated subtraction. Here, we'll divide two 2- byte
BCD numbers.
Data:
DIV_DONE:
MOV A, M
SUB D
JC NO_ADJUST
NO_ADJUST:
DAA
MOV M, A
INX D
RET
1. Segment the BCD values: Similar to addition and subtraction, multibyte BCD
numbers are divided into individual bytes, where each byte represents a single BCD
digit (4 bits each).
2. Perform multiplication: Each BCD digit is multiplied using binary multiplication
rules. The products may be larger than a single BCD digit (up to 16 in decimal), so
each product is checked. If it exceeds 1001, a correction of 0000 1010 must be added,
and any overflow is carried to the next byte.
Multibyte BCD Division
1. Segment the BCD values: The multibyte BCD numbers are divided into individual
bytes for division, just like in addition, subtraction, and multiplication.
2. Perform division: Each BCD digit is divided using binary division rules. If a byte
results in a quotient or remainder that is not valid in BCD (greater than 9), adjustments
may be required. The quotient is checked, and if necessary, the correction factor 0000
1010 is used to adjust the result to maintain valid BCD representation.
5. During multibyte BCD multiplication, what is the maximum value a single BCD
product can represent?
A) 5
B) 9
C) 10
D) 15
UNIT IV
The 8085 Interrupts – RIM AND SIM instructions - 8259 Programmable Interrupt
Controller - Direct Memory Access (DMA) and 8257 DMA controller.
Vectored and Non-Vectored Interrupts – Vectored Interrupts are those which have
fixed vector address (starting address of sub-routine) and after executing these, program
control is transferred to that address. Vector Addresses are calculated by the formula 8 *
TYPE
[Link] CS – SEMESTER III UNIT - IV
RST 5.5 2C H
RST 6.5 34 H
RST 7.5 3C H
RST 0 00 H
RST 1 08 H
RST 2 10 H
RST 3 18 H
RST 4 20 H
RST 5 28 H
RST 6 30 H
RST 7 38 H
Non-Vectored Interrupts are those in which vector address is not predefined. The
interrupting device gives the address of sub-routine for these interrupts. INTR is the only
non-vectored interrupt in 8085 microprocessor.
Maskable and Non-Maskable Interrupts – Maskable Interrupts are those which can be
disabled or ignored by the microprocessor. These interrupts are either edge-
triggered or level-triggered, so they can be disabled. INTR, RST 7.5, RST 6.5, RST
5.5 are maskable interrupts in 8085 microprocessor. Non-Maskable Interrupts are those which
cannot be disabled or ignored by microprocessor. TRAP is a non- maskable interrupt. It
[Link] CS – SEMESTER III UNIT - IV
consists of both level as well as edge triggering and is used in critical power failure
conditions.
Priority of Interrupts – When microprocessor receives multiple interrupt requests
simultaneously, it will execute the interrupt service request (ISR) according to the priority of
the interrupts.
Fig 1. Interrupts
4. Read Interrupt Mask (RIM) – This instruction is used to read the status of the
hardware interrupts (RST 7.5, RST 6.5, RST 5.5) by loading into the A register a byte
which defines the condition of the mask bits for the interrupts. It also reads the
condition of SID (Serial Input Data) bit on the microprocessor.
priority conflicts and result in incorrect operation or system failure. Therefore, the
priority levels of each interrupt signal need to be carefully designed and tested to
avoid conflicts.
2. Race conditions: Race conditions can occur when multiple processes try to
access the same resources, such as registers or memory locations,
simultaneously. This can lead to incorrect results or system failure. Therefore,
interrupt handlers need to be carefully designed to avoid race conditions, such as
by disabling interrupts during critical operations.
3. Interrupt latency: Interrupt latency is the time delay between when an interrupt
occurs and when the corresponding ISR starts executing. Interrupt latency can
affect the system’s responsiveness and real-time performance. Therefore, interrupt
handlers need to be designed to minimize interrupt latency, such as by using fast
interrupt service routines and optimizing the interrupt handling process.
4. Interrupt nesting: Interrupt nesting occurs when an interrupt occurs while the
microprocessor is executing an ISR for another interrupt. Interrupt nesting can
lead to complex interrupt handling and priority conflicts. Therefore, interrupt
handlers need to be carefully designed to avoid interrupt nesting, such as by
disabling lower-priority interrupts during critical operations.
5. Interrupt overhead: Interrupt overhead is the additional processing time and
resources required to handle interrupts. Interrupt overhead can affect the system’s
performance and efficiency, especially if the system experiences a high volume of
interrupts. Therefore, interrupt handlers need to be designed to minimize interrupt
overhead, such as by optimizing the interrupt handling process and reducing
unnecessary operations.
Let us sum up
The 8085 Interrupts
1. TRAP Interrupt:
o Description: TRAP is a non-maskable interrupt that is the highest
priority among the 8085 interrupts, allowing it to interrupt the
microprocessor immediately.
o Functionality: It is typically used for critical tasks such as emergency stop
functions or system failures, ensuring that important events are handled
promptly.
o Vector Address: The TRAP interrupt is assigned a vector address of 0024H,
where the corresponding interrupt service routine (ISR) begins execution.
2. RST 7.5 Interrupt:
o Description: RST 7.5 is a maskable interrupt with a medium priority level,
allowing it to be enabled or disabled through the interrupt enable (EI) and
disable (DI) instructions.
o Functionality: It is used for handling specific events that are not as
critical as TRAP but still require attention from the microprocessor.
o Vector Address: The vector address for RST 7.5 is 003CH, where the ISR for
this interrupt is executed.
[Link] CS – SEMESTER III UNIT - IV
Answer: b) To temporarily halt the execution of the current program and redirect
control to an interrupt service routine (ISR)
2. Which of the following interrupts has the highest priority in the 8085
microprocessor?
a) RST 7.5
b) RST 6.5
c) INTR
d) TRAP
Answer: d) TRAP
[Link] CS – SEMESTER III UNIT - IV
Answer: c) TRAP
4. Which interrupt is non-vectored in the 8085 microprocessor?
a) TRAP
b) RST 6.5
c) RST 7.5
d) INTR
Answer: d) INTR
Answer: b) 5
Answer: d) EI
7. What is the vector address for the RST 5.5 interrupt in the 8085
microprocessor?
a) 00H
b) 2CH
c) 3CH
d) 28H
Answer: b) 2CH
[Link] CS – SEMESTER III UNIT - IV
The SIM (Set Interrupt Mask) and RIM (Read Interrupt Mask) instructions are two
instructions in the 8085 microprocessor that are used to control interrupts.
The SIM instruction allows the microprocessor to selectively enable or disable interrupts
by setting the appropriate bits in the Interrupt Mask Register (IMR). The IMR is a register that
controls which interrupts are allowed to be processed by the microprocessor. The SIM
instruction takes one byte as an operand and sets the corresponding bits in the IMR based on
the value of the operand.
The RIM instruction, on the other hand, reads the current value of the IMR and copies it
to the accumulator. This allows the microprocessor to check which interrupts are currently
enabled or disabled. The RIM instruction takes no operands and simply reads the value of the
IMR.
These instructions are commonly used in embedded systems and other applications that
require interrupt-driven processing. By selectively enabling or disabling interrupts, the
microprocessor can control the flow of data and ensure that critical tasks are executed in a
timely manner. The SIM and RIM instructions are
[Link] CS – SEMESTER III UNIT - IV
important tools for managing interrupts and optimizing the performance of the
microprocessor in various applications.
Set Interrupt Mask (SIM) : In 8085 Instruction set, SIM stands for “Set Interrupt Mask”.
It is 1-Byte instruction and it is a multi-purpose instruction.
The main uses of SIM instruction are –
It is responsible for
masking/unmasking of RST 7.5, It checks whether RST 7.5, RST 6.5,
2 RST 6.5 and RST 5.5. RST 5.5 are masked or not.
SIM instruction can be used for RIM instruction can be used for
5 serial output of data. serial input of data.
Takes no operand
7 Takes a byte operand
[Link] CS – SEMESTER III UNIT - IV
SIM instruction changes the RIM instruction does not modify any
10 contents of the IMR registers or flags
SIM instruction is used for setting RIM instruction is used for reading
the mask register before an interrupt the mask register during interrupt
11 is enabled service routine
Let us sum up
RIM (Read Interrupt Mask) Instruction
1. Purpose: The RIM instruction is used to read the status of interrupt signals and the
interrupt mask from the 8085 microprocessor, allowing the program to check which
interrupts are currently enabled or pending.
2. Functionality: Upon execution, RIM places the status of the interrupt system in the
accumulator. This includes:
o The status of the interrupt lines (TRAP, RST 7.5, RST 6.5, RST 5.5, and
INTR).
o The state of the interrupt mask (which interrupts are enabled or
disabled).
3. Register Status: The flags in the accumulator after executing RIM indicate which
interrupts are currently active, enabling the program to make informed decisions
based on the interrupt status.
SIM (Set Interrupt Mask) Instruction
[Link] CS – SEMESTER III UNIT - IV
1. Purpose: The SIM instruction is used to configure the interrupt system by setting
or clearing the interrupt mask, thereby enabling or disabling specific interrupts for
the 8085 microprocessor.
2. Functionality: Upon execution, SIM allows the program to:
o Specify which maskable interrupts (RST 7.5, RST 6.5, and RST 5.5) are to
be enabled or disabled.
o Control the status of the interrupt system, influencing how the
microprocessor responds to incoming interrupt requests.
3. Mask Control: The bits in the data byte provided to SIM determine the state of each
interrupt line, allowing fine-grained control over the interrupt handling mechanism.
Difference between SIM and RIM Instructions
1. Functionality:
o RIM: Reads and reports the status of the interrupt system and identifies which
interrupts are active.
o SIM: Configures the interrupt system by enabling or disabling specific
interrupts based on program requirements.
2. Operation:
o RIM: Outputs the interrupt status to the accumulator, providing
feedback to the program.
o SIM: Takes input from the accumulator or a data byte to control the
interrupt mask, modifying the behavior of the interrupt system.
3. Usage Context:
o RIM: Typically used when the program needs to check which interrupts are
active before making decisions on handling them.
o SIM: Used when setting up or modifying the interrupt configuration to
control how the microprocessor interacts with peripheral devices.
Check your Progress
1. What does the SIM instruction in the 8085 microprocessor stand for?
a) Set Interrupt Mask
b) Serial Interrupt Mask
c) Signal Interrupt Mask
d) Select Interrupt Mode
3. Which interrupt lines are controlled by the SIM instruction in the 8085
microprocessor?
a) RST 5.5, RST 6.5, and RST 7.5
b) TRAP, INTR, and RST 7.5
c) RST 4.5, RST 5.5, and RST 6.5
d) RST 0, RST 1, and RST 2
4. Before executing the SIM instruction, what must be initialized in the 8085
microprocessor?
a) Interrupt Enable Flip-Flop
b) Accumulator with the required value
c) Stack Pointer
d) Program Counter
Intel 8259 is a Programmable Interrupt Controller (PIC). There are 5 hardware interrupts
and 2 hardware interrupts in Intel 8085 and Intel 8086 microprocessors respectively. But by
connecting Intel 8259 with these microprocessors, we can increase their interrupt handling
capability. Intel 8259 combines the multi-interrupt input sources into a single interrupt
output. Interfacing of single PIC provides 8 interrupts inputs from IR0-IR7. For example,
Interfacing of 8085 and 8259 increases the interrupt handling capability of 8085
microprocessor from 5 to 8 interrupt levels.
Features of Intel 8259 PIC are as follows:
Intel 8259 is designed for Intel 8085 and Intel 8086 microprocessor.
It can be programmed either in level triggered or in edge triggered interrupt level.
We can mask individual bits of interrupt request register.
We can increase interrupt handling capability upto 64 interrupt level by
cascading further 8259 PICs.
Clock cycle is not required.
[Link] Computer Science – SEMESTER III UNIT - V
Pin Diagram of 8259 – We can see through above diagram that there are total 28 pins in
Intel 8259 PIC where Vcc : 5V Power supply and Gnd : ground. Other pins use are explained
below. Block Diagram of 8259 PIC microprocessor –
The Block Diagram consists of 8 blocks which are – Data Bus Buffer, Read/Write Logic,
Cascade Buffer Comparator, Control Logic, Priority Resolver and 3 registers- ISR, IRR, IMR.
1. Data bus buffer – This Block is used as a mediator between 8259 and 8085/8086
microprocessor by acting as a buffer. It takes the control word from the 8085 (let
[Link] Computer Science – SEMESTER III UNIT - V
Advantages:
Interrupt Management: The 8259 PIC is designed to handle interrupts efficiently and
effectively, allowing for faster and more reliable processing of interrupts in a system.
Flexibility: The 8259 PIC is programmable, meaning that it can be customized to suit the
specific needs of a given system, including the number and type of interrupts that need to be
managed.
Compatibility: The 8259 PIC is compatible with a wide range of microprocessors, making it
a popular choice for managing interrupts in many different systems.
Multiple Interrupt Inputs: The 8259 PIC can manage up to 8 interrupt inputs,
allowing for the management of complex systems with multiple devices.
[Link] Computer Science – SEMESTER III UNIT - V
Ease of Use: The 8259 PIC includes simple interface pins and registers, making it relatively
easy to use and program.
Disadvantages:
Cost: While the 8259 PIC is relatively affordable, it does add cost to a system, particularly if
multiple PICs are required.
Limited Number of Interrupts: The 8259 PIC can manage up to 8 interrupt inputs, which
may be insufficient for some applications.
Complex Programming: Although the interface pins and registers of the 8259 PIC are
relatively simple, programming the 8259 can be complex, requiring careful attention to
interrupt prioritization and other parameters.
Limited Functionality: While the 8259 PIC is a useful peripheral for interrupt management,
it does not include more advanced features, such as DMA (direct memory access) or
advanced error correction.
Let us sum up
The 8259 Programmable Interrupt Controller (PIC) manages multiple interrupt
requests from up to eight devices (IRQ0 to IRQ7), allowing efficient handling of
interrupts in a microprocessor system.
It prioritizes interrupts so that urgent requests can preempt less critical ones.
The PIC is programmable, enabling users to configure which interrupts are enabled
and their priority levels.
It includes key components like IRQ lines for receiving requests, control logic for
managing priorities, and a data bus interface for communication with the CPU.
The 8259 also allows monitoring of pending interrupts, ensuring timely
responses to external device signals.
1. What is the primary function of the Intel 8259 PIC?
a) To provide direct memory access
b) To combine multiple interrupt sources into a single interrupt output
c) To manage data transmission between microprocessors
d) To handle memory management
Answer: c) 8
4. What is the function of the Interrupt Request Register (IRR) in the 8259 PIC?
a) To store the interrupt levels currently being serviced
b) To store the interrupt levels requesting service
c) To mask interrupt levels
d) To reset the microprocessor
5. What is the purpose of the Interrupt Mask Register (IMR) in the 8259 PIC?
a) To store interrupt levels that have to be masked
b) To store interrupt levels currently being executed
c) To prioritize interrupt levels
d) To reset all interrupt levels
DMA Controller is a hardware device that allows I/O devices to directly access memory with
less participation of the processor. DMA controller needs the same old circuits of an interface
to communicate with the CPU and Input/Output devices.
What is a DMA Controller?
Direct Memory Access uses hardware for accessing the memory, that hardware is called a
DMA Controller. It has the work of transferring the data between Input Output devices and
main memory with very less interaction with the processor. The direct Memory Access
Controller is a control unit, which has the work of transferring data.
DMA Controller Diagram in Computer Architecture
DMA Controller is a type of control unit that works as an interface for the data bus and the
I/O Devices. As mentioned, DMA Controller has the work of transferring the data without the
intervention of the processors, processors can control the data transfer. DMA Controller also
contains an address unit, which generates the address and selects an I/O device for the
transfer of data. Here we are showing the block diagram of the DMA Controller.
[Link] Computer Science – SEMESTER III UNIT - V
Explanation: The CPU initializes the DMA by sending the given information through the
data bus.
The starting address of the memory block where the data is available (to read) or
where data are to be stored (to write).
It also sends word count which is the number of words in the memory block to be
read or written.
Control to define the mode of transfer such as read or write.A control to begin the DMA
transfer
Modes of Data Transfer in DMA
There are 3 modes of data transfer in DMA that are described below.
Burst Mode: In Burst Mode, buses are handed over to the CPU by the DMA if
the whole data is completely transferred, not before that.
Cycle Stealing Mode: In Cycle Stealing Mode, buses are handed over to the CPU
by the DMA after the transfer of each byte. Continuous request for bus control is
generated by this Data Transfer Mode. It works more easily for higher-priority
tasks.
Transparent Mode: Transparent Mode in DMA does not require any bus in the
transfer of the data as it works when the CPU is executing the transaction.
8237 DMA Controller
8237 DMA Controller is a type of DMA Controller which has a flexible number of
channels but generally works on 4 Input-Output channels. In these present channels, the
channel has to be given the highest priority to be decided by the Priority Encoder. Each
channel in the 8237 DMA Controller has to be programmed separately.
8257 DMA Controller
8257 DMA Controller is a type of DMA Controller, that when a single Intel 8212 I/O
[Link] Computer Science – SEMESTER III UNIT - V
device is paired with it, becomes 4 channel DMA Controller. In 8257 DMA Controller, the
highest priority channel is acknowledged. It contains two 16-bit registers, one is DMA
Address Register and the other one is Terminal Count Register.
Advantages of DMA Controller
Data Memory Access speeds up memory operations and data transfer.
CPU is not involved while transferring data.
DMA requires very few clock cycles while transferring data.
DMA distributes workload very appropriately.
DMA helps the CPU in decreasing its load.
Disadvantages of DMA Controller
Direct Memory Access is a costly operation because of additional
operations.
DMA suffers from Cache-Coherence Problems.
DMA Controller increases the overall cost of the system.
DMA Controller increases the complexity of the software.
Let us sum up
Direct Memory Access (DMA)
1. Definition:
DMA is a method that allows certain hardware components to access system memory
independently of the CPU, enabling high-speed data transfer.
2. Functionality:
DMA transfers data between I/O devices and memory without CPU intervention,
freeing the CPU to perform other tasks.
8257 DMA Controller
1. Purpose:
The 8257 is a dedicated DMA controller that manages DMA operations, coordinating
data transfers between peripherals and memory.
2. Channels:
The 8257 can support up to four DMA channels, allowing multiple devices to
perform DMA transfers simultaneously.
Types of DMA Controllers
1. Single-Channel DMA:
A single DMA controller that handles one device at a time, leading to simpler designs
but limited efficiency.
2. Multi-Channel DMA:
Controllers like the 8257 that support multiple channels, enabling concurrent data
transfers and improving overall system performance.
Advantages of DMA Controller
1. Increased Throughput:
By allowing devices to transfer data without CPU intervention, DMA increases the
[Link] Computer Science – SEMESTER III UNIT - V
1. Complexity:
Implementing DMA adds complexity to the system design, requiring additional
hardware and control logic.
2. Potential for Conflicts:
Since DMA allows devices direct access to memory, it may lead to conflicts or data
corruption if not properly managed, especially in systems with multiple active devices.
1. What is the primary function of the Intel 8259 PIC?
a) To provide direct memory access
b) To combine multiple interrupt sources into a single interrupt output
c) To manage data transmission between microprocessors
d) To handle memory management
Answer: c) 8
4. What is the function of the Interrupt Request Register (IRR) in the 8259 PIC?
a) To store the interrupt levels currently being serviced
b) To store the interrupt levels requesting service
c) To mask interrupt levels
d) To reset the microprocessor
5. What is the purpose of the Interrupt Mask Register (IMR) in the 8259 PIC?
a) To store interrupt levels that have to be masked
b) To store interrupt levels currently being executed
c) To prioritize interrupt levels
d) To reset all interrupt levels
Answer: a) To store interrupt levels that have to be masked
UNIT V
Since memory and I/O has to be Since memory and I/O are present
connectedexternally, the circuit becomes large. internally, thecircuit is small.
Cannot be used in compact systems and Can be used in compact systems and hence
henceinefficient it isan efficient technique
Cost of the entire system increases Cost of the entire system is low
[Link] Computer Science – SEMESTER III UNIT - V
Due to external components, the entire power Since external components are low, total
consumption is high. Hence it is not suitable power consumption is less and can be
to used with devices running used with devices running on stored
on stored power like batteries. power like batteries.
Since memory and I/O components are all Since components are internal, most of the
external, each instruction will need external operations are internal instruction, hence
operation, hence it is relatively speed is fast.
slower.
Microprocessors are based on von Neumann Micro controllers are based on Harvard
model/architecture where program and data architecture where program memory and
are stored in same Data memory are separate
memory module
Microprocessor:
Requires external memory and I/O components. Based on the von Neumann
architecture, where program and data share the same memory space, resulting in
relatively slower performance.
Due to external memory and I/O components, it occupies more space and is less
efficient for compact systems.
Microcontroller:
Follows the Harvard architecture, where program and data memory are separate,
allowing faster execution.
Integrated components reduce cost and power consumption, and it often includes
power-saving modes (e.g., idle and sleep modes).
5. Which architecture stores program and data in the same memory module?
A) Harvard architecture
B) ARM architecture
C) von Neumann architecture
D) RISC architecture
Answer: C) von Neumann architecture
Interrupt control: It supports five interrupt sources, which can interrupt the normal
program execution to handle specific events.
Central Processing Unit (CPU): This is the brain of the microcontroller, which is
responsible for executing instructions and performing arithmetic and logical
operations.
Oscillator: It requires an external oscillator to provide a clock signal to the
microcontroller
Bus control: The 8051 microcontroller includes a bus controller that manages data
transfer between the CPU and peripheral devices, such as memory or input/output
devices.
4k byte ROM: The 8051-microcontroller architecture includes a 4 kilobyte (4k) read-
only memory (ROM) for storing the program instructions that are executed by the CPU.
128-byte RAM: The 8051 microcontrollers also has a 128-byte random-access
memory (RAM) for storing data that is used by the program instructions during
runtime.
Input/Output Ports: They have four 8-bit input/output (I/O) ports that can be
configured as either input or output.
Timers and Counters: They have two 16-bit timers/counters that can be used for a
variety of tasks such as measuring time intervals, generating PWM signals, and
counting external events.
Serial Communication Interface (SCI): It has a built-in serial port that can be used for
asynchronous serial communication.
In this section, the 8051-microcontroller architecture block diagram is depicted as:
[Link] Computer Science – SEMESTER III UNIT - V
5.2.2 Applications
The microcontroller 8051 applications include a large number of machines, principally
because it is simple to incorporate in a project or to assemble a machine around it. The
following are the key spots of the spotlight:
1. Energy Management: Competent measuring device systems aid in calculating energy
consumption in domestic and industrialized applications. These meter systems are
prepared competent by integrating microcontrollers.
2. Touch screens: A high degree of microcontroller suppliers integrate touch sensing
abilities in their designs. Transportable devices such as media players, gaming devices
& cell phones are some illustrations of micro-controller integrated with touch sensing
screens.
3. Automobiles: The microcontroller 8051 discovers broad recognition in supplying
automobile solutions. They are extensively utilized in hybrid motor vehicles to control
engine variations
4. Medical Devices: Handy medicinal gadgets such as glucose & blood pressure
monitors bring into play micro-controllers, to put on view the measurements, as a
results.
5.2.3 Advantages:
It is a cheaper option, which makes it a popular choice for low-cost applications.
Designed to consume very low power for applications.
8051 Microcontroller Architecture is known for its high reliability.
5.2.4 Disadvantages:
It has limited processing power compared to microcontrollers
Memory is limited for applications it requires a lot of data storage.
It highly requires advanced peripherals such as USB or Ethernet connectivity
Definition:
The 8051 microcontroller, designed by Intel in 1981, is an 8-bit microcontroller with
40 pins, 4KB ROM, 128 bytes of RAM, and two 16-bit timers.
It includes four 8-bit programmable I/O ports and a built-in 12 MHz crystal
oscillator
Applications:
The 8051 microcontroller is used in energy management systems to calculate
consumption, integrated into touch screens for devices like phones and gaming
consoles, controls hybrid vehicles in the automotive industry, and powers medical
devices like glucose and blood pressure monitors.
B) 4KB
C) 8KB
D) 128KB
Answer: B) 4KB
2. Which of the following is a key characteristic of a List ADT?
A) 16-bit timers
B) Serial Communication Interface
C) On-chip oscillator
D) 64KB RAM
Answer: D) 64KB RAM
3. What kind of architecture does the 8051 microcontroller follow?
A) Harvard
B) von Neumann
C) ARM
D) MIPS
Answer: A) Harvard
4. Where are 8051 microcontrollers commonly used?
A) Spacecraft
B) Automobiles
C) Nuclear Plants
D) Oil Refineries
Answer: B) Automobiles
5. Which is an advantage of the 8051 microcontroller?
A) High processing power
B) Low power consumption
C) Large memory space
D) USB connectivity
Answer: B) Low power consumption
Port 1
P1 is a true I/O port as it doesn’t have any alternative functions as in P0, but this port
can be configured as general I/O only. It has a built-in pull-up resistor and is completely
compatible with TTL circuits.
Port 2
P2 is similar to P0 when the external memory is used. Pins of this port occupy
addresses intended for the external memory chip. This port can be used for higher address
byte with addresses A8-A15. When no memory is added then this port can be used as a
general input/output port similar to Port 1.
Port 3
In this port, functions are similar to other ports except that the logic 1 must be applied
to appropriate bit of the P3 register.
Pins Current Limitations
When pins are configured as an output (i.e. logic 0), then the single port pins can
receive a current of 10mA.
When these pins are configured as inputs (i.e. logic 1), then built-in pull-up resistors
provide very weak current, but can activate up to 4 TTL inputs of LS series.
If all 8 bits of a port are active, then the total current must be limited to 15mA (port
P0: 26mA).
If all ports (32 bits) are active, then the total maximum current must be limited to
71mA.
Pins 1 to 8 − These pins are known as Port 1. This port doesn’t serve any other
functions. It is internally pulled up, bi-directional I/O port.
Pin 9 − It is a RESET pin, which is used to reset the microcontroller to its initial values.
Pins 10 to 17 − These pins are known as Port 3. This port serves some functions like
interrupts, timer input, control signals, serial communication signals RxD and TxD, etc.
[Link] Computer Science – SEMESTER III UNIT - V
Pins 18 & 19 − These pins are used for interfacing an external crystal to get the system
clock.
Pin 20 − This pin provides the power supply to the circuit.
Pins 21 to 28 − These pins are known as Port 2. It serves as I/O port. Higher order
address bus signals are also multiplexed using this port.
Pin 29 − This is PSEN pin which stands for Program Store Enable. It is used to read a
signal from the external program memory.
Pin 30 − This is EA pin which stands for External Access input. It is used to
enable/disable the external memory interfacing.
Pin 31 − This is ALE pin which stands for Address Latch Enable. It is used to
demultiplex the address-data signal of port.
Pins 32 to 39 − These pins are known as Port 0. It serves as I/O port. Lower order
address and data bus signals are multiplexed using this port.
Pin 40 − This pin is used to provide power supply to the circuit.
There are two 16-bit timers and counters in 8051 microcontroller: timer 0 and timer
1. Both timers consist of 16-bit register in which the lower byte is stored in TL and the
higher byte is stored in TH. Timer can be used as a counter as well as for timing operation
that depends on the source of clock pulses to counters.
Counters and Timers in 8051 microcontroller contain two special function registers: TMOD
(Timer Mode Register) and TCON (Timer Control Register), which are used for activating and
configuring timers and counters. There are four different modes of the Timer or Counter. The
Mode 0 to Mode 2 are for both of the Timer/Counter. Mode 3 has a different meaning for
each timer register. There is a register called TMOD. This register can be programmed to
configure these timers or counters. The Serial port is used for serial communication in mode 1
and 3. Timer1 is used for generating the baud rate. So only Timer0 is available for timer or
counter operations.
5.4.1 Operating Modes:
TMOD Register
TMOD (Timer Mode) is an SFR. The address of this register is 89H. This is not bit-
addressable.
[Link] Computer Science – SEMESTER III UNIT - V
Now, let us see the circuit that controls the running of the timers.
In the following table, we will see the bit details and their different operations for high or low
value.
Bit 00 01 10 11
Details
The Gate bit will be high when the timer or counter is in mode 0 to 2.
The Mode 0 operation is the 8-bit timer or counter with a 5-bit pre-scaler. So it is a
13-bit timer/counter. It uses 5 bits of TL0 or TL1 and all of the 8-bits of TH0 or TH1.
In this example the Timer1is selected, in this case, every 32 (25)event for counter
operations or 32 machine cycles for timer operation, the TH1 register will be incremented by
1. When the TH1overflows from FFH to 00H, then the TF1 of TCON register will be high,
and it stops the timer/counter. So for an example, we can say that if the TH1 is holding F0H,
and it is in timer mode, then TF1will be high after 10H * 32
= 512 machine cycles.
MOVTMOD, #00H MOVTH1,
#0F0H
MOVIE, #88H
SETB TR1
In the above program, the Timer1 is configured as timer mode 0. In this case Gate = 0.
Then the TH1 will be loaded with F0H, then enable the Timer1 interrupt. At last set the TR1
of TCON register, and start the timer.
Operating Mode 1 of Timer/Counter
The Mode 1 operation is the 16-bit timer or counter. In the following diagram, we are
[Link] Computer Science – SEMESTER III UNIT - V
In this case every event for counter operations or machine cycles for timer operation,
the TH0– TL0 register-pair will be incremented by 1. When the register pair overflows from
FFFFH to 0000H, then the TF0 of TCON register will be high, and it stops the timer/counter.
So for an example, we can say that if the TH0 – TL0 register pair is holding FFF0H, and it is
in timer mode, then TF0 will be high after 10H = 16 machine cycles. When the clock
frequency is 12MHz, then the following instructions generate an interrupt 16 µs after Timer0
starts running.
MOVTMOD, #01H
MOVTL0, #0F0H
MOVTH0, #0FFH
MOVIE, #82H
SETB TR0
In the above program, the Timer0 is configured as timer mode 1. In this case Gate = 0.
Then the TL0 will be loaded with F0H and TH0 is loaded with FFH, then enable the Timer0
interrupt. At last set the TR0 of TCON register, and start the timer.
Operating Mode 2 of Timer/Counter
The Mode 2 operation is the 8-bit auto reload timer or counter. In the following
diagram, we are using Mode 2 for Timer1.
In this case every event for counter operations or machine cycles for timer operation,
the TL1register will be incremented by 1. When the register pair overflows from FFH to 00H,
then the TF1 of TCON register will be high, also theTL1 will be reloaded with the content of
TH1 and starts the operation again. So for an example, we can say that if the TH1 and TL1
register both are holding F0H and it is in timer mode, then TF1 will be high after 10H= 16
machine cycles. When the clock frequency is 12MHz this happens after 16 µs, then the
following instructions generate an interrupt once every 16 µs after Timer1 starts running.
MOVTMOD, #20H
MOVTL1, #0F0H
MOVTH1, #0F0H
MOVIE, #88H
SETBTR1
In the above program, the Timer1 is configured as timer mode 2. In this case Gate = 0.
Then the TL1 and TH1 are loaded with F0H. then enable the Timer1 interrupt. At last set the
TR1 of TCON register, and start the timer. Timer1 in mode 2 generates the desired baud rate
when the serial port is working on Mode 1 or 3.
Mode 3 is different for Timer0 and Timer1. When the Timer0 is working in mode 3, the
TL0 will be used as an 8-bit timer/counter. It will be controlled by the standard Timer0
control bits, T0 and INT0 inputs. The TH0 is used as an 8-bit timer but not the counter. This
is controlled by Timer1 Control bit TR1. When the TH0 overflows from FFH to 00H, then
TF1 is set to 1. In the following diagram, we can Timer0 in Mode 3.
When the Timer1 is working in Mode 3, it simply holds the count but does not run.
[Link] Computer Science – SEMESTER III UNIT - V
When Timer0 is in mode 3, the Timer1 is configured in one of the mode 0, 1 and
2. In this case, the Timer1 cannot interrupt the microcontroller. When the TF1 is used by TH0
timer, the Timer1 is used as Baud Rate Generator. The meaning of gate bit in Timer0 and
Timer1 for mode 3 is as follows: It controls the running of 8-bit timer/counter TL0 as like
Mode 0, 1, or 2. The running of TH0 is controlled by TR1 bit only. So the gate bit in this
mode for Timer0 has no specific role. The mode 3 is present for applications requiring an
extra 8-bit timer/counter. In Mode 3 of Timer0, the 8051 has three timers. One 8-bit timer by
TH0, another 8-bit timer/counter by TL0, and one 16-bit timer/counter by Timer1.
Gate: If the gate bit is set to ‘0’, then we can start and stop the “software” timer in the same
way. If the gate is set to ‘1’, then we can perform hardware timer.
C/T: If the C/T bit is ‘1’, then it is acting as a counter mode, and similarly when set C+
=/T bit is ‘0’; it is acting as a timer mode.
Mode select bits: The M1 and M0 are mode select bits, which are used to select the timer
operations. There are four modes to operate the timers.
Mode 0: This is a 13-bit mode that means the timer operation completes with “8192” pulses.
Mode 1: This is a16-bit mode, which means the timer operation completes with
maximum clock pulses that “65535”.
Mode 2: This mode is an 8-bit auto reload mode, which means the timer operation completes
with only “256” clock pulses.
Mode 3: This mode is a split-timer mode, which means the loading values in T0 and
automatically starts the T1.
[Link] Computer Science – SEMESTER III UNIT - V
Sample Program:
Counters in 8051
Keep a counter by keeping C/T bit high, i.e., logic ‘1’ in the TMOD register. For better
understanding, we have given one program which uses timer 1 as a counter. Here the LEDs
are connected to 8051 Port 2, and the switch to the timer1 pin P3.5; and therefore, if the
switch is pressed, the value will be counted. Otherwise, an externally connected sensor to this
counter pin as input does this counting operation.
a) 1
b) 2
c) 3
d) 4
Answer: b) 2
a) TCON
b) TMOD
c) TH
d) TL
Answer: b) TMOD
a) 8-bit
b) 16-bit
c) 13-bit
d) 32-bit
Answer: b) 16-bit
a) Mode 0
b) Mode 1
c) Mode 2
[Link] Computer Science – SEMESTER III UNIT - V
d) Mode 3
Answer: d) Mode 3
a) Timer mode
c) Interrupt enable
5.5 INTERRUPTS
IMPORTANCE OF INTERRUPTS.
ISR will always ends with RETI instruction. The execution of RETI instruction
results in the following.
1. POP the current stack top to the PC.
External interrupts are those initiated by peripheral devices through the external pins of
the microcontroller. Internal interrupts are those activated by the internal peripherals of the
microcontroller like timers, serial controller etc.)
2. Maskable and non-maskable interrupts.
The category of interrupts which can be disabled by the processor using program is
called maskable interrupts. Non-maskable interrupts are those categories by which the
programmer cannot disable it using program.
3. Vectored and non-vectored interrupt.
Starting address of the ISR is called interrupt vector. In vectored interrupts the starting
address is predefined. In non-vectored interrupts, the starting address is provided by the
peripheral as follows.
Microcontroller receives an interrupt request from external device.
Controller sends an acknowledgement (INTA) after completing the execution of
current instruction.
The peripheral device sends the interrupt vector to the microcontroller.
5.5.1 Interrupts in 8051:
Interrupts are the events that temporarily suspend the main program, pass the control to
the external sources and execute their task. It then passes the control to the main program
where it had left off.8051 has 5 interrupt signals, i.e. INT0, TFO, INT1, TF1, RI/TI. Each
interrupt can be enabled or disabled by setting bits of the IE register and the whole interrupt
system can be disabled by clearing the EA bit of the same register.
IE (Interrupt Enable) Register
This register is responsible for enabling and disabling the interrupt. EA register is set to
one for enabling interrupts and set to 0 for disabling the interrupts. Its bit sequence and their
meanings are shown in the following figure.
The priority levels of the interrupts can be altered by changing the corresponding bit in
the Interrupt Priority (IP) register as shown in the following figure.
A low priority interrupt can only be interrupted by the high priority interrupt, but not
interrupted by another low priority interrupt.
If two interrupts of different priority levels are received simultaneously, the
request of higher priority level is served.
If the requests of the same priority levels are received simultaneously, then the internal
polling sequence determines which request is to be serviced.
The interruptions that the microcontroller interfaces with (external) devices are known
as external interrupts. They are received by the controller’s INTx pins. These may be
triggered by edges or levels. Interrupt is enabled for a low at the INTx pin when it is level
triggered, and for a high to low transition at the INTx pin when it is edge triggered. TCON is
another register used to control operations of counter and timers in microcontrollers. It is an
8-bit register wherein four upper bits are responsible for timers and counters and lower bits
are responsible for interrupts.
TF1: The TF1 stands for ‘timer1’ flag bit. Whenever calculating the time-delay in timer1, the
TH1 and TL1 reaches to the maximum value that is “FFFF” automatically.
EX: while (TF1==1)
Whenever the TF1=1, then clear the flag bit and stop the timer.
TR1: The TR1 stands for timer1 start or stop bit. This timer starting can be through software
instruction or through hardware method.
EX: gate=0 (start timer 1 through software instruction) TR1=1; (Start timer)
TF0: The TF0 stands for ‘timer0’ flag-bit. Whenever calculating the time delay in timer1, the
TH0 and TL0 reaches to a maximum value that is ‘FFFF’, automatically.
EX: while (TF0==1) Whenever the TF0=1, then clear the flag bit and stop the timer.
TR0: The TR0 stands for ‘timer0’ start or stop bit; this timer starting can be through software
instruction or through hardware method.
EX: gate=0 (start timer 1 through software instruction)
TR0=1; (Start timer)
5.5.3 Execution of Interrupts:
Types of 8051 Microcontroller Interrupts
8051 Microcontroller suffers five different types of interrupts that hampers the main
program execution. These five types of interrupts are:
Timer 0 overflow interrupt- TF0
Timer 1 overflow interrupt-TF1
External hardware interrupt- INT0
External hardware interrupt- INT1
Serial communication interrupt- RI/TI
[Link] Computer Science – SEMESTER III UNIT - V
Reset – 0000H
TCON manages external interrupts from the INTx pins and indicates edge or level
triggering.
The upper four bits control timers and counters; the lower bits manage
interrupts.
Interrupts in 8051
The 8051 has five interrupt signals: INT0, TF0, INT1, TF1, and RI/TI.
Interrupts can be controlled via the Interrupt Enable (IE) register.
The EA bit in the IE register can disable all interrupts when cleared.
The Interrupt Priority (IP) register manages interrupt priority levels
Answer: C) IE Register
3. What type of interrupt cannot be disabled by the programmer?
A) Maskable Interrupt
B) Non-maskable Interrupt
C) Vectored Interrupt
[Link] Computer Science – SEMESTER III UNIT - V
D) Internal Interrupt