Microprocessor Notes
Microprocessor Notes
Unit – I INTRODUCTION
Digital Computers - Microcomputer Organization- Computer languages –Microprocessor
Architecture and its operations – Microprocessor initiated operations and 8085 Bus organization
– Internal Data operations and 8085 registers - Peripheral or External initiated operations.
Text Book(s)
1. R. S. Gaonkar- "Microprocessor Architecture- Programming and Applications with 8085"- 5th
Edition- Penram International Publications, 2009. [For unit I to unit IV]
2. Soumitra Kumar Mandal -“Microprocessors and Microcontrollers – Architectures,
Programming and Interfacing using 8085, 8086, 8051”, Tata McGraw Hill Education Private
Limited. [For unit V].
Reference Books:
1. Mathur- “Introduction to Microprocessor”- 3rd Edition- Tata McGraw-Hill -1993.
2. Raj Kamal - “Microcontrollers: Architecture, Programming, Interfacing and System Design”,
Pearson Education, 2005.
3.Krishna Kant, “Microprocessors and Microcontrollers – Architectures, Programming and
System Design 8085, 8086, 8051, 8096”, PHI, 2008
UNIT-1
INTRODUCTION
Digital Computers
Digital computers are devices that process data using digital technology, where data is
represented in discrete, binary form (0s and 1s).
These machines are ubiquitous in modern society and are used for a wide range of tasks,
from simple calculations to complex simulations and data analysis.
1. Central Processing Unit (CPU): The brain of the computer, responsible for executing
instructions, performing calculations, and managing data movement.
2. Memory: Storage for data and instructions that the CPU can access quickly. This includes
both random access memory (RAM) for temporary storage and long-term storage devices like
hard disk drives (HDDs) or solid-state drives (SSDs).
3. Input Devices: These allow users to interact with the computer by providing data and
instructions. Common input devices include keyboards, mice, touchscreens, and microphones.
4. Output Devices: These display or otherwise present the results of computations to the user.
Examples include monitors, printers, speakers, and actuators.
5. Motherboard: The main circuit board of the computer, which holds the CPU, memory, and
other essential components and provides the connections between them.
6. Operating System: Software that manages the computer's resources and provides a user
interface for interacting with the hardware and running applications.
Digital computers operate using a binary system, where information is represented using
combinations of 0s and 1s.
This binary representation allows for efficient manipulation and processing of data
through logical operations such as AND, OR, and NOT.
The development of digital computers has revolutionized fields such as science,
engineering, medicine, business, and entertainment, enabling tasks that were previously
impractical or impossible.
Today's digital computers range from small, handheld devices like smartphones to
powerful supercomputers capable of processing massive amounts of data at incredible
speeds.
Microcomputer Organization
1. Microprocessor:
At the heart of a microcomputer is the microprocessor, which executes instructions
and performs calculations.
Early microprocessors, such as the Intel 4004 and 8008, were simple and had limited
capabilities compared to modern CPUs like those found in PCs and smartphones.
2. Memory:
Microcomputers typically have different types of memory, including random access
memory (RAM) for temporary data storage and read-only memory (ROM) for storing
firmware and boot instructions.
RAM is used to hold data and program instructions that the CPU needs to access
quickly during operation.
3. Input/Output (I/O) Interfaces:
Microcomputers connect to external devices such as keyboards, mice, displays,
storage devices, and network interfaces through various I/O ports and controllers.
These interfaces allow users to interact with the computer and transfer data to and
from external devices.
4. Bus Architecture:
The bus architecture of a microcomputer determines how different components
communicate with each other.
It consists of data buses, address buses, and control signals that facilitate the transfer
of data and instructions between the CPU, memory, and I/O devices.
5. Peripheral Devices:
Microcomputers can be expanded with additional peripheral devices to enhance their
functionality.
Common peripherals include printers, scanners, disk drives, and expansion cards for
adding features like graphics, sound, and networking.
6. System Software:
Microcomputers typically run an operating system (OS) that manages the hardware
resources and provides a user interface for running applications.
Popular operating systems for microcomputers include Microsoft Windows, macOS,
and various distributions of Linux.
7. Assembly Language and High-Level Languages:
Software for microcomputers is typically developed using programming languages
such as assembly language or high-level languages like C, C++, or Python.
Assembly language provides low-level access to the microcomputer's hardware,
while high-level languages offer greater abstraction and ease of programming.
Microcomputer organization has evolved significantly since the introduction of the first
microprocessors in the 1970s.
Today's microcomputers are powerful, versatile, and widely used in various applications
ranging from personal computing and gaming to embedded systems and IoT devices.
Computer languages
Programming Language Generations
A computer is a digital machine. It can only understand electric signals either ON or OFF
or 1 or 0.
But how do we communicate with this digital machine? Just like there are multiple
languages we communicate with each other (e.g., English, Hindi, Tamil, Gujarati, etc.).
But computers cannot understand our languages. We can interact with the computer
through multiple languages like machine language, assembly language, C, C++, Java, etc.
Basic Terms:
Computer language: A computer language is a way to give instructions to a computer to
perform desired tasks.
Program: A set of instruction written in a specific sequence for the computer to accomplish a
given task.
Machine language: The binary medium of communication with a computer through a designed
set of instruction specific to each computer.
Mnemonic: A combination of letter to suggest the operation of an instruction. E.g, ADD, HALT
etc.
Low-Level Languages:
These languages give instructions to a computer in a way that is easily understood by the
hardware of the computer.
These languages are easier for a computer to understand but difficult for a human
understanding.
This language is machine-dependent or specific to a given computer.
Two low-level languages are Machine Language and Assembly Language.
High-Level Languages:
Firstly, computers were given instructions in the forms of 1’s and 0’s.
This language is called Machine Language or first-generation language.
A computer was able to understand it directly without any conversion.
This language is also known as Machine Language or Binary language.
Binary language because only two symbols 1 and 0.
Machine Language was just 1’s and 0’s, in which error finding and correcting were very
difficult.
So we have to develop a second-generation language. Also called an Assembly
Language.
In this language, instructions were replaced with some coded terms called mnemonic.
So that it becomes a little easier to read, understand, and correct.
A computer can understand and work on machine code only.
So assembly language needed a special software called Assembler that converts
mnemonic into machine language.
Intel 8085
Intel 8085 is used in mobile phones, microwave ovens, washing machines etc.
The Arithmetic and Logic Unit, ALU performs the arithmetic and logical operations:
Addition
Subtraction
Logical AND
Logical OR
Logical EXCLUSIVE OR
Complement (Logical NOT)
Increment (add 1)
Decrement (subtract 1)
Left shift, Rotate left, Rotate right
Clear, etc.
Registers
Registers are used for temporary storage and manipulation of data and instructions by the
microprocessor.
Data remain in the registers till they are sent to the I/O devices or memory. Intel 8085
microprocessor has the following registers:
In addition to the above mentioned registers the 8085 microprocessor contains a set of
five flip-flops which serve as flags (or status flags).
A flag is a flip-flop which indicates some conditions which arises after the execution of
an arithmetic or logical instruction.
Accumulator (ACC):
The accumulator is an 8-bit register associated with the ALU.
The register 'A' is an accumulator in the 8085.
It is used to hold one of the operands of an arithmetic and logical operation.
The final result of an arithmetic or logical operation is also placed in the accumulator.
a. General-Purpose Registers:
d. Instruction Register:
The instruction register holds the opcode (operation code or instruction code) of
the instruction which is being decoded and executed.
e. Temporary Register:
It is an 8-bit register associated with the ALU. It holds data during an
arithmetic/logical operation. It is used by the microprocessor. It is not accessible
to programmer.
f. Flags:
The Intel 8085 microprocessor contains five flip-flops to serve as a status flags.
The flip-flops are reset or set according to the conditions which arise during an
arithmetic or logical operation.
If a flip-flop for a particular flag is set, then it indicates 1. When it is reset, it indicates 0.
These are operations that are initiated by the microprocessor itself to interact with
external devices. The different types are
MPU (micro processing unit) identifies peripheral device. It places a 16 bit address on
the address bus.
External logical circuit decodes the address and identifies the memory location.
MPU sends a memory read synchronization signal.
The memory chip activates.
The contents of the memory chip are placed on the 8 bit data bus.
Initiated Operations:
5. Stack Operations:
The microprocessor supports stack operations for subroutine calls and return addresses
storage.
Example instructions: PUSH (push data onto stack), POP (pop data from stack).
6. Interrupt Handling:
The 8085 handles interrupts, both maskable and non-maskable, to respond to external
events promptly.
Example instructions: RST (restart), DI (disable interrupts), EI (enable interrupts).
3. Control Bus:
The control bus carries control signals to coordinate the activities of the microprocessor,
memory, and I/O devices. Control signals include read/write signals, memory enable, I/O
enable, interrupt request, and clock signals.
Internal operations:
These are operations that happen within the microprocessor, such as
Storing data in register.
Performing various arithmetic and logical operations.
Doing test conditions.
Sequence the execution of instructions.
Storing data temporarily in stacks.
MVI A,50H
MVI B,20H
ADD B
HLT
2000 3E MVI A
2001 50 50H
2002 06 MVI B
2003 20 20H
2004 80 ADD B
2005 76 HLT
Memory locations are incremented by byte value and not bit. Each instruction is stored in
the form of hexadecimal codes in the memory. Every instruction has a specific
hexadecimal code. MVI A has a hexadecimal code 3E .
Steps:
When the program starts, the microprocessor places the address of the first operation on
the address bus.
It then increments the address on the program counter by 1 (the address of the next
instruction).
A memory read control signal is sent which activates the external memory chip. The data
in the address is then placed on the bidirectional data bus and sent to the microprocessor.
The instruction is stored in the instruction register.
The instruction decoder decodes the instruction.
Steps 1-3 repeat again to fetch 50 H stored in the memory. It is then stored in the B register. The
same steps repeat for MVI A,20H. Once the ADD B instruction is fetched, stored in instruction
register and decoded, the data in the B register is fetched and stored in the temporary register.
The contents of the Accumulator and the temporary register are given as inputs to the ALU. The
results of the ALU is stored in the accumulator. If the results of the carry operation result in a
carry, the carry flag (it is a flip flop) becomes 1.
Temporary Registers
(a)Temporary Data Register - The ALU has two inputs. One input is supplied by the
accumulator and other from the temporary data register. The programmer cannot access this
temporary data register. However, it is internally used for execution of most of the arithmetic
and logical instructions.
(b) W and Z registers - Wand Z registers are temporary registers. These registers are used to
hold 8-bit data during the execution of some instructions. These registers are not available for the
programmer since 8085Microprocessor Architecture uses them internally.
(b)Flag Register - It is a 3-bit register, in which five of the bits carry significant information in
the form of flags: S (Sign flag), Z (Zero flag), AC(Auxiliary carry flag), P (Parity flag), and CY
(carry flag); as shown in Fig. 1.2.
S-Sign flag - After the execution of arithmetic or logical operations, if bit D7 of the result is
1, the sign flag is set. In a given byte if D7 is1, the number will be viewed as a negative
number. If D7 is U, the number will be considered as a positive number.
Z-Zero flag -The zero flag sets if the result of the operation in ALU is zero and flag resets if
the result is non zero. The zero flags are also set if a certain register content becomes zero
following an increment or decrement operation of that register.
AC-auxiliary Carry flag - This flag is set if there is an overflow out of bit 3 i.e. carry from
lower nibble to higher nibble (D3 bit to D4 bit). This flag is used for BCD operations and it is
not available for the programmer.
P-Parity flag - Parity is defined by the number of ones present in the accumulator. After
arithmetic or logical operation, if the result has an even number of ones, i.e.even parity, the
flag is set. If the parity is odd, the flag is reset.
CY-Carry flag - This flag is set if there is an overflow out of bit 7. The carry flag also serves
as a borrow flag for subtraction. In both the examples shown below, the carry flag is set.
Addition
9BH -----> 1001 1011
+75 H -----> + 0111 0101
--------- -----------
Carry 1 10 H -----> 1 0001 0000
Subtraction
89H -----> 1000 1001
-AB H -----> - 1010 1011
--------- -----------
Borrow1 10 H -----> 1 1101 1110
c) Instruction Register - In a typical processor operation, the processor first fetches the
opcode of instruction from memory (i.e. it places an address on the address bus and memory
responds by placing the data stored at the specified address on the data bus). The CPU stores this
opcode in a register called the instruction register. This opcode is further sent to the instruction
decoder to select one of the 256 alternatives.
The stack is a reserved area of the memory in the RAM where temporary information may be
stored.
A 16-bit stack pointer is used to hold the address of the most recent stack entry.
In the following figure depicts the architecture of 8085 microprocessor and with its register
organization –
These are operations that are initiated by the peripheral devices connected to the microprocessor:
1. Reset – When this pin is activated, all the internal operations are suspended, the address of
the program counter is reset to 0000H. The program execution starts at 0000H.
2. Interrupt – The activation of this pin temporarily suspends the internal operations to execute
other operations called a service routine (emergency procedures). After performing the
service routine, normal internal operations resume.
3. Ready – The activation of this pin tells the microprocessor that the peripheral device is ready
for the next action. If the ready pin is not activated, the microprocessor is in a wait stage. It is
waiting for the peripheral device to complete its operation so they can continue to the next
operation.
4. Hold – When the hold pin is activates, the microprocessor gives up control of the its buses
and lets the peripheral device use them. The microprocessor becomes the slave while the
peripheral device that sent that signal becomes the master.
2. Reset in – Used to reset the microprocessor. This involves suspending all the internal
operations and setting the address in the program counter to 0000H.
3. Reset out – All the connected devices are also reset when the microprocessor is reset.
4. TRAP, RST 7.5, RST 6.5, RST 5.5, and INTR are interrupt signals.
UNIT-II
8085 MICROPROCESSOR
8085 Microprocessor
The 8085 microprocessor is an 8-bit microprocessor introduced by Intel in 1976.
It's part of the Intel 8080 family and is backward compatible with the 8080.
Here are some key features and aspects:
1. Architecture:
It uses a Von Neumann architecture, meaning that both data and instructions are
stored in the same memory.
It has an 8-bit data bus and a 16-bit address bus.
2. Registers:
The 8085 has six general-purpose registers, labeled B, C, D, E, H, and L.
These can be combined as register pairs to perform 16-bit operations.
It also has a 16-bit stack pointer and a 16-bit program counter.
3. Instruction Set:
The instruction set of the 8085 consists of around 74 instructions.
These instructions are classified into various groups like data transfer, arithmetic,
logic, branching, etc.
4. Clock Speed:
The 8085 typically operates at a clock speed of 3 MHz.
5. Memory:
It can address up to 64 KB of memory directly.
6. Interrupts:
The 8085 supports five interrupts: TRAP, RST 7.5, RST 6.5, RST 5.5, and INTR.
These interrupts allow external devices to request the attention of the
microprocessor.
7. Instruction Execution:
It executes instructions in a serial manner, meaning it executes one instruction at
a time.
The 8085 was widely used in various applications, including industrial control systems,
instrumentation, and early personal computers. Despite its age, it still has relevance in
certain embedded systems and educational environments.
0 1 1 Opcode fetch
0 1 0 Memory read
0 0 1 Memory write
IO/M’ S1 S0 Data Bus Status
1 1 0 I/O read
1 0 1 I/O write
1 1 1 Interrupt acknowledge
0 0 0 Halt
RD’ – It is a signal to control READ operation. When it is low the selected memory or
input-output device is read.
WR’ – It is a signal to control WRITE operation. When it goes low the data on the data bus
is written into the selected memory or I/O location.
READY – It senses whether a peripheral is ready to transfer data or not. If READY is
high(1) the peripheral is ready. If it is low(0) the microprocessor waits till it goes high. It is
useful for interfacing low speed devices.
3. Power Supply and Clock Frequency:
Vcc – +5v power supply
Vss – Ground Reference
XI, X2 – A crystal is connected at these two pins. The frequency is internally divided by
two, therefore, to operate a system at 3MHZ the crystal should have frequency of 6MHZ.
CLK (OUT) – This signal can be used as the system clock for other devices.
4. Interrupts and Peripheral Initiated Signals:
The 8085 has five interrupt signals that can be used to interrupt a program execution.
(i) INTR
(ii) RST 7.5
(iii) RST 6.5
(iv) RST 5.5
(v) TRAP
The microprocessor acknowledges Interrupt Request by INTA’ signal. In addition to
Interrupts, there are three externally initiated signals namely RESET, HOLD and READY.
To respond to HOLD request, it has one signal called HLDA.
INTR – It is an interrupt request signal.
INTA’ – It is an interrupt acknowledgement sent by the microprocessor after INTR is
received.
5. Reset Signals:
RESET IN’ – When the signal on this pin is low(0), the program-counter is set to zero,
the buses are tristated and the microprocessor unit is reset.
RESET OUT – This signal indicates that the MPU is being reset. The signal can be used
to reset other devices.
6. DMA Signals:
HOLD – It indicates that another device is requesting the use of the address and data bus.
Having received HOLD request the microprocessor relinquishes the use of the buses as
soon as the current machine cycle is completed. Internal processing may continue. After the
removal of the HOLD signal the processor regains the bus.
HLDA – It is a signal which indicates that the hold request has been received after the
removal of a HOLD request, the HLDA goes low.
7. Serial I/O Ports: Serial transmission in 8085 is implemented by the two signals,
SID and SOD – SID is a data line for serial input where as SOD is a data line for serial
output.
Functional Block Diagram
Functional Block Diagram of 8085 Microprocessor
1. ALU
The ALU performs the actual numerical and logic operation such as ‘add’, ‘subtract’,
‘AND’, ‘OR’ etc.
Uses data from memory and from Accumulator to perform arithmetic operation and
always stores result of operation in Accumulator.
The ALU consists of accumulator, flag register and temporary register.
a. Accumulator
The accumulator is an 8-bit register that is a part of arithmetic/logic unit (ALU). This
register is used to store 8-bit data and to perform arithmetic and logical operations.
The result of an operation is stored in the accumulator.
The accumulator is also identified as register A.
b. Flag register
8085 has 8-bit flag register. There are only 5 active flags.
S Z AC P CY
i. Sign flag(S):
Sign flag indicates whether the result of a mathematical or logical operation is negative or
positive.
If the result is negative, this flag will be set (i.e. S=1) and if the result is positive, the flag
will be reset (i.e. S=0).
This flag indicates whether the current result is of even parity (no. of 1’s is even) or
odd parity (no. of 1’s is odd).
If even parity, P flag will be set otherwise reset.
b. Address bus
It carries ‘address’ of operand in binary form.
Typical size is 16-bit.
c. Control Bus
Control Bus are various lines which have specific functions for coordinating and
controlling MP operations
E.g.: Read/Write control line.
6. Interrupt Control
Interrupt is a signal, which suspends the routine what the MP is doing, brings the
control to perform the subroutine, completes it and returns to main routine.
May be hardware or software interrupts. Some interrupts may be ignored (maskable),
some cannot (non-maskable).
E.g. INTR, TRAP, RST 7.5, RST 6.5, RST 5.5
Immediate Addressing:
Data is provided in the instruction.
Load the immediate data to the destination provided.
Example: MVI A, 12 H
Register Addressing:
Data is provided through the registers.
Example: MOV B, C
Direct Addressing:
Used to accept data from outside devices to store in the accumulator or send the data
stored in the accumulator to the outside device.
Example: MOV A, [1000]
Indirect Addressing:
The processor calculates the effective address, and the contents of the address is used
to form a second address. The second address is where the data is stored.
Example: MOV A, [[1000]]
Implicit addressing:
In this addressing mode, the data itself specifies the data to be operated upon.
Example: CMA; Complement the contents of the accumulator.
8085 Microprocessor Instruction Set
An instruction is a binary pattern designed inside a microprocessor to perform a specific
function. Each instruction is represented by an 8-bit binary value. The instruction set can
be categorized into 5 types:
2.Arithmetic Instructions:
These instructions are used to perform arithmetic operations such as addition,
subtraction, increment or decrement of the content of a register or memory.
Examples: ADD, ADC, ADI, DAD, SUB, INR, DCR, etc.
3.Logical Instructions:
These instructions perform logical operations such as AND, OR, compare, rotate etc.
Examples: ANA, ANI, ORA, ORI, XRA, CMA, CMC, STC, CMP, RLC, RAL,
RAR, etc.
4.Branching Instructions:
These instructions are used to perform a conditional and unconditional jump, subroutine
call and return, and restart.
Examples: JZ, JNZ, JC, JNC, JP, JM, JPE, JPO, CALL, RET, RST, etc.
2 Arithmetic Group
The arithmetic instructions add, subtract, increment, or decrement data in registers or memory.
ADD Add to Accumulator
ADI Add Immediate Data to Accumulator
ADC Add to Accumulator Using Carry Flag
ACI Add immediate data to Accumulator Using Carry
SUB Subtract from Accumulator
SUI Subtract Immediate Data from Accumulator
SBB Subtract from Accumulator Using Borrow (Carry) Flag
SBI Subtract Immediate from Accumulator Using Borrow (Carry) Flag
INR Increment Specified Byte by One
DCR Decrement Specified Byte by One
INX Increment Register Pair by One
DCX Decrement Register Pair by One
DAD Double Register Add; Add Content of Register
Pair to H & L Register Pair
3 Logical Group
This group performs logical (Boolean) operations on data in registers and memory and on
condition flags. The logical AND, OR, and Exclusive OR instructions enable you to set
specific bits in the accumulator ON or OFF.
ANA Logical AND with Accumulator
ANI Logical AND with Accumulator Using Immediate Data
ORA Logical OR with Accumulator
OR Logical OR with Accumulator Using Immediate Data
XRA Exclusive Logical OR with Accumulator
XRI Exclusive OR Using Immediate Data
The Compare instructions compare the content of an 8-bit value with the contents of the
accumulator;
CMP Compare
CPI Compare Using Immediate Data
The rotate instructions shift the contents of the accumulator one bit position to the left or right:
RLC Rotate Accumulator Left
RRC Rotate Accumulator Right
RAL Rotate Left Through Carry
RAR Rotate Right Through Carry
Complement and carry flag instructions:
CMA Complement Accumulator
CMC Complement Carry Flag
STC Set Carry Flag
4 Branch Group
The branching instructions alter normal sequential program flow, either unconditionally
or conditionally. The unconditional branching instructions are as follows:
JMP Jump
CALL Call
RET Return
Conditional branching instructions examine the status of one of four condition flags to
determine whether the specified branch is to be executed. The conditions that may be
specified are as follows:
NZ Not Zero (Z = 0)
Z Zero (Z = 1)
NC No Carry (C = 0)
C Carry (C = 1)
PO Parity Odd (P = 0)
PE Parity Even (P = 1)
P Plus (S = 0)
M Minus (S = 1)
Thus, the conditional branching instructions are specified as follows
Jumps Calls Returns
INC CNC RNC (No Carry)
JNZ CNZ RNZ (Not Zero)
JM CM RM (Minus)
JP0 CPO RPO (Parity Odd)
JM CM RM (Minus)
JPE CPE RPE (Parity Even)
JP0 CPO RPO (Parity Odd)
Two other instructions can affect a branch by replacing the contents or the program
counter:
PCHL Move H & L to Program Counter
RST Special Restart Instruction Used with Interrupts
5 Stack Instructions
The following instructions affect the Stack and/or Stack Pointer
PUSH Push Two bytes of Data onto the Stack
POP Pop Two Bytes of Data off the Stack
XTHL Exchange Top of Stack with H & L
SPHL Move content of H & L to Stack Pointer
6 I/0 instructions
IN Initiate Input Operation
OUT Initiate Output Operation
3. Concatenate the decimal digits: After converting each group to decimal, concatenate them
together to form the BCD representation of the original binary number.
Example:
Let's say we have the binary number 1101101.
1. Split the binary number into groups of 4 bits: 0110 1101.
2. Convert each group to decimal:
- 0110 in decimal is 6.
- 1101 in decimal is 13.
3. Concatenate the decimal digits: 6 13 in binary is equivalent to 0110 1101 in BCD.
These are the basic steps for performing BCD to binary and binary to BCD conversions. You can
use these steps in programming or digital logic circuits to perform the conversions as needed.
There are many methods or techniques which can be used to convert code from one format to
another. We'll demonstrate here the following
Calculating BCD Equivalent. Convert each digit into groups of four binary digits
equivalent.
Result
(11101)2 = (00101001)BCD
Steps
Calculating Decimal Equivalent. Convert each four digit into a group and get decimal equivalent
for each group.
Result
(00101001)BCD = (11101)2
Converting between ASCII (American Standard Code for Information Interchange) and Binary-
Coded Decimal (BCD) involves encoding characters from the ASCII table into their respective
BCD representations, and vice versa. Here are some examples:
ASCII to BCD Conversion:
1. Convert ASCII character to its ASCII code: Look up the ASCII code for each character in the
ASCII table.
2. Convert ASCII code to binary: Convert the ASCII code to binary representation.
3. Group binary digits into sets of four: For each ASCII code, group the binary digits into sets of
four.
4. Convert each group to BCD: Convert each 4-bit group to its BCD representation.
5. Concatenate BCD representations: Concatenate the BCD representations of each ASCII code
together.
Example:
Let's convert the ASCII string "HELLO" to BCD.
1. ASCII codes for "HELLO":
- H: 72
- E: 69
- L: 76
- L: 76
- O: 79
2. Convert ASCII codes to binary:
- H: 01001000
- E: 01000101
- L: 01001100
- L: 01001100
- O: 01001111
3. Group binary digits into sets of four:
- H: 0100 1000
- E: 0100 0101
- L: 0100 1100
- L: 0100 1100
- O: 0100 1111
4. Convert each group to BCD:
- H: 0100 1000 -> 0100 (4) 1000 (8)
- E: 0100 0101 -> 0100 (4) 0101 (5)
- L: 0100 1100 -> 0100 (4) 1100 (12)
- L: 0100 1100 -> 0100 (4) 1100 (12)
- O: 0100 1111 -> 0100 (4) 1111 (15)
5. Concatenate BCD representations: 0100 1000 0100 0101 0100 1100 0100 1100 0100 1111
BCD to ASCII Conversion:
1. Split the BCD representation into pairs of digits: For each pair of BCD digits, separate them.
2. Convert each pair to binary: Convert each pair of BCD digits to binary.
3. Convert binary to ASCII: Convert the binary representation to its corresponding ASCII
character using the ASCII table.
Example:
Let's convert the BCD representation 0100 1000 0100 0101 0100 1100 0100 1100 0100 1111 to
ASCII.
1. Split BCD representation into pairs:
0100 1000
0100 0101
0100 1100
0100 1100
0100 1111
2. Convert each pair to binary:
0100 1000 -> 01001000 -> 72 (ASCII code for 'H')
0100 0101 -> 01000101 -> 69 (ASCII code for 'E')
0100 1100 -> 01001100 -> 76 (ASCII code for 'L')
0100 1100 -> 01001100 -> 76 (ASCII code for 'L')
0100 1111 -> 01001111 -> 79 (ASCII code for 'O')
3. Convert binary to ASCII: "HELLO"
These examples demonstrate how to perform ASCII to BCD and BCD to ASCII conversions.
You can follow similar steps to perform conversions for other characters or strings.
Converting between binary and ASCII involves encoding characters from the ASCII table into
their respective binary representations, and vice versa. Here are the steps for binary to ASCII and
ASCII to binary conversions:
Binary to ASCII Conversion:
1. Split the binary representation into groups of 8 bits: For each ASCII character, split the binary
representation into groups of 8 bits.
2. Convert each group to decimal: Convert each group of 8 bits (byte) to its decimal equivalent.
3. Find the corresponding ASCII character: Look up the decimal value in the ASCII table to find
the corresponding ASCII character.
4. Concatenate ASCII characters: Concatenate the ASCII characters together to form the ASCII
string.
Example:
Let's convert the binary string "01001000 01000101 01001100 01001100 01001111" to ASCII.
1. Split binary representation into groups of 8 bits:
- 01001000 (72 in decimal, corresponds to 'H' in ASCII)
- 01000101 (69 in decimal, corresponds to 'E' in ASCII)
- 01001100 (76 in decimal, corresponds to 'L' in ASCII)
- 01001100 (76 in decimal, corresponds to 'L' in ASCII)
- 01001111 (79 in decimal, corresponds to 'O' in ASCII)
2. Concatenate ASCII characters: "HELLO"
ASCII to Binary Conversion:
1. Convert each ASCII character to its ASCII code: Look up the ASCII code for each character
in the ASCII table.
2. Convert ASCII code to binary: Convert each ASCII code to its binary representation.
3. Pad binary representation if necessary: Ensure that each binary representation is 8 bits long by
adding leading zeros if needed.
4. Concatenate binary representations: Concatenate the binary representations together to form
the binary string.
Example:
Let's convert the ASCII string "HELLO" to binary.
1. ASCII codes for "HELLO":
- H: 72
- E: 69
- L: 76
- L: 76
- O: 79
2. Convert ASCII codes to binary:
- H: 01001000
- E: 01000101
- L: 01001100
- L: 01001100
- O: 01001111
3. Concatenate binary representations: "01001000 01000101 01001100 01001100 01001111"
These examples demonstrate how to perform binary to ASCII and ASCII to binary conversions.
You can follow similar steps to perform conversions for other characters or strings.
Binary Arithmetic
Binary arithmetic is essential part of all the digital computers and many other digital system.
Binary Addition
It is a key for binary subtraction, multiplication, division. There are four rules of binary addition.
In fourth case, a binary addition is creating a sum of (1 + 1 = 10) i.e. 0 is written in the given
column and a carry of 1 over to the next column.
Example − Addition
Binary Subtraction
Subtraction and Borrow, these two words will be used very frequently for the binary
subtraction. There are four rules of binary subtraction.
Example − Subtraction
Binary Multiplication
Binary multiplication is similar to decimal multiplication. It is simpler than decimal
multiplication because only 0s and 1s are involved. There are four rules of binary multiplication.
Example − Multiplication
Binary Division
Binary division is similar to decimal division. It is called as the long division procedure.
Example − Division
Multibyte addition and subtraction using Binary Coded Decimal (BCD)
arithmetic
Addition Example:
Let's add two multibyte BCD numbers:
1234
+ 5678
______
6912
Here's how it works:
1. Start from the rightmost digits and add them together: 4 + 8 = 12 (BCD: 0010).
2. Carry over the tens place (1) to the next column.
3. Add the next pair of digits along with the carry: 3 + 7 + 1 = 11 (BCD: 0001).
4. Carry over the tens place (1) again.
5. Add the next pair of digits along with the carry: 2 + 6 + 1 = 9 (BCD: 1001).
6. No carry this time.
7. Finally, add the leftmost digits: 1 + 5 = 6.
So, the result is 6912 in BCD format.
Subtraction Example:
Let's subtract a multibyte BCD number from another:
9876
- 5432
______
4444
Sure, let's delve into examples of multibyte multiplication and division using Binary Coded
Decimal (BCD) arithmetic:
Multiplication Example:
Let's multiply two multibyte BCD numbers:
123
× 456
_________
To multiply these numbers:
1. Start with the rightmost digit of the bottom number (6) and multiply it by each digit of the top
number in turn, moving left:
- \( 6 \times 3 = 18 \) (BCD: 0001 1000)
- \( 6 \times 2 = 12 \) (BCD: 0001 0010)
- \( 6 \times 1 = 6 \) (BCD: 0110)
2. Then, move to the next digit of the bottom number (5) and repeat the process, but shifted one
place to the left:
- \( 5 \times 3 = 15 \) (BCD: 0001 0101)
- \( 5 \times 2 = 10 \) (BCD: 0001 0000)
- \( 5 \times 1 = 5 \) (BCD: 0101)
3. Lastly, move o the leftmost digit of the bottom number (4) and repeat the process, but shifted
two places to the left:
- \( 4 \times 3 = 12 \) (BCD: 0001 0010)
- \( 4 \times 2 = 8 \) (BCD: 1000)
- \( 4 \times 1 = 4 \) (BCD: 0100)
4. Finally, add all the partial products together:
1 1 7 7 3 1 8
× 1 2 3
_______________
4 6 3 8 3 1 8
231456
37418
_______________
5615738
So, the result of the multiplication is \( 561738 \).
Division Example
Let's divide one multibyte BCD number by another:
1234 ÷ 56
To perform division:
1. Start by dividing the leftmost digits of the dividend by the divisor. In this case, \( 12 ÷ 56 = 0
\), and the remainder is \( 12 \).
2. Bring down the next digit of the dividend to form \( 124 \)
3. Now, divide \( 124 ÷ 56 \), which gives \( 2 \) with a remainder of \( 12 \).
4. Bring down the next digit of the dividend to form \( 1234 \).
5. Finally, divide \( 1234 ÷ 56 \), which gives \( 22 \) with a remainder of \( 2 \).
So, the result of the division is \( 22 \) with a remainder of \( 2 \).
UNIT-IV
8085 INTERRUPTS
The 8085 Interrupts – RIM AND SIM instructions-8259 Programmable Interrupt Controller-
Direct Memory Access (DMA) and 8257 DMA controller.
Interrupts in 8085
Interrupts are the signals generated by the external devices to request the microprocessor
to perform a task.
There are 5 interrupt signals,
i.e. TRAP, RST 7.5, RST 6.5, RST 5.5, and INTR.
Vector interrupt − In this type of interrupt, the interrupt address is known to the
processor. For example: RST7.5, RST6.5, RST5.5, TRAP.
Non-Vector interrupt − In this type of interrupt, the interrupt address is not known to
the processor so, the interrupt address needs to be sent externally by the device to
perform interrupts. For example: INTR.
Maskable interrupt − In this type of interrupt, we can disable the interrupt by writing
some instructions into the program. For example: RST7.5, RST6.5, RST5.5.
Non-Maskable interrupt − In this type of interrupt, we cannot disable the interrupt by
writing some instructions into the program. For example: TRAP.
Software interrupt − In this type of interrupt, the programmer has to add the instructions
into the program to execute the interrupt. There are 8 software interrupts in 8085, i.e.
RST0, RST1, RST2, RST3, RST4, RST5, RST6, and RST7.
Hardware interrupt − There are 5 interrupt pins in 8085 used as hardware interrupts,
i.e. TRAP, RST7.5, RST6.5, RST5.5, INTA.
A small program or a routine that when executed, services the corresponding interrupting
source is called an ISR.
TRAP
RST7.5
It is a maskable interrupt, having the second highest priority among all interrupts.
When this interrupt is executed, the processor saves the content of the PC register into the
stack and branches to 003CH address.
RST 6.5
It is a maskable interrupt, having the third highest priority among all interrupts.
When this interrupt is executed, the processor saves the content of the PC register into the
stack and branches to 0034H address.
RST 5.5
It is a maskable interrupt. When this interrupt is executed, the processor saves the content
of the PC register into the stack and branches to 002CH address.
INTR
It is a maskable interrupt, having the lowest priority among all interrupts. It can be
disabled by resetting the microprocessor.
When INTR signal goes high, the following events can occur −
The microprocessor checks the status of INTR signal during the execution of each
instruction.
When the INTR signal is high, then the microprocessor completes its current instruction
and sends active low interrupt acknowledge signal.
When instructions are received, then the microprocessor saves the address of the next
instruction on stack and executes the received instruction.
. Masking of interrupts: Only the LS 4 bits of the accumulator are used for masking or
unmasking of interrupts.
Bit Purpose
No.
Bit This is the Mask Set Enable (MSE) bit. This bit can have two values: 0or 1.
3:
If MSE bit = 0, SIM instruction is not being used for masking or unmasking of
interrupts. In such a case, the LS 3bits of the Accumulator are not having any useful
information.
If MSE bit = 1, the SIM instruction is used for masking or unmasking of interrupts.
Then the LS 3 bits provide information about masking or unmasking of interrupts.
Bit This is mask RST7.5 (M7.5) bit. Thisbit is meaningful only if MSE bit = 1. If MSE = 1 and
2: M7.5 = 0,RST7.5 is unmasked. If MSE = 1 and M7.5 = 1, RST7.5 is masked.
Bit This is M6.5 bit, used for masking/unmasking of RST6.5. It is similar to M7.5 bit.
1:
Bit This is M5.5 bit, used for masking/unmasking of RST5.5. It is similar to M7.5 bit.
0:
It should be noted that RST7.5, RST6.5, and RST5.5 can be masked or unmasked using
this SIM instruction.
TRAP and INTR cannot be masked or unmasked using SIM.
TRAP is not allowed to be masked because it is the highest priority un-maskable
interrupt.
INTR does do not need the facility of masking because it is the lowest priority interrupt.
After reset of 8085 RST7.5, RST6.5, and RST5.5 interrupts will be in masked condition.
Reset RST7.5 flip-flop: Bit 4 (R7.5) of Accumulator is used for resetting to 0 RST7.5
flip-flop output when SIM instruction is executed.
If R7.5 = 0, SIM instruction is not being used for resetting of RST7.5 flip-flop. Thus, if
R7.5 = 0, there is no change in the RST7.5 flip-flop output.
If R7.5 = 1, the RST7.5flip-flop gets cleared. Let us consider the following diagram for
the better understanding –
Form the diagram it is clear that SIM signal is activated if and only if, SIM instruction is
executed. R7.5 signal is activated when bit 4 (R7.5) of Accumulator = 1.
So the RST7.5flip-flop receives logic 1 to its clear input and thus gets cleared when bit 4
of Accumulator = 1 and SIM instruction is executed.
Alternatively, RST7.5 flip-flop gets cleared when RST7.5 interrupt is recognized by the
8085 or whenever the 8085 is reset.
Bit Purpose
No.
Bit This is the serial output enables (SOE) bit. If this bit = 0, SIM instruction is not being used
6: for serial output of data. In such a case, the MS bit of Accumulator is not having any useful
information. If SOE bit = 1, the SIM instruction is used for serial output of data. Then the
MS bit provides the data to be sent out on the SOD pin of 8085.
Bit This is serial output data (SOD)bit. This bit is meaningful only if SOE bit = 1. If SOE = 1
7: and SIM instruction is executed, then the SOD bit comes out on the SOD pin of 8085.
Through this RIM instruction, 8085 can know which interrupt is masked or unmasked, etc.
The contents of the Accumulator after the execution of the RIM instruction provide this
information.
The meaning of the various bits of the Accumulator after Read Interrupt Mask is
executed is shown in the following figure –
Mask status of interrupts: The LS 3 bits of the accumulator are used to provide mask
status of interrupts. Note that they are not used for masking or unmasking. Masking or
unmasking has to be done using the Read Interrupt Mask instruction.
Bit Purpose
No.
Bit This is mask RST5.5 (M5.5) bit.
0: If M5.5 = 1, it means that RST5.5 interrupt has been masked.
If M5.5 = 0, RST5.5 interrupt is unmasked.
Bit This is mask RST6.5 (M6.5) bit.
1: If M6.5 = 1, it means that RST 6.5 interrupt has been masked.
If M6.5 = 0, RST 6.5 interrupt is unmasked.
Bit This is mask RST7.5 (M7.5) bit.
2: If M7.5 = 1, it means that RST 7.5 interrupt has been masked.
If M7.5 = 0, RST7.5 interrupt is unmasked.
Interrupt Enable (IE) status: Bit 3 of the Accumulator provides the status of IE flip-flop
after the Read Interrupt Mask instruction is executed.
If IE = 1, it means that the interrupt system is enabled. This will be the situation if EI
instruction is executed sometime prior to the RIM instruction.
If IE = 0, it means that the interrupt system is disabled. This will be the situation if
sometime prior to execution of the RIM instruction, one of the following things have
occurred.
DI instruction was executed
Intel 8085 has been reset
Intel 8085 has entered an interrupt service subroutine.
Bit Purpose
No.
Bit This is interrupt pending RST5.5 (IP5.5) bit.
4: If IP5.5 = 1, it means that RST5.5 interrupt is pending, waiting to be serviced. This will
be the situation when RST5.5 interrupt pin is activated, but RST5.5 is masked, or the
interrupt system is disabled.
If IP5.5 = 0, the RST5.5interrupt is not pending.
Bit This is interrupt pending RST6.5 (IP6.5) bit.
5: If IP6.5 = 1, it means that RST6.5 interrupt is pending, waiting to be serviced.
If IP6.5 = 0, the RST6.5interrupt is not pending.
Bit This is interrupt pending RST7.5 (IP7.5) bit.
6: If IP7.5 = 1, it means that RST7.5 interrupt is pending, waiting to be serviced.
If IP7.5 = 0, the RST7.5 interrupt is not pending.
Bit This is SID bit. After the RIM instruction is executed, the data on the SID pin of 8085 gets
7: loaded into this bit position.
Let us discuss details about the various interrupts of 8085 as summarized in the table that
follows.
Pin Priority Interrupt Service Sub- Sensitivity Condition
routine Address
TRAP Highest 0024H Rising Edge and Unconditional
High Level
RST7.5 Second 003CH Rising Edge Unmasked and EI
RST6.5 Third 0034H High Level Unmasked and EI
RST5.5 Fourth 002CH High Level Unmasked and EI
INTR Lowest Supplied by an external High Level EI
device
Initially, when any device has to send data between the device and the memory, the
device has to send DMA request (DRQ) to DMA controller.
The DMA controller sends Hold request (HRQ) to the CPU and waits for the CPU to
assert the HLDA.
Then the microprocessor tri-states all the data bus, address bus, and control bus. The
CPU leaves the control over bus and acknowledges the HOLD request through
HLDA signal.
Now the CPU is in HOLD state and the DMA controller has to manage the operations
over buses between the CPU, memory, and I/O devices.
Features of 8257
It has four channels which can be used over four I/O devices.
Each channel has 16-bit address and 14-bit counter.
Each channel can transfer data up to 64kb.
Each channel can be programmed independently.
Each channel can perform read transfer, write transfer and verify transfer operations.
It generates MARK signal to the peripheral device that 128 bytes have been transferred.
It requires a single phase clock.
Its frequency ranges from 250Hz to 3MHz.
It operates in 2 modes, i.e., Master mode and Slave mode.
8257 Architecture
The following image shows the architecture of 8257 −
8257 Pin Description
The following image shows the pin diagram of a 8257 DMA controller −
DRQ0−DRQ3
These are the four individual channel DMA request inputs, which are used by the
peripheral devices for using DMA services.
When the fixed priority mode is selected, then DRQ0 has the highest priority and
DRQ3 has the lowest priority among them.
DACKo − DACK3
These are the active-low DMA acknowledge lines, which updates the requesting
peripheral about the status of their request by the CPU.
These lines can also act as strobe lines for the requesting devices.
Do − D7
These are bidirectional, data lines which are used to interface the system bus with the
internal data bus of DMA controller.
In the Slave mode, it carries command words to 8257 and status word from 8257.
In the master mode, these lines are used to send higher byte of the generated address to
the latch. This address is further latched using ADSTB signal.
IOR
It is an active-low bidirectional tri-state input line, which is used by the CPU to read
internal registers of 8257 in the Slave mode.
In the master mode, it is used to read data from the peripheral devices during a memory
write cycle.
IOW
It is an active low bi-direction tri-state line, which is used to load the contents of the data
bus to the 8-bit mode register or upper/lower byte of a 16-bit DMA address register or
terminal count register.
In the master mode, it is used to load the data to the peripheral devices during DMA
memory read cycle.
CLK
It is a clock frequency signal which is required for the internal operation of 8257.
RESET
This signal is used to RESET the DMA controller by disabling all the DMA channels.
Ao - A3
CS
A4 - A7
These are the higher nibble of the lower byte address generated by DMA in the master
mode.
READY
It is an active-high asynchronous input signal, which makes DMA ready by inserting wait
states.
HRQ
This signal is used to receive the hold request signal from the output device.
In the slave mode, it is connected with a DRQ input line 8257.
In Master mode, it is connected with HOLD input of the CPU.
HLDA
It is the hold acknowledgement signal which indicates the DMA controller that the bus
has been granted to the requesting peripheral by the CPU when it is set to 1.
MEMR
It is the low memory read signal, which is used to read the data from the addressed
memory locations during DMA read cycles.
MEMW
It is the active-low three state signal which is used to write the data to the addressed
memory location during DMA write operation.
ADST
This signal is used to convert the higher byte of the memory address generated by the
DMA controller into the latches.
AEN
TC
It stands for ‘Terminal Count’, which indicates the present DMA cycle to the present
peripheral devices.
MARK
The mark will be activated after each 128 cycles or integral multiples of it from the
beginning.
It indicates the current DMA cycle is the 128th cycle since the previous MARK output to
the selected peripheral device.
Vcc
It is the power signal which is required for the operation of the circuit.