0% found this document useful (0 votes)
12 views

MP 8085 Notes

A microprocessor is a digital integrated circuit that contains the central processing unit of a computer. It takes in input, performs arithmetic and logical operations on the input, and produces output. Microprocessors are used in many electronic devices like computers, smartphones, tablets, TVs, and cars. They work by executing a sequence of instructions stored in memory, fetching instructions from memory, decoding them, and executing them. Common components include the arithmetic logic unit, control unit, registers, and bus system.

Uploaded by

Saddam Ansari
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views

MP 8085 Notes

A microprocessor is a digital integrated circuit that contains the central processing unit of a computer. It takes in input, performs arithmetic and logical operations on the input, and produces output. Microprocessors are used in many electronic devices like computers, smartphones, tablets, TVs, and cars. They work by executing a sequence of instructions stored in memory, fetching instructions from memory, decoding them, and executing them. Common components include the arithmetic logic unit, control unit, registers, and bus system.

Uploaded by

Saddam Ansari
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 37

INTRODUCTION TO MICROPROCESSOR

A microprocessor is a digital integrated circuit (IC) that contains the central


processing unit (CPU) of a computer. It is a programmable device that takes in
input, performs some arithmetic and logical operations over it, and produces the
desired output.

Microprocessors are used in a wide variety of electronic devices, including


computers, smartphones, tablets, TVs, and even cars. They are also used in
industrial control systems and other embedded systems.

How Microprocessors Work

Microprocessors work by executing a sequence of instructions. These


instructions are stored in the computer's memory. The microprocessor fetches
the instructions from memory, decodes them, and then executes them.

The microprocessor has several different components that help it to execute


instructions. These components include:

● Arithmetic and logic unit (ALU): The ALU performs arithmetic and logical
operations on data.
● Control unit: The control unit manages the flow of execution of instructions.
● Registers: Registers are used to store temporary data.
● Bus system: The bus system connects the microprocessor to the other
components of the computer system, such as memory and input/output
devices.

Types of Microprocessors

There are many different types of microprocessors available. Microprocessors


can be classified by their word size, clock speed, and instruction set architecture
(ISA).
● Word size: The word size is the number of bits that the microprocessor
can operate on at a time. Common word sizes include 4 bits, 8 bits, 16
bits, 32 bits, and 64 bits.
● Clock speed: The clock speed is the number of times per second that the
microprocessor can execute an instruction. Clock speeds are measured in
megahertz (MHz) or gigahertz (GHz).
● Instruction set architecture (ISA): The ISA is the set of instructions that the
microprocessor can understand and execute. Common ISAs include x86,
ARM, and MIPS.

Applications of Microprocessors

Microprocessors are used in a wide variety of electronic devices. Some common


applications of microprocessors include:

● Computers: Microprocessors are used in all types of computers, from


desktop computers to laptops to smartphones.
● Mobile devices: Microprocessors are used in all types of mobile devices,
such as smartphones, tablets, and e-readers.
● Embedded systems: Microprocessors are used in embedded systems,
which are specialized computers that are designed to perform a specific
task. Embedded systems are used in a wide variety of devices, such as
cars, appliances, and industrial control systems.

COMPONENTS OF MICROPROCESSORS

The main components of a microprocessor are:

Control unit (CU): The CU is responsible for fetching instructions from


memory, decoding them, and executing them. It also oversees the flow of data
within the microprocessor.
● Arithmetic and logic unit (ALU): The ALU performs arithmetic and logical
operations on data. These operations can include addition, subtraction,
multiplication, division, AND, OR, and XOR.
● Registers: Registers are high-speed storage units that are used to store
data and instructions that are currently being processed by the
microprocessor.
● Bus system: The bus system connects the microprocessor to the other
components of the computer system, such as memory and input/output
devices.

How the Components Work Together

The CU fetches instructions from memory and decodes them. It then sends the
decoded instructions to the ALU. The ALU performs the arithmetic and logical
operations specified by the instructions. The results of the operations are stored
in registers.

The CU may also send data to and from memory. The bus system is used to
connect the microprocessor to memory.

The microprocessor continues to fetch and execute instructions until it reaches a


halt instruction. A halt instruction tells the microprocessor to stop executing
instructions.
1 REGISTERS

Registers are high-speed storage units that are used to store data and
instructions that are currently being processed by the microprocessor. They are
very fast, but they have a limited capacity. Registers are typically used to store
the following types of data:

● Data that is being operated on by the ALU


● The addresses of data in memory
● Status information about the microprocessor

The 8085 microprocessor has eight registers. These registers can be classified
into two main types: general-purpose registers and special-purpose registers.

1. General-purpose registers

The general-purpose registers can be used to store any type of data, including 8-
bit numbers, 16-bit addresses, and instructions. The general-purpose registers in
the 8085 microprocessor are:

● A (accumulator)
● B
● C
● D
● E
● H
● L

The accumulator is the most important general-purpose register in the 8085


microprocessor. It is used in most arithmetic and logical operations. The other
general-purpose registers can be used to store temporary data or to store
addresses of data in memory.
2. Special-purpose registers

The special-purpose registers are used for specific tasks. The special-purpose
registers in the 8085 microprocessor are:

● Program counter (PC)


● Stack pointer (SP)
● Program status word (PSW)

The program counter (PC) stores the address of the next instruction to be
executed. The stack pointer (SP) stores the address of the top of the stack. The
program status word (PSW) stores information about the status of the
microprocessor, such as the carry flag and the zero flag.

2 ALU

An arithmetic and logic unit (ALU) is a digital circuit that performs arithmetic and
logical operations on data. It is a key component of the central processing unit
(CPU) in a computer.

The ALU performs a variety of operations, including:

● Arithmetic operations: addition, subtraction, multiplication, and division


● Logical operations: AND, OR, XOR, and NOT
● Comparison operations: greater than, less than, equal to

The ALU can also perform more complex operations, such as floating-point
arithmetic and bit-shifting.

The ALU is typically implemented as a combinational circuit. This means that the
output of the ALU is only dependent on the current input. Combinational circuits
are very fast, but they can be complex to design.
3 CONTROL AND TIMING

Control in a microprocessor refers to the process of managing the execution of


instructions. The control unit (CU) is responsible for fetching instructions from
memory, decoding them, and sending the decoded instructions to the arithmetic
and logic unit (ALU) for execution. The CU also controls the flow of data within
the microprocessor and between the microprocessor and other components of
the computer system.

Timing in a microprocessor refers to the generation of signals that synchronize


the operation of the different components of the microprocessor. The clock
generator is responsible for generating a clock signal that is used to synchronize
the operation of the CU, ALU, and other components of the microprocessor.

The control and timing units in a microprocessor work together to ensure that
instructions are executed correctly and efficiently. The control unit manages the
flow of execution of instructions, while the timing unit ensures that the different
components of the microprocessor are synchronized.

Here is an example of how the control and timing units work together:

1. The CU fetches the next instruction from memory.


2. The CU decodes the instruction and sends the decoded instruction to the
ALU.
3. The ALU executes the instruction.
4. The CU stores the results of the operation in a register.
5. The CU fetches the next instruction from memory.

This process repeats until the program reaches a halt instruction.

The control and timing units are essential components of a microprocessor. They
work together to ensure that instructions are executed correctly and efficiently.
They help to ensure that instructions are executed correctly, efficiently, and
reliably.
4 SYSTEM BUS

A system bus is a communication channel that connects the major components


of a computer system, including the microprocessor, memory, and input/output
(I/O) devices. The system bus carries data, addresses, and control signals
between the different components of the computer system.

The system bus is typically divided into three separate buses:

● Data bus: The data bus carries data between the different components of
the computer system.
● Address bus: The address bus specifies the memory location or I/O device
that the microprocessor wants to access.
● Control bus: The control bus carries signals that control the operation of
the different components of the computer system.

The system bus is essential for the operation of a computer system. It allows the
microprocessor to communicate with the memory and I/O devices, which enables
the microprocessor to execute instructions and process data.

There are two main types of system buses:

● Parallel bus: A parallel bus transmits data in parallel, meaning that all of
the bits of a data word are transmitted at the same time. Parallel buses are
typically faster than serial buses, but they are also more complex and
expensive to implement.
● Serial bus: A serial bus transmits data in series, meaning that the bits of a
data word are transmitted one at a time. Serial buses are typically slower
than parallel buses, but they are also simpler and less expensive to
implement.

Most modern computer systems use serial buses, such as PCI Express (PCIe)
and USB. Serial buses are more flexible and scalable than parallel buses, and
they can also support higher data rates.
Here are some examples of how the system bus is used in a computer system:

● When the microprocessor needs to read data from memory, it sends the
address of the memory location to the memory controller over the address
bus. The memory controller then reads the data from memory and sends it
to the microprocessor over the data bus.
● When the microprocessor needs to write data to memory, it sends the
address of the memory location and the data to be written to the memory
controller over the address bus and data bus, respectively. The memory
controller then writes the data to memory.
● When the microprocessor needs to communicate with an I/O device, it
sends the address of the I/O device to the I/O controller over the address
bus. The I/O controller then communicates with the I/O device.

MICROPROCESSOR SYSTEM WITH BUS ORGANIZATION


MICROPROCESSOR ARCHITECTURE AND OPERATIONS

Microprocessor architecture is the design of the internal components of a


microprocessor, as well as the way in which those components interact with each
other. The architecture of a microprocessor determines its capabilities,
performance, and power consumption.

The following are some of the key concepts in microprocessor architecture:

● Instruction set architecture (ISA): The ISA is the set of instructions that a
microprocessor can understand and execute.
● Clock speed: The clock speed is the number of times per second that the
microprocessor can execute an instruction.
● Word size: The word size is the number of bits that the microprocessor
can operate on at a time.
● Pipeline: A pipeline is a technique that allows the microprocessor to
execute multiple instructions at the same time.
● Cache memory: Cache memory is a high-speed memory that stores
frequently accessed data and instructions.

Microprocessor operations are the basic actions that a microprocessor can


perform. These operations include:

● Arithmetic operations: Addition, subtraction, multiplication, and division


● Logical operations: AND, OR, XOR, and NOT
● Comparison operations: Greater than, less than, equal to
● Control operations: Conditional jumps, loops, and subroutine calls
● Data transfer operations: Moving data between registers and memory.

The microprocessor performs the following four operations using the address bus,
data bus, and control bus:
● Memory Read: Reads data (or instruction) from memory.
● Memory Write: Writes data (or instruction) into memory.
● I/O Read: Accepts data from the input device.
● I/O Write: Sends data to the output device

MEMORY

In a computer system, various types of memory are used to store and manage data at
different stages of processing. These memory types serve specific purposes and have
different characteristics. Here are the main types of memory used in a typical computer:

1. Registers:
○ Type: CPU Registers
○ Characteristics: Fastest and smallest memory directly on the CPU.
○ Purpose: Registers store data that the CPU is actively processing. They are
used for immediate data manipulation and calculations.
2. Cache Memory:
○ Types: L1 Cache, L2 Cache, L3 Cache (in multi-core processors)
○ Characteristics: Fast and located close to the CPU.
○ Purpose: Cache memory temporarily stores frequently used data and
instructions to reduce the time it takes for the CPU to access them from
slower main memory.
3. Main Memory (RAM - Random Access Memory):
○ Type: RAM
○ Characteristics: Larger than cache memory, but slower.
○ Purpose: RAM stores the data and program code that the CPU is actively
using. It provides volatile storage, meaning data is lost when the computer is
powered off.
4. Virtual Memory:
○ Type: Virtual Memory
○ Characteristics: A portion of the hard drive or SSD used as an extension of
RAM.
○ Purpose: Virtual memory is used when RAM is insufficient. It allows the
computer to store data not immediately needed on disk and swap it in and out
of RAM as needed.
5. Solid-State Drives (SSD):
○ Type: SSD
○ Characteristics: Non-volatile storage with faster access times compared to
traditional HDDs.
○ Purpose: SSDs are used for long-term storage of the operating system,
applications, and user data.
6. Hard Disk Drives (HDD):
○ Type: HDD
○ Characteristics: Slower access times compared to SSDs, but with larger
storage capacity.
○ Purpose: HDDs are used for long-term storage of data and are often used in
systems where high capacity is more important than speed.
7. Optical Drives:
○ Type: CD/DVD/Blu-ray drives
○ Characteristics: Slow access times, used for reading and writing optical
discs.
○ Purpose: Optical drives are used for data backup, software installation, and
media playback.
8. Tape Drives:
○ Type: Magnetic tape drives
○ Characteristics: Very slow access times but high storage capacity.
○ Purpose: Tape drives are used for long-term data archival due to their low
cost per stored gigabyte.
9. External Storage Devices:
○ Type: External hard drives, USB flash drives, memory cards, etc.
○ Characteristics: Various speeds and capacities.
○ Purpose: External storage devices are used for portable data storage and
backup.
10. GPU Memory (VRAM):
○ Type: VRAM (Video RAM)
○ Characteristics: Specialized memory on a graphics processing unit (GPU).
○ Purpose: VRAM stores textures, frame buffers, and other data necessary for
rendering graphics in applications and games.
INPUT / OUTPUT DEVICES AND OPERATIONS

Input/output (I/O) operations in microprocessors allow the microprocessor to


communicate with the outside world. The microprocessor uses I/O operations to
read data from input devices, such as keyboards and mice, and to write data to
output devices, such as monitors and printers.

There are three main types of I/O operations:

● Programmed I/O: In programmed I/O, the microprocessor directly controls


the I/O device. This means that the microprocessor has to read and write
data from and to the I/O device itself.
● Interrupt-driven I/O: In interrupt-driven I/O, the I/O device interrupts the
microprocessor when it has data ready to be read or written. This means
that the microprocessor does not have to constantly check the I/O device
to see if it has data.
● Direct memory access (DMA): In DMA, the I/O device can directly access
memory without having to go through the microprocessor. This is the
fastest type of I/O operation, but it is also the most complex to implement.

The type of I/O operation that is used depends on the I/O device and the
requirements of the application.

Here is an example of how programmed I/O might be used to read data from a
keyboard:

1. The microprocessor sends a read command to the keyboard controller.


2. The keyboard controller reads the data from the keyboard and stores it in
a buffer.
3. The microprocessor polls the keyboard controller to see if it has data
ready.
4. When the keyboard controller has data ready, it sets a flag.
5. The microprocessor reads the data from the buffer in the keyboard
controller.
This process is repeated until the user releases the key on the keyboard.

Here is an example of how interrupt-driven I/O might be used to read data from a
mouse:

1. The microprocessor enables the mouse interrupt.


2. When the mouse moves, it generates an interrupt signal.
3. The microprocessor receives the interrupt signal and disables the mouse
interrupt.
4. The microprocessor reads the data from the mouse.
5. The microprocessor re-enables the mouse interrupt.

This process is repeated every time the mouse moves.

DMA is typically used for high-speed I/O devices, such as hard disk drives and
network adapters. DMA allows the I/O device to directly access memory without
having to go through the microprocessor. This can significantly improve the
performance of I/O operations.

I/O operations are essential for microprocessors to be useful. They allow


microprocessors to communicate with the outside world and to interact with
users.
8085 MICROPROCESSOR ARCHITECTURE
8085 PIN DIAGRAM
8085 PIN DIAGRAM EXPLAIN

1. Address Bus and Data Bus:


The address bus is a group of sixteen lines i.e A0-A15. The address bus is
unidirectional, i.e., bits flow in one direction from the microprocessor unit to the
peripheral devices and uses the high order address bus.

2. Control and Status Signals:

 ALE – It is an Address Latch Enable signal. It goes high during first T


state of a machine cycle and enables the lower 8-bits of the address, if its
value is 1 otherwise data bus is activated.

 IO/M’ – It is a status signal which determines whether the address is for


input-output or memory. When it is high(1) the address on the address bus
is for input-output devices. When it is low(0) the address on the address
bus is for the memory.

 SO, S1 – These are status signals. They distinguish the various types of
operations such as halt, reading, instruction fetching or writing.

 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.
DEMULTIPLEXING OF BUSES

Demultiplexing of buses in a microprocessor is the process of separating the


address bus and data bus into two separate buses. This is necessary because the
address bus and data bus are often multiplexed to reduce the number of pins on the
microprocessor chip.

Multiplexing means that the same bus lines are used to carry both address and data
information at different times. This is done by using a control signal to indicate
whether the bus is carrying address or data information.

Demultiplexing is the opposite of multiplexing. It means separating the address and


data buses into two separate buses. This is necessary to avoid confusion between
address and data information.

Demultiplexing of buses in a microprocessor is typically done using a latch. The latch


is enabled by the control signal that indicates whether the bus is carrying address or
data information. When the latch is enabled, it stores the address or data information
on the bus.

The demultiplexed address and data buses are then connected to the appropriate
devices, such as the memory and the I/O devices.

Here is an example of how demultiplexing of buses is used in the 8085


microprocessor :

 The 8085 microprocessor has a multiplexed address/data bus, which means


that the same bus lines are used to carry both address and data information.

 The 8085 microprocessor uses a control signal called ALE (Address Latch
Enable) to indicate whether the bus is carrying address or data information.

 When ALE is high, the address bus is enabled and the data bus is disabled.

 When ALE is low, the data bus is enabled and the address bus is disabled.

To demultiplex the address/data bus, a latch is used. The latch is enabled by the
ALE signal. When ALE is high, the latch stores the address information on the bus.
When ALE is low, the latch stores the data information on the bus.
The 8086 microprocessor has time-multiplexed 16-bit address/data bus
AD15-AD0 and 4-bit address/status bus A19/S6-A16/S3.

GENERATION OF CONTROL SIGNALS

The 8085 microprocessor generates control signals to control the operation of the
memory and I/O devices. The control signals are generated by the 8085's internal
control unit.

The 8085 microprocessor has three control signals that are used to generate the
other control signals:

 IO/M': Input/Output or Memory signal. This signal indicates whether the 8085
is accessing memory or an I/O device.
 RD': Read signal. This signal indicates that the 8085 is reading data from
memory or an I/O device.
 WR': Write signal. This signal indicates that the 8085 is writing data to
memory or an I/O device.

The other control signals are generated using a decoder. The decoder is a logic
circuit that takes a set of input signals and generates a set of output signals. The
decoder is configured to generate the following control signals:

 MEMR': Memory Read signal. This signal is asserted when the 8085 is
reading data from memory.
 MEMW': Memory Write signal. This signal is asserted when the 8085 is writing
data to memory.
 IOR': I/O Read signal. This signal is asserted when the 8085 is reading data
from an I/O device.
 IOW': I/O Write signal. This signal is asserted when the 8085 is writing data to
an I/O device

The control signal decoder is typically implemented using a 3-to-8 decoder IC, such
as the 74LS138. The three input signals to the decoder are IO/M', RD', and WR'. The
eight output signals from the decoder are MEMR', MEMW', IOR', and IOW'.
In the 8085 microprocessor, the generation of control signals is a crucial aspect of its
operation. These control signals are responsible for coordinating the various
activities within the microprocessor and ensuring that instructions are executed
correctly. The control signals are generated based on the contents of the instruction
register (IR) and the state of the microprocessor.

Here's a high-level explanation of how control signals are generated in the 8085
microprocessor:

1. Fetch Phase:

 During the fetch phase, the microprocessor fetches the next instruction
from memory.

 The program counter (PC) holds the address of the next instruction to
be executed.

 Control signals are generated to perform the following tasks:

 PC output enable: This signal enables the PC to put the address


on the address bus.

 Memory read (RD): This signal indicates that the microprocessor


is reading from memory.

 Memory write (WR): This signal indicates that the


microprocessor is not writing to memory during the fetch phase.

 Address bus multiplexing: The address bus is multiplexed to


carry both memory addresses and status/control information.

2. Decode Phase:

 During the decode phase, the instruction in the instruction register (IR)
is decoded to determine the operation to be performed.

 Control signals are generated to:


 Set various internal registers and flags based on the instruction.

 Activate specific functional units like the ALU (Arithmetic Logic


Unit) for arithmetic and logic operations.

 Enable the appropriate data paths for register-to-register or


memory-to-register transfers.

 Set or reset flags like the zero flag, sign flag, carry flag, and
parity flag based on the operation's result.

3. Execute Phase:

 In this phase, the microprocessor executes the actual operation


specified by the instruction.

 Control signals are generated to:

 Activate the ALU and specify the operation (e.g., addition,


subtraction, logical AND, etc.).

 Enable the data paths for reading source operands and writing
the result.

 Perform memory read or write operations if needed.

4. Interrupt and Control Signals:

 Control signals are also generated to handle interrupts and control the
overall operation of the microprocessor.

 For example, the interrupt control signals (e.g., INTA, RSTn) are
generated to manage interrupts from external devices.

 Control signals for controlling the microprocessor's clock, resetting,


halting, and enabling/disabling interrupts are also generated as
needed.
It's important to note that the specific control signals and their timing can vary
depending on the instruction being executed and the microprocessor's internal state.
The microprocessor's control unit is responsible for generating these signals in
synchronization with the clock signal to ensure proper instruction execution and data
flow within the CPU. The sequence and timing of control signals are critical for the
8085 microprocessor's correct operation.

INSTRUCTION CYCLE

In the context of the 8085 microprocessor, an instruction cycle, also known as a machine
cycle, refers to the time it takes to execute a single machine-level instruction. The instruction
cycle is composed of a series of smaller internal operations that the microprocessor
performs to fetch, decode, execute, and complete an instruction.

The 8085 microprocessor typically has a minimum of four machine cycles for each
instruction, although some instructions may require more cycles. These four basic machine
cycles are:

1. Fetch Cycle (T1): In the first machine cycle, the microprocessor fetches the
instruction from memory. The program counter (PC) provides the memory address of
the instruction to be fetched. During this cycle, the memory read operation is
performed, and the fetched instruction is loaded into the instruction register (IR).

2. Decode Cycle (T2): During the second machine cycle, the microprocessor decodes
the instruction stored in the instruction register (IR). The control unit generates
control signals based on the opcode (operation code) of the instruction to determine
the specific operation to be executed.

3. Execute Cycle (T3): In the third machine cycle, the actual execution of the instruction
takes place. The microprocessor performs the specified operation, such as
arithmetic, logic, or data transfer. Data may be read from or written to memory or
registers as needed.

4. Memory Write Cycle (T4): This cycle is optional and is only executed if the instruction
involves writing data back to memory. During this cycle, the microprocessor writes
the result of the operation back to memory.
The following is an example of the instruction cycle for the MOV A, B instruction:

(i). The microprocessor fetches the MOV A, B instruction from the memory location
pointed to by the PC.

(ii) The microprocessor decodes the MOV A, B instruction to determine that it is a


data transfer instruction that moves the contents of register B to register A.

(iii) The microprocessor executes the MOV A, B instruction by moving the contents
of register B to register A.

(iv) The microprocessor does not need to store the result of the execution, because
the result is already stored in register A.

MACHINE CYCLE

The machine cycle is the time it takes for a computer's central processing unit (CPU)
to execute a single machine language instruction. It's also known as the instruction
cycle. The 8085 microprocessor has seven basic machine cycles:

 Opcode fetch cycle

 Memory read cycle

 Memory write cycle

 I/O read cycle

 I/O write cycle

 Interrupt acknowledge

 Bus idle
T-STATES IN 8085

In the context of the 8085 microprocessor, T-states, short for "Time States," refer to
the individual clock cycles or time intervals within a machine cycle. T-states are used
to precisely measure the execution time of instructions and operations in the
microprocessor. Each machine cycle consists of a specific number of T-states, and
the total number of T-states required for an instruction determines its execution time

One time period of frequency of microprocessor is called t-state. A t-state is


measured from the falling edge of one clock pulse to the falling edge of the next
clock pulse. Fetch cycle takes four t-states and execution cycle takes three t-states

Instruction T-states
MOV A, B 3
MOV B, A 3
ADD A, B 4
SUB A, B 4
MUL B 10
DIV B 24
JMP 2000H 10
CALL 2000H 17
MEMORY INTERFACING

Memory interfacing in the 8085 microprocessor is the process of connecting the


microprocessor to memory devices such as ROM, RAM, and EPROM. Memory
interfacing is necessary for the microprocessor to be able to read and write data to
memory.
The 8085 microprocessor has a 16-bit address bus, which means that it can access
up to 64 KB of memory. The 8085 microprocessor also has an 8-bit data bus, which
means that it can read and write 8 bits of data at a time.
To interface the 8085 microprocessor to memory devices, the following steps are
typically followed:

1. Select the memory devices: The first step is to select the memory devices that
will be used with the microprocessor. The most common memory devices
used with the 8085 microprocessor are ROM, RAM, and EPROM.
2. Determine the memory map: The next step is to determine the memory map.
The memory map is a table that shows the addresses of the different memory
devices in the system.
3. Connect the memory devices to the microprocessor: Once the memory map
has been determined, the memory devices can be connected to the
microprocessor. The address bus, data bus, and control signals are
connected to the memory devices.
4. Test the memory interface: Once the memory devices have been connected,
the memory interface should be tested to make sure that it is working
properly. This can be done by writing data to memory and then reading it back
to verify that the data is correct.
ASSEMBLY LANGUAGE PROGRAMMING BASICS

Assembly language programming in 8085 is the process of writing instructions for


the 8085 microprocessor in assembly language. Assembly language is a low-level
programming language that is specific to a particular microprocessor. It is more
difficult to learn than high-level programming languages, but it gives programmers
more control over the microprocessor.

Assembly language programs are written using a text editor. The assembly language
program is then compiled into a machine code program that can be executed by the
8085 microprocessor.

Assembly language programs are typically written using a set of mnemonics.


Mnemonics are easy-to-remember abbreviations for the machine code instructions.
For example, the mnemonic for the MOV instruction is MOV. The MOV instruction is
used to move data from one register to another or from memory to a register.

Assembly language programs also use labels to identify memory locations and
instructions. Labels are symbolic names that are assigned to memory locations and
instructions. For example, the following code shows how to use a label to identify a
memory location:

START: MOV A, 5
HLT

The label START is assigned to the memory location where the MOV instruction is
located.

Assembly language programs are typically divided into two sections: the data section
and the code section. The data section contains the data that will be used by the
program. The code section contains the instructions that will be executed by the
program.

Here is an example of a simple assembly language program in 8085:

START: MOV A, 5
ADD B
HLT
This program contains two instructions: MOV A, 5 and ADD B. The MOV instruction
moves the value 5 into register A. The ADD instruction adds the contents of register
B to register A. The HLT instruction halts the microprocessor.

EXAMPLE ==> Add two 8-bit numbers.

1. LXI H, 2501H : "Get address of first number in H-L pair. Now H-L points to 250
1H"
2. MOV A, M : "Get first operand in accumulator"
3. INX H : "Increment content of H-L pair. Now, H-L points 2502H"
4. ADD M : "Add first and second operand"
5. INX H : "H-L points 4002H"
6. MOV M, A : "Store result at 2503H"
7. HLT : "Stop"

INSTRUCTIONS AND THEIR CLASSIFICATIONS


In a microprocessor like the 8085, an instruction is a binary code that specifies a
particular operation to be performed by the microprocessor. These instructions are
the fundamental building blocks of machine-level programs, and each instruction
corresponds to a specific operation, such as arithmetic, data transfer, branching, or
control.
Instructions in the 8085 microprocessor can be classified based on several criteria,
including their function, addressing modes, and opcode structure. Here are the
primary classifications of instructions in the 8085 microprocessor:
1. Data Transfer Instructions:
 These instructions are used to move data between registers, memory,
and I/O devices. Examples include MOV (Move), MVI (Move
Immediate), LXI (Load Register Pair with Immediate), LDA (Load
Accumulator Directly), STA (Store Accumulator Directly), etc.
2. Arithmetic Instructions:
 Arithmetic instructions are used for mathematical operations such as
addition, subtraction, multiplication, division, and increment/decrement.
Examples include ADD, SUB, INR (Increment Register), DCR
(Decrement Register), etc.
3. Logical Instructions:
 Logical instructions perform bitwise operations like AND, OR, XOR,
complementing (NOT), and shifting bits left or right. Examples include
ANA (Logical AND), ORA (Logical OR), XRA (Logical XOR), CMA
(Complement Accumulator), etc.
4. Branch Control Instructions:
 These instructions control the flow of program execution by altering the
program counter (PC). Conditional branch instructions allow the
program to branch to a different memory location based on certain
conditions, such as JNZ (Jump if Not Zero), JZ (Jump if Zero), JMP
(Unconditional Jump), CALL (Call Subroutine), RET (Return from
Subroutine), etc.
5. Stack Operations:
 These instructions are used to manipulate the stack pointer (SP) and
perform push and pop operations on the stack. Examples include
PUSH, POP, PUSH PSW, POP PSW, etc.
6. Input/Output Instructions:
 I/O instructions allow the microprocessor to communicate with external
devices and peripherals. IN and OUT instructions are commonly used
for this purpose.
7. Control Instructions:
 Control instructions are used to control the operation of the
microprocessor. They include instructions like HLT (Halt), NOP (No
Operation), SIM (Set Interrupt Mask), RIM (Read Interrupt Mask), etc.
8. Flag Control Instructions:
 Flag control instructions are used to manipulate the status flags in the
status register (PSW). For example, STC (Set Carry Flag), CMC
(Complement Carry Flag), DI (Disable Interrupts), EI (Enable
Interrupts), etc.
9. NOP and HLT Instructions:
 NOP (No Operation) performs no operation and is often used as a
placeholder. HLT (Halt) instructs the microprocessor to enter a halt
state, stopping all operations until an interrupt occurs or a reset is
triggered.
10. Data Exchange Instructions:
 These instructions are used to exchange the values of two registers.
Examples include XCHG (Exchange), XTHL (Exchange Stack Pointer
with H and L Registers), etc.

** Instructions can also be classified based on their length. The 8085 microprocessor
has three types of instructions:
 1-byte instructions: These instructions are 1 byte long.
 2-byte instructions: These instructions are 2 bytes long.
 3-byte instructions: These instructions are 3 bytes long.
The length of an instruction depends on the number of operands that the instruction
takes. For example, the MOV A, B instruction is a 1-byte instruction because it takes
two operands: register A and register B.

ADDRESSING MODES

Addressing modes are the rules and techniques used by processors to calculate the
memory address or operand location for data operations. They define how
instructions specify the source or destination of data within the system's memory or
registers.

Types of addressing modes –


In 8085 microprocessor there are 5 types of addressing modes:

1. Immediate Addressing Mode –


In immediate addressing mode the source operand is always data. If the
data is 8-bit, then the instruction will be of 2 bytes, if the data is of 16-bit
then the instruction will be of 3 bytes.
Examples:
MVI B 45 (move the data 45H immediately to register B)
LXI H 3050 (load the H-L pair with the operand 3050H immediately)
JMP address (jump to the operand address immediately)

2. Register Addressing Mode –


In register addressing mode, the data to be operated is available inside the
register(s) and register(s) is(are) operands. Therefore the operation is
performed within various registers of the microprocessor.
Examples:
MOV A, B (move the contents of register B to register A)
ADD B (add contents of registers A and B and store the result in register
A)
INR A (increment the contents of register A by one)

3. Direct Addressing Mode –


In direct addressing mode, the data to be operated is available inside a
memory location and that memory location is directly specified as an
operand. The operand is directly available in the instruction itself.
Examples:
LDA 2050 (load the contents of memory location into accumulator A)
LHLD address (load contents of 16-bit memory location into H-L register
pair)
IN 35 (read the data from port whose address is 35)

4. Register Indirect Addressing Mode –


In register indirect addressing mode, the data to be operated is available
inside a memory location and that memory location is indirectly specified
by a register pair.
Examples:
MOV A, M (move the contents of the memory location pointed by the H-
L pair to the accumulator)
LDAX B (move contents of B-C register to the accumulator)
STAX B (store accumulator contents in memory pointed by register pair
B-C)

5. Implied/Implicit Addressing Mode –


In implied/implicit addressing mode the operand is hidden and the data to
be operated is available in the instruction itself.
Examples:
CMA (finds and stores the 1’s complement of the contents of accumulator
A in A)
RRC (rotate accumulator A right by one bit)
RLC (rotate accumulator A left by one bit)

6.Relative Addressing Mode:


In this mode, the operand is a memory location specified by the contents of the
program counter plus a constant value.

INSTRUCTION SET
An instruction set is a set of instructions that a microprocessor can understand. Instructions
are commands that tell the microprocessor what to do. The instruction set is defined by the
microprocessor's architecture.
The instruction set for a microprocessor is typically divided into several categories, such as:
 Data transfer instructions: These instructions move data between registers, memory,
and I/O devices.
 Arithmetic instructions: These instructions perform arithmetic operations on data,
such as addition, subtraction, multiplication, and division.
 Logical instructions: These instructions perform logical operations on data, such as
AND, OR, and XOR.
 Control flow instructions: These instructions change the flow of execution of a
program, such as jumps, calls, and returns.
The size and complexity of the instruction set varies depending on the microprocessor.
Some microprocessors have a small instruction set, while others have a large and complex
instruction set.
INSTRUCTIONS ANS DATA FORMAT
Instructions and data formats are two fundamental concepts in computer
architecture.

Instructions are the commands that tell a computer what to do. They are written in a
machine code language that is specific to the computer's processor. Instructions are
typically divided into two parts: the opcode and the operands. The opcode specifies
the operation to be performed, and the operands specify the data to be operated on.
Data formats are the ways in which data is represented in computer memory.
Common data formats include integers, floating-point numbers, characters, and
strings. Data formats are important because they determine how data can be
manipulated and used by computer programs.

The following table shows some examples of instructions and data formats:

Data
Instruction Description
format

ADD A, B Integer Adds the contents of register B to register A.

MOV A, 5 Integer Loads the value 5 into register A.

Compares the contents of register A to the contents of


CMP A, B Integer
register B.

Jumps to the instruction located at memory address


JMP 2000H Address
2000H.

Loads the contents of memory location 2000H into


LDA 2000H Address
register A.

Instructions and data formats are essential for understanding how computers work.
By understanding the different types of instructions and data formats, programmers
can write more efficient and reliable code.

Here are some additional details about instructions and data formats:
 Instructions can be simple or complex. Simple instructions, such as ADD A, B,
typically perform a single operation on two operands. Complex instructions,
such as MUL A, B, may perform multiple operations on multiple operands.

 Data formats can be simple or complex. Simple data formats, such as


integers and characters, can be represented using a small number of bits.
Complex data formats, such as floating-point numbers and strings, require
more bits to represent.

 The instruction set and data formats of a computer are determined by its
processor. Different processors have different instruction sets and data
formats.

 Programmers must use the correct instruction set and data formats when
writing programs for a particular computer. If a programmer uses the wrong
instruction set or data format, the program will not work correctly.

WRITING ASSEMBLING AND EXECUTING A PROGRAM

Writing, assembling, and executing a program involves the process of creating a


computer program in assembly language, translating it into machine code, and then
running it on a computer or microcontroller. Here are the key steps involved in this
process:

1. Writing the Program:


 First, you write the program in assembly language. Assembly language
is a low-level programming language that uses mnemonic instructions
and symbolic names for registers and memory locations. The program
is essentially a series of text instructions that correspond to the
operations you want the computer or microcontroller to perform.
2. Assembling the Program:
 Once you have written the program in assembly language, you need to
translate it into machine code, which is the binary representation of the
instructions that the computer's CPU can execute. This process is
called assembly or assembling.
 To assemble the program, you use an assembler, which is a software
tool specifically designed for this purpose. The assembler takes your
assembly code as input and generates a binary file containing the
machine code instructions.
3. Loading the Program:
 After assembling the program, you need to load it into the memory of
the computer or microcontroller where it will be executed. The method
of loading depends on the specific system you are using.
 In some systems, you may need to use a separate utility or hardware
programmer to load the program into non-volatile memory (e.g., a ROM
or flash memory). In other cases, you can simply copy the program to a
specific location in RAM.
4. Executing the Program:
 Once the program is loaded into memory, you can execute it by
triggering its start or entry point. The program will run on the computer
or microcontroller's CPU, and it will perform the operations specified in
your assembly code.
 During execution, the CPU fetches and executes each instruction in the
program sequentially, updating registers, performing arithmetic and
logic operations, and interacting with memory and I/O devices as
needed.

DEBUGGING THE PROGRAME

Debugging is the process of finding and removing errors, or bugs, in a program. The goal of
debugging is to identify and correct the root cause of an error. Debugging is an important part
of software engineering because bugs can cause a software system to malfunction.
The process of debugging involves:
 Identifying the bug

 Finding the source of the bug


 Correcting the problem
Debugging is a multistep process. When software doesn't work as expected, computer
programmers study the code to determine why any errors occurred. To launch an application
into the market, it is necessary to cross-check it multiple times so as to deliver an error-free
product.
STACK AND SUBROUTINES

In the 8085 microprocessor, the stack and subroutines play crucial roles in
organizing and controlling program execution. They are essential for managing the
flow of control and preserving the state of the program during subroutine calls and
returns. Here's an explanation of how stacks and subroutines work in the 8085
microprocessor:

1. Stack:
 The stack is a region of memory reserved for storing data temporarily during
program execution.
 In the 8085 microprocessor, the stack operates as a "Last-In, First-Out"
(LIFO) data structure, meaning that the most recently pushed data is the first
to be popped off the stack.
 The stack in the 8085 is typically implemented using a portion of memory
addresses, with a stack pointer (SP) register used to keep track of the current
top of the stack.
 Stack operations involve pushing data onto the stack and popping data off the
stack. The stack pointer is incremented or decremented accordingly.
 Instructions related to stack operations in the 8085 include PUSH, POP,
XTHL (Exchange Stack Pointer with HL), and SPHL (Load Stack Pointer from
HL).

2. Subroutines:

You might also like