Microprocessor Material
Microprocessor Material
8085 Microprocessor – Pinout and Signals – Functional block diagram - 8085 Instruction Set and
Classifications.
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.
The 8085 Interrupts – RIM AND SIM instructions-8259 Programmable Interrupt ControllerDirect
Memory Access (DMA) and 8257 DMA controller.
Text Book(s)
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:
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.
Assembly language: A medium of communication with a computer in which programs are written in
mnemonics. An assembly language is specific to a given 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.
First, two generations of languages were comparatively easier for a computer to understand,
but it was difficult for humans to read, understand and code in them.
Thus, came English like programming languages to give instructions to computers.
These languages are known as High-Level Languages as they are easier for humans to
understand.
C, C++, Java, COBOL Pascal, etc. are some High-Level Languages.
Intel 8085 is used in mobile phones, microwave ovens, washing machines etc.
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:
The 8085 microprocessor contains six 8-bit general purpose registers.
They are: B, D, C, E, H and L register.
To hold data of 16-bit a combination of two 8-bit registers can be employed.
The combination of two 8-bit registers is called register pair.
The valid register pairs in the 8085 are: D-E, B-C and H-L.
The H-L pair is used to act as a memory pointer.
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.
Zero Flag(Z)
Sign Flag(S)
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 [Link] 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 synchronisation 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 [Link] 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 [Link] 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 8bit
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, [Link] 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 opcodeof
instruction from memory (i.e. it places an address on the address bus and memory responds by
placing the data stored at the specifiedaddress on the data bus). The CPU storesthis opcode in a
register called the instruction register. Thisopcode is further sent to the instruction decoder to select
one ofthe 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 –
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
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
inputoutput 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.
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.
This flag indicates whether during an addition or subtraction operation carry or borrow is
generated or not.
4. Register array
The register unit of 8085 consists of
Six general-purpose data registers B,C,D,E,H,L
Two internal registers W and Z
Two 16-bit address registers PC (program counter) and SP (stack pointer)
One increment/decrement counter register
And, one multiplexer (MUX)
The six general-purpose registers are used to store 8-bit data. They can be combined as
register pairs BC, DE, and HL to perform some 16-bit operations.
The two internal registers W and Z are used to hold 8-bit data during the execution of
some instructions, CALL and XCHG instructions.
SP is 16-bit registers used to point the address of data stored in the stack memory. It
always indicates the top of the stack.
PC is 16-bit register used to point the address of the next instruction to be fetched and
executed stored in the memory.
5. System bus
a. Data bus
It carries ‘data’, in binary form, between MP and other external units, such as memory.
Typical size is 8 or 16 bits.
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.
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
[Link] 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.
[Link] 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.
[Link] 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 Spe cified 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
UNIT-III
BCD to Binary and Binary to BCD conversions
Converting between Binary-Coded Decimal (BCD) and binary can be useful in certain applications,
particularly in digital electronics or computing systems where decimal representation is required.
Here's how you can perform these conversions:
BCD to Binary Conversion:
1. Separate the digits: BCD encodes each decimal digit in a 4-bit binary number. Separate each digit
into groups of four bits.
2. Convert each digit to binary: For each BCD digit, convert it to its 4-bit binary equivalent.
3. Concatenate the binary digits: After converting each BCD digit to binary, concatenate them together
to form the binary representation of the original BCD number.
Example:
Let's say we have the BCD number 1010 0110.
1. Separate the digits: 1010 and 0110.
2. Convert each digit to binary:
- 1010 in binary is 10.
- 0110 in binary is 6.
3. Concatenate the binary digits: 1010 0110 in BCD is equivalent to 101000110 in binary.
Binary to BCD Conversion:
1. Split the binary number into groups of 4 bits: Start from the rightmost bit and group the binary digits
into sets of four, adding leading zeros if necessary.
2. Convert each group to decimal: Convert each 4-bit group to its decimal equivalent.
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
(11101)2 = (00101001)BCD
BCD to Binary Conversion
Steps
Result
(00101001)BCD = (11101)2
Converting between ASCII (American Standard Code for Information Interchange) and BinaryCoded
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
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.
Let us consider the following program segment –
Address Hex Mnemonic Comment
Codes
2000 3E MVI A, A ← 19H =0001 1001, it means SOD=0,
19H SDE=0, R7.5=1, MSE=1, M5.5=1
2001 19 Accumulator value 19H
2002 30 SIM Set Interrupt Mask
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.
The pin level diagram and functional pin diagram is like below -
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
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.
UNIT I – INTRODUCTION (10 MCQs)
1. The 8085 is a:
o A) 4-bit
o B) 8-bit
o C) 16-bit
o D) 32-bit
2. Maximum memory accessed by the 8085 is:
o A) 16 KB
o B) 64 KB
o C) 32 KB
o D) 128 KB
3. Number of address lines in the 8085:
o A) 8
o B) 16
o C) 20
o D) 24
4. Number of data lines in the 8085:
o A) 4
o B) 8
o C) 16
o D) 32
5. Machine language uses:
o A) English
o B) Binary
o C) Hexadecimal
o D) Decimal
6. CPU stands for:
o A) Central Program Unit
o B) Central Processing Unit
o C) Computer Processing Unit
o D) Central Power Unit
7. ALU performs:
o A) Printing
o B) Arithmetic and Logic operations
o C) Storage
o D) Communication
8. RAM is:
o A) Permanent memory
o B) Temporary memory
o C) Optical memory
o D) Secondary memory
9. ROM stands for:
o A) Random Output Memory
o B) Read Only Memory
o C) Read Open Memory
o D) Run Only Memory
10. The brain of the computer is:
A) RAM
B) CPU
C) Hard Disk
D) Keyboard
1. 8051 is a:
o A) Microprocessor
o B) Microcontroller
o C) Memory Chip
o D) ALU
2. Number of I/O ports:
o A) 2
o B) 4
o C) 6
o D) 8
3. Total pins in the 8051:
o A) 20
o B) 40
o C) 28
o D) 64
4. Number of timers:
o A) 1
o B) 2
o C) 3
o D) 4
5. Number of interrupts:
o A) 3
o B) 5
o C) 6
o D) 8
6. Program Counter is:
o A) 8-bit
o B) 16-bit
o C) 32-bit
o D) 4-bit
7. TMOD register is used for:
o A) Interrupts
o B) Timer Modes
o C) Ports
o D) Memory
8. TCON register is used for:
o A) Serial Communication
o B) Timer Control
o C) Memory
o D) ALU
9. Which port has alternate functions?
o A) Port 0
o B) Port 3
o C) Port 1
o D) Port 2
10. The 8051 is mainly used in:
A) Desktop Computers
B) Embedded Systems
C) Supercomputers
D) Servers
UNIT I – INTRODUCTION
Important 5 Marks
Explain the pin diagram of the 8085.
Explain the instruction classification.
Explain addressing modes.
Important 10 Marks
Draw and explain the functional block diagram of the 8085.
Explain the instruction set classification with examples.
Important 5 Marks
Explain BCD to Binary conversion.
Explain ASCII to BCD conversion.
Explain Binary to ASCII conversion.
Important 10 Marks
Explain multiplication and division using the 8085.
Explain multibyte addition and subtraction.
Write an 8085 program for BCD arithmetic.
UNIT IV – INTERRUPTS
Important 5 Marks
Explain interrupts in the 8085.
Explain RIM and SIM instructions.
Explain the DMA controller.
Important 10 Marks
Explain the 8259 programmable interrupt controller.
Explain the 8257 DMA controller with a block diagram.
Important 5 Marks
Explain the architecture of the 8051.
Explain timers and counters.
Explain interrupt control registers.
Compare the microprocessor and microcontroller.
Important 10 Marks
Explain the architecture of the 8051 with a neat diagram.
Explain interrupts in the 8051.
Explain timer operating modes with examples.
Compare the 8085 microprocessor and the 8051 microcontroller.