INTRODUCTION TO MICRO COMPUTER AND MICROPROCESSOR Introduction

A Microprocessor is a multipurpose programmable logic device which reads the binary instructions from a storage device called ‘Memory’ , accepts binary data as input and process data according to the instructions and gives the results as output. So, you can understand the Microprocessor as a programmable digital device, which can be used for both data processing and control applications. In view of a computer student, it is the CPU of a Computer or heart of the computer. A computer which is built around a microprocessor is called a microcomputer. A microcomputer system consists of a CPU (microprocessor), memories (primary and secondary) and I/O devices as shown in the block diagram in Fig 1. The memory and I/O devices are linked by data and address (control) buses. The CPU communicates with only one peripheral at a time by enabling the peripheral by the control signal. For example to send data to the output device, the CPU places the device address on the address bus, data on the data bus and enables the output device. The other peripherals that are not enabled remain in high impedance state called tri-state.

Fig.1 Block diagram of a Microcomputer

Evolution of Microprocessors

1

The first Microprocessor (4004) was designed by Intel Corporation which was founded by Moore and Noyce in 1968. In the early years, Intel focused on developing semiconductor memories (DRAMs and EPROMs) for digital computers. In 1969, a Japanese Calculator manufacturer, Busicom approached Intel with a design for a small calculator which need 12 custom chips. Ted Hoff, an Intel Engineer thought that a general purpose logic device could replace the multiple components. This idea led to the development of the first so called microprocessor. So, Microprocessors started with a modest beginning of drivers for calculators. Fedrico Faggin and Stanely Mazor implemented the ideas of Ted Hoff’s and designed the Intel 4000 family of processors comprising 4001 (2K-ROM), the 4002 (320 bit RAM), the 4003 (10 bit I/O shift-register) and the 4004, a 4 bit CPU. Intel introduced the 4004 microprocessor to the world wide market on November 15, 1971. It was a 4-bit PMOS chip with 2300 transistors. Around the same time Texas Instruments developed a 4-bit microprocessor TMS 1000 and became the owner of microprocessor patent. Later Intel introduced world’s first 8 bit general purpose microprocessor 8008 in 1972. This processor was used in the popular computer ‘Mark-8’ in those days. In 1974, Intel introduced the improved version of 8008, the 8080 microprocessor. This 8080 is the much more highly integrated chip than its predecessors which is built around N-channel MOS technology. It could execute up to 290,000 operations per second and could address up to 64K.bytes of memory. The other notable 8 bit microprocessors include Motorola 6800, Rockwell PPS-8 and Signetics 2650 with powerful architecture and instruction set. With developments in integration technology Intel was able to integrate the additional chips like 8224 clock generator and the 8228 system controller along with 8080 microprocessor with in a single chip and released the 8 bit microprocessor 8085 in the year 1976. The 8085 microprocessor consisted of 6500 MOS transistors and could work at clock frequencies of 3-5 MHz. It works on a single +5 volts supply. The other improved 8 bit microprocessors include Motorola MC 6809, Zilog Z-80 and RCA COSMAC. In 1978, Intel introduced the 16 bit microprocessor 8086 and 8088 in 1979. IBM selected the Intel 8088 for their personal computer (IBM-PC).8086 microprocessor made up of 29,000 MOS transistors and could work at a clock speed of 5-10 MHz. It has a 16-bit ALU with 16-bit data bus and 20-bit address bus. It can address up to 1MB of address space. The pipelining concept was used for the first time to improve the speed of the processor. It had a pre-fetch queue of 6 instructions where in the instructions to be executed were fetched during the execution of an instruction. It means 8086 architecture supports parallel processing. The 8088 microprocessor is similar to 8086 processor in architecture ,but the basic difference is it has only 8-bit data bus even though the ALU is of 16-bit.It has a prefetch queue of 4-instructions only. In 1982 Intel released another 16-bit processor called 80186 designed by a team under the leadership of Dave Stamm. This is having higher reliability and faster operational speed but at a lower cost. It had a pre-fetch queue of 6-instructions and it is suitable for high volume applications such as computer workstations, word-processor and personal computers. It is made up of 134,000 MOS transistors and could work at clock rates of 4 and 6 MHz. This is also comes under first generation of Microprocessors. Intel released another 16 bit microprocessor 80286 having 1, 34,000 transistors in 1981. It was used as CPU in PC-ATs in 1982. It is the second generation microprocessor, more advanced to 80186 processor. It could run at clock speeds of 6 to 12.5 MHz .It has a 16bit data bus and 24-bit address bus, so that it can address up to 16MB of address space and 1GB of virtual memory. It had a pre-fetch queue of 6 instructions .Intel introduced the concept of protected mode and virtual mode to ensure proper operation. It also had onchip memory management unit (MMU) .This was popularly called as Intel 286 in those days.

2

In 1985, Intel released the first 32 bit processor 80386, with 275,000 transistors. It has 32bit data bus and 32-bit address bus so that it can address up to a total of 4GB memory also a virtual memory space of 64TB.It could process five million instructions per second and could work with all popular operating systems including Windows. It has a pre-fetch queue of length 16-bytes with extensive memory management capabilities. It is incorporated with a concept called paging in addition to segmentation technique. It uses a math co-processor called 80387. Intel introduced 80486 microprocessor with a built-in maths co-processor and with 1.2 million transistors. It could run at the clock speed of 50 MHz This is also a 32 bit processor but it is twice as fast as 80386.The additional features in 486 processor are the built-in Cache and built-in math co-processors. The address bus here is bidirectional because of presence of cache memory. On 19th October, 1992, Intel released the Pentium-I Processor with 3.1 million transistors. So, the Pentium began as fifth generation of the Intel x86 architecture. This Pentium was a backward compatible while offering new features. The revolutionary technology followed is that the CPU is able to execute two instruction at the same time. This is known as super scalar technology. The Pentium uses a 32-bit expansion bus, however the data bus is 64 bits. The 7.5 million transistors based chip, Intel Pentium II processor was released in 1997. It works at a clock speed of 300M.Hz. Pentium II uses the Dynamic Execution Technology which consists of three different facilities namely, Multiple branch prediction, Data flow analysis, and Speculative execution unit. Another important feature is a thermal sensor located on the mother board can monitor the die temperature of the processor. For thermal management applications. Intel Celeron Processors were introduced in the year 1999. Pentium-III processor with 9.5 million transistors was introduced in 1999. It also uses dynamic execution micro-architecture, a unique combination of multiple branch prediction, dataflow analysis and speculative execution. The Pentium III has improved MMX and processor serial number feature. The improved MMX enables advanced imaging, 3D streaming audio and video, and speech recognition for enhanced Internet facility. Pentium-IV with 42 million transistors and 1.5 GHz clock speed was released by Intel in November 2000. The Pentium 4 processor has a system bus with 3.2 G-bytes per second of bandwidth. This high bandwidth is a key reason for applications that stream data from memory. This bandwidth is achieved with 64 –bit wide bus capable of transferring data at a rate of 400 MHz. The Pentium 4 processor enables real-time MPEG2 video encoding and near real-time MPEG4 encoding, allowing efficient video editing and video conferencing. Intel with partner Hewlett-Packard developed the next generation 64-bit processor architecture called IA-64 .This first implementation was named Itanium. Itanium processor which is the first in a family of 64 bit products was introduced in the year 2001.The Itanium processor was specially designed to provide a very high level of parallel processing ,to enable high performance without requiring very high clock frequencies .Key strengths of the Itanium architecture include ,up to 6 instructions/cycle. The Itanium processor can handle up to 6 simultaneous 64 –bit instructions per clock cycle.

3

8085A can operate with a 3MHZ single phase clock and 8085A-2 version can operate at a maximum frequency of 5MHZ. Its clock cycle is 320 ns. The enhanced version of 8080 is the Intel 8085AH. This 8085 microprocessor is built with nearly 6200 transistors. Hence microprocessor is also known as the heart of the computer. and models based on the Arrandale dual-core mobile processor have been announced. While this allows twice the performance to a dual-core processors at the same clock frequency in ideal conditions. forming a quad-core processor. with approximately two times performance. This 8085 is an enhanced version of its predecessor the 8080A.The Itanium II is an IA-64 microprocessor developed jointly by Hewlett-Packard (HP) and Intel and released on July 8. The time for the clock cycle of Intel 8085 is 200 ns. The block diagram of 8085 microprocessor is shown in Fig 2. 8085A has an on-chip clock generator with external crystal. price and performance at a given clock frequency. In September.. 2010. generally speaking.2006. It is a 40 pin IC available as a DIP (Dual Inline Package) chip. Programs are stored in the memory. The CPU performs the various activities in response to a set of instructions called a program. 5MHZ and 6MHZ selections are available.It is theoretically capable of performing nearly 8 times more work per clock cycle than other CISC and RISC architectures due to its parallel computing micro-architecture. a 2 MB L2 cache shared by both cores. as it can deliver optimal performance (when over clocked) at a low price. It is an N channel depletion load. The first six-core processor in the Core lineup is the Gulftown. The Pentium Dual-Core was also a very popular choice for over clocking. It has 20% lower power consumption than 8085A for 3MHZ and 5MHZ. The first Itanium 2 processor (code named McKinley) was more powerful than the original Itanium processor. Core 2 Quad processors are multi-chip modules consisting of two dies similar to those used in Core 2 Duo. a microprocessor is nothing but the CPU . new Core i7 models based on the Lynnfield desktop quad-core processor and the Clarksfield quad-core mobile were added. So. Pentium 4EE was released by Intel in the year 2003 and Pentium 4E was released in the year 2004. Here 3MHZ. 2007. Intel Core Duo consists of two cores on one die. The recent Itanium processor features a split L2 cache. and an arbiter bus that controls both L2 cache and FSB access. Pentium Dual-Core processors were positioned above Celeron but below Core and Core 2 microprocessors in Intel's product range.5 MHZ. The CPU reads in data control signals (instructions) through the input ports and executes one instruction at a time. which becomes a dedicated data cache. which was launched on March 16. It is also 100% compatible with 8085A. The Pentium Dual-Core brand was used for mainstream X86-architecture microprocessors from Intel from 2006 to 2009 The 64 bit Intel Core2 was released on July 27. Both the regular Core i7 and the Extreme Edition are advertised as five stars in the Intel Processor Rating. adding a dedicated 1MB L2 cache for instructions and thereby effectively growing the original 256KBL2 cache. LC or RC network. The Pentium Dual Core. The 8085 CPU consists of three major sections. silicon gate (HMOS) 8-bit processor. Its instruction set is 100% software compatible with the 8085A. which consists of 167 million transistors was released on January 21. The Intel 8085 Microprocessor: Intel 8085A is a single chip 8-bit N-channel microprocessor which works at +5V DC power supply.2009. It has 80 basic instructions and 246 op-codes. Its instruction set is upward compatible with that of the 8080A. In terms of features. Central Processing Unit (CPU) The Central Processing Unit of any microcomputer is the microprocessor.The Intel 8085 CPU is an 8-bit device with a clock speed of 3 .2002. 4 . this is highly workload specific and requires applications to take advantage of the extra cores.

logical AND. many times the Accumulator register is treated as a default register.They are: (i). Most of the arithmetic and logic operations are performed using this accumulator.Accumulator (A).Registers (iii). incrementing and decrementing.Temporary register.Flag register. Certain instructions like DAA are performed using only accumulator. complementing. Arithmetic and logic unit (ALU) (ii). logical Exclusive OR. (b). (c). 5 . the data from an input device is read only through the accumulator. It is from the accumulator only. After performing the arithmetic operations the result is stored back in accumulator. So. subtraction. Similarly. rotate. No other register can be used for these operations. Arithmetic and logic unit (ALU) The ALU performs all the arithmetic and logical operations like addition. shift and clear. The data in the accumulator alone can be rotated or shifted. An ALU is made of many logic gates and adders etc. The arithmetic and logic unit consists of the following units (a).Timing and Control unit. the data is sent out to an output device. logical OR. One of the operands for arithmetic operations in ALU is from the accumulator. (a) Accumulator (A): It is an 8-bit register which is treated as a special function register. All the I/O data transfers between 8085 and I/O devices are performed via accumulator.

Figure 2 .The Block Diagram of 8085 Microprocessor (b) Temporary register: 6 .

Hence this flag register is also known as Status register. The final result is stored in the Accumulator and the flags are set or reset according to the result of the operation. if D7 is 1. if bit D7 of the result (Normally in the Accumulator) is 1. In arithmetic operations with signed numbers bit D7is reserved for indicating the sign and the remaining seven bits are used to denote the magnitude of the number. In arithmetic and logical operations. it contains only 5 flag bits and the remaining three bits are undefined as shown in Fig. For example the data byte 10111101 has even parity and the data byte 10011011 has odd parity. when a carry is generated by and passed on to bit 4 . the AC flag is set. Z . This Flag is used with signed numbers. AC – Auxiliary carry Flag In this arithmetic operation. CY-Carry flag After an arithmetic operation. this parity flag is set to 1 otherwise (if number of 1s is odd) the flag is reset (made0). this flag is set or reset based on the results in the accumulator as well as in the other registers. P-Parity Flag If the result after an arithmetic and logical operation has an even number of 1s. For example in ADD C instruction C register contents are moved to the Temp. Else (if it is zero). 7 .bit register which generally reflect data conditions in the accumulator with certain exceptions.Flag register: The flag register is an 8. For example when MVI M.3 In the Flag register each flag bit is a Flip-Flop. This register is used by the microprocessor to load the second operand during arithmetic/logical operations in ALU..For example in a given byte. subtraction if there exists a carry or barrow. So P bit=0.This is an 8-bit register which is not accessible to the user.3. Register and the addition of A and Temp.the accumulator provides one operand. This flag is used internally for BCD arithmetic and is not available for the programmer to change the sequence of a program with a jump instruction. IR register will receive the opcode for MVI M and the Temporary register will receive 17H. (c). the bit may be either in the flip state or flop state Figure 3. the sign flag is set. But the Z and CY flags can be used for this purpose. i. this flag CY is set to 1 else it is reset (made0) Example : Let us consider the addition of two binary numbers 11011001 and 11101101 and check the Flag register. the number is treated as a negative number. The other is provided by the temporary register. Though this flag register is an eight bit register. Register contents is performed by the ALU. and the flag is reset (made 0) if the result is not zero.Zero Flag This Flag is set (made 1) if the result after any arithmetic operation is zero. Flag Register S . like addition. that involves two operands . So.Sign Flag After execution of an arithmetic and logic operation. 17H instruction is fetched. it is viewed as a positive.e.

(ii) General purpose registers : 8 . The organization of 8085 registers is shown in Fig. 3. E.As these registers are internally used by the CPU. so.D7 D0 11011001 11101101 1 11000110 In the result. intermediate operations. So carry Flag is set (CY=1). the current Program counter (PC) contents are pushed on to the stack and the given address is loaded on to PC. during the execution of XCHG instruction. the no. H and L). So Z-Flag is reset (Z=0). They are used by the processor for internal. At the time of exchange W and Z registers are used for temporary storage of data. The given address is temporarily stored in W and Z registers and placed on the bus for the fetch cycle. the sum is not zero. Among these registers W and Z are not accessible to the user. So AC Flag is set (AC=1). It includes six .General purpose registers (iii). the contents of H-L pair are exchanged with D-E pair. So. C.Temporary registers. The temporary data register is associated with the ALU operations. Similarly W and Z are also temporary registers used to hold 8-bit data during execution of certain instructions. D. parity is even (P=1). they are not accessible to the user. there is a carry. Thus the program control is transferred to the address given in the instruction. W register and Z register. They are (i). (i) Temporary registers : The Temporary registers are temporary data registers.Special purpose registers. One of the operand is stored in this register. of 1s is even. After addition. When a CALL instruction is encountered in any program. This is not accessible to user. The W and Z registers are used by the processor during CALL instruction. All are 8bit registers. The Flag register contents after addition are shown below: D7 D0 Register Organization The 8085 microprocessor has different types of registers. The remaining registers are accessible to the user. one 8-bit Accumulator and two 16-bit registers (SP and PC). Another example is. Also there are two 8-bit temporary registers W and Z. (ii). The D7 bit=1.4 The various registers of 8085 are classified into three types. In the result. 8 – bit registers (B. the sign Flag is set (S=1). There is a carry from the third bit to fourth bit.

Parity and Carry as shown below Here X means undefined. D-E and H-L register pairs only as shown below.Now the H-L pair points to the location 8500 H. The five flags are Sign. It is mainly used for arithmetic. Accumulator (Register A): It is an 8-bit tri-state register.Each flag bit is a flip flop that indicates either a set or reset state. the result is stored in Accumulator after execution. This will load immediately the address of memory location (8500H) in to H-L pair .as their name indicates. D. Program Counter (PC) and Stack Pointer (SP). Zero. (iii) Special purpose registers: The Special purpose registers . These registers can be used as separate 8-bit registers and also can be paired as 16-bit registers to store the address of a memory location. Register organization When used as pair. 8500 H. E. But they must be paired as B-C. The H-L pair also functions as a data pointer or memory pointer For Ex: LXI H. are used for some specific purpose. the higher order byte moves to the first register (B) and the low order byte moves to the second register (C). 9 . load and store operations. logic. In most of operations. Which consists of only five flags. Flag Register: It is an 8-bit register. Instruction Register(IR). C. The Special purpose registers are Accumulator (A).B. Auxiliary carry. Figure 4. Flag Register. H and L are six. 8-bit general purpose registers to store data. for example B-C. It is also used in I/O operations.

it always points to top of the Stack. 10 . The Stack Pointer is initialized by load register pair immediate instruction. 8530 H Here 8530 H is the 16 bit address of the top of Stack location.Sign Flag: The sign flag is set to1 if the most significant bit of the result of an arithmetic or logic operations is 1. it is called Odd Parity and the Parity flag is set 0. Similarly when the Read operation (POP) occurs. which stores the address of the next instruction to be fetched or executed. Program Counter (PC): It is a 16-bit special purpose register. A stack works on Last in First out (LIFO) basis. This process is repeated till the last instruction of the program.G Auxiliary carry Flag: This flag is set if there is a carry from 3 rd bit to 4th bit during BCD operations (carry from lower nibble to higher nibble). The instruction register is a 8 – bit special register. After any arithmetic or logical operation. the contents of the stack pointer is decremented by two so that the SP points to the new location. Once the first instruction is executed. Stack is a part of the memory location used to store the data temporarily. the PC is automatically incremented to point to the next instruction unless a jump to some specific address occurs. The Decoder decodes the instruction and develops the sequence of events to follow. Ex: LXI SP. Otherwise. The execution of a program is initiated by loading the PC by the address of the first instruction of the program. In case of JUMP or CALL instructions.e. When a Write operation (PUSH) takes place. When an instruction is fetched from memory. it is loaded in the instruction register. only top of the Stack of the memory can be accessed. The processor then fetches the next instruction from the new address specified by the JUMP or CALL instruction. If there is odd number of 1s in the result. Parity Flag: Parity is defined by the number of 1s present in a binary number stored in A register. The instruction decoder decodes the instruction at a binary level and sends the appropriate signals to the control unit. the processor increments the Program Counter by three so that it points the instruction followed by the conditional JUMP or CALL instruction. The remaining blocks of 8085 microprocessor block diagram Instruction Register and Decoder: The instruction register and the decoder are also part of the ALU.e. As the Stack pointer always points to the top of the Stack. Stack Pointer (SP): It is a 16-bit special purpose register which always stores the address of top of the Stack. but it is not a programmable and is not accessible to the user. i. the Stack pointer is incremented by two to point to the next data on top of the Stack. if the condition is not satisfied. Else it is reset (0). current address is stored in the Program Counter. Zero Flag: The Zero status flag is set to 1 if the result of an arithmetic or logic operation is Zero For non-Zero result it is reset to 0. if the result has an even number of 1s it is called even parity and the Parity Flag is set to 1. In conditional JUMP and conditional CALL instructions. This flag is not accessible to the user. Otherwise the processor fetches the next instruction from the new address specified by JUMP or CALL instruction. i.

They are TRAP. their locations in the order of highest to lowest priority are given in Table 3. the microprocessor is interrupted when the input is both edge and level sensitive. The various interrupts. So. The address and data bus buffers are used to drive external address and data buses respectively. It is also used to tri-state the higher order address (A8-A15) bus under certain conditions like reset. RST 5. The TRAP is also a non maskable interrupt. They are TRAP. in a microprocessor the driving capacity of the address pins after the internal buffering may not be adequate. and halt and also when A/D bus lines are not in use. and halt and also when address lines are not in use. Serial I/O control: This control provides two lines SOD (Serial Out Data) and SID (serial In Data) for serial communication. RST 6. RST 7.Increment/ Decrement Address Latch: This is a 16 bit special register not accessible to the user. The numbers succeeding the RST (7. the microprocessor loads the program counter with 0024H. Address/Data Buffer: This is an 8-bit bi-directional buffer. 11 . The address bus AD 0-AD7 continues to be available on the bus after T1 state from this latch. Among all these interrupts TRAP has the highest priority and INTR (Interrupt Request) has the lowest priority.5) are related to the call locations.5. Interrupt control: This is an important block related to interrupts. the 8085 will always get interrupted even if the 8085 is in DI (Disable Interrupt) state. This interrupt control has five interrupt signals. Address Buffer: This is an 8-bit unidirectional buffer. The control block will take care of enabling and disabling of these interrupts etc… 8085 Interrupts: The 8085 microprocessor has five interrupts. It is used to drive external higher order address bus. and 5.5. Due to these buffers the address and data buffers can be tri-stated when they are not in use.5. Here RST means RESTART.When interrupted. RST5.5. there will be external buffer chips also available. hold. Trap input is both edge and level sensitive.1. It is also used to tri-state the multiplexed address/data bus under certain conditions like reset. RST 7. hold.state of op code fetch machine cycle (T1) the microprocessor increments the PC register contents to point to the next location. The 16 bit address that is sent out through AD0-AD7 and A8-A15 are latched into this register. Among these interrupts INTR is the only nonvector interrupt whereas the other interrupts are vectored interrupts.5 and INTR.5 and INTR.5.5. It means that whenever the pin is activated. During first T . These lines are used during serial data transmission over long distance where data is transmitted and received bit by bit. the microprocessor is interrupted when the input pulse goes from low to high or when it remains high . The Serial Output Data (SOD) pin is used to send data out serially and serial Input Data (SID) pin is used to receive data serially by the 8085 microprocessor. 6. So. It means low order address bus (A7-A0) and data bus (D7-D0). In actual practice. This register is used by the CPU to increment/ decrement the contents of the Stack Pointer (SP) and increment program counter (PC) during instruction execution. TRAP: It is a non maskable interrupt with highest priority. This block is linked to the CPU through the 8-bit internal data bus. This increment operation takes place on increment/ decrement register address latch. So. It is used to drive multiplexed address/data bus. RST 6.

interrupt. they are automatically transferred (vectored) to specific locations on memory page 00H without any external hardware.5 RST 5. This unit with the help of these signals controls the entire operation of the microprocessor and the peripherals. RST 6.5 x 8)H = 003CH (6. It generates three types of signals namely status.RST 7. But coming to INTR. During this time.5 RST 6. The mask on INTR can be removed by executing EI (Enable Interrupt) instruction. This flip flop is set 1. -Read (active low): This is a Read control signal.5 x 8)H = 0034H (5.5 and RST 5. S1 and S0 to identify the nature of the operation and one special signal ALE which indicates the starting of the operation. If the microprocessor is not able to respond to the requests immediately. The condition of these interrupts can be known using RIM (Read Interrupt Mask) instruction and the condition of the masking interrupt can be set and reset using SIM instruction (Set Interrupt Mask). the remaining operation is executed by the processor S. This signal indicates that the selected I/O or memory device is to be read and data are available on the data bus. These signals are explained below in detail. the flip flop associated with this is set and the mask is removed.5 is a maskable interrupt known as MI. The necessary hardware is already implemented inside the 8085. During this cycle.5 and INTR. control and timing signals required for the operation of memory and I/O devices. it means the triggering level should be on until the microprocessor completes the execution of the current instruction.5: It is an edge sensitive pin.N o 1 2 3 4 5 Interrupts TRAP (Highest priority) RST 7. The signal works as a signal during acknowledge machine cycle. INTR: It is only non-vectored interrupt in 8085 microprocessor. when a positive –going edge occurs on RST 7.5 input. Various Interrupts .5and RST 5. the microprocessor loads the code into instruction register from I/O device. This is a non-vectored interrupt because when the remaining interrupts are initialized.5 x 8)H = 002CH No location Table 1 . This is also a maskable interrupt and can be disabled using the instruction DI (Disable Interrupt). When EI instruction is executed. This interrupt is enabled under program control with two instructions EI (Enable Interrupt) and SIM (Set Interrupt Mask) RST 6. They do not require the signal. the device that has interrupted this microprocessor will provide the operation code.5 interrupt has a higher priority than RST 6. it executes interrupt acknowledge machine cycle.5.5 INTR (least priority) Call locations 0024H (7. and three status signals IO/ . This RST 7.Call locations in order of highest to lowest priority Timing and control Unit This unit of the microprocessor issues necessary timing and control signals for the execution of instructions. RST 5.5: These interrupts are level sensitive. they should be stored or held by external hardware. Based on the code. The signals associated with this unit are two control signals.5 interrupt pin . 12 . Internal to 8085 there is a flip-flop connected to RST 7.5 have higher priority than INTR interrupt. These two interrupts are also maskable interrupts. This interrupt has the lowest priority among all the interrupts. RST 7.

Write (active low): This is a Write control signal. 13 .. This signal indicates that the data on the data bus are to be written into a selected memory or I/O device.

This signal is combined with Read ( ) and Write to generate necessary I/O and memory control signals. It indicates that the bits on AD 7 . A bus is nothing but a group of electrical lines used to transmit the information as electrical signals.AD0 are address bits.2 . Status signals of 8085 IO/ : This is a status signal used to differentiate between I/O and memory operations. when it is low it denotes a memory operation.S. 14 . The various operations and the associated status signals are shown in Table 3. ALE (Address Latch Enable): This is a positive going pulse generated every time the 8085 begins an operation. Hence it is Uni-directional(because the converse is not possible). Data and Control Buses: Intel 8085 has 16-bit unidirectional address bus which carries the address of memories and peripheral devices. The width of the parallel bus determines how much memory that a microprocessor can address. When this signal is high. This signal is used primarily to latch the low-order address from the multiplexed bus and generate a set of eight address lines A7 – A0. The size of the address bus is independent of the size of the microprocessor. this 16-bit parallel address bus carries address from microprocessor to memories/peripherals. it indicates an I/O operation. used to identify various operations.The 8085 microprocessor with 16-bit address bus can address a maximum of 2 16= 65536=64 KB of memory locations. So. S1 and S0: These signals are also status signals like IO/ . Address. No 1 2 3 4 5 6 7 8 9 IO/ 0 0 1 1 1/0 1 * * * S1 0 1 0 1 1 1 0 X X S0 0 0 1 0 1 1 0 X X Status Memory Write Memory Read I/O Write I/O Read Opcode fetch Interrupt Acknowledge Halt Hold RESET Table 2. The complete operation of the microprocessor can be understood by these three signals.

The various pins of 8085 microprocessor can be grouped in the following categories Power Supply and Clock pins Data bus and Address bus Control and Status signals Interrupt signals DMA signals Serial I/O signals The description of various pins is given below. This is also a parallel bus. LC Network) is connected at these two pins. at some instances it acts as a 8. A microprocessor may also have certain additional control signals and such as interrupt signals. i. 15 . acknowledgement signals and hold signals. INTEL used this time multiplexing technique to save the pins. the crystal of the tuned circuit should have a frequency of 6MHZ. Thus. Similarly8086 is a 16-bit microprocessor and its data bus width is 16 bits INTEL 8085 has Address/ Data bus namely AD 7-AD0. A 0-A7 will always have the address during the first T state (T1) of the machine cycle. It means whether the microprocessor operation is a read or writes and whether it is memory or I/O operation. therefore to operate a system at 3MHZ. the A/D bus operates in a time shared mode. The above three buses that interface the CPU to the system components are combinedly known as the System bus. the lower order address lines are multiplexed with the data bus. When ALE=1 (high) the A/D bus acts as a lower order address bus else it acts as Data bus. Typical control signals are Read or Write signals. i.e. So. The size of the data bus determines the size of the microprocessor. i.e. This refers to the width of the data bus but not the address bus. But they are not considered as part of control bus even through they take part in control of microprocessor based systems. the INTEL’s 8-bit general purpose registers matches with its 8-bit data bus. The size of the control bus depends upon the specific microprocessor. The 8085 microprocessor has 8-bit data bus and hence it is called an 8bit microprocessor.In INTEL 8085 microprocessor. To demultiplexe the A/D bus the pin ALE is used. and address latch enables. the data and address are sent on the same lines but at different instants of time. The Data bus is a bidirectional bus which is used to send data to and from the microprocessor. The internal clock generator divides oscillator frequency by 2.bit address bus and at other instances it works as a 8-bit data bus. From the figure it is clear that it is 40 pin DIP chip. so that all the bits on the bus can at one time come into or go out of any of the registers. Generally the size of the internal general purpose registers matches the size of the data bus. Pin configuration The pin diagram of 8085 microprocessor is shown in Fig 5. the 8 most significant bits of the address are transmitted by the high order address bus A8-A15. But the 8 least significant bits of the addresses are transmitted by Address/Data bus or A/D bus.e. X1 and X2: A Crystal (or RC. In addition to this it includes state signals. The control bus of 8085 is a uni-directional bus because the microprocessor alone sends control signals to memories or peripheral devices. The size of the data bus matches the size of the internal registers. Power supply and clock pins: Vcc: +5V power supply Vss: Ground reference.

Control and Status Signals: ALE (Address Latch Enable): This is a positive going pulse generated every time the 8085 begins an operation. (Write): This is an active low write control pin. During the first part of the machine cycle (T1). which are bidirectional with dual purpose. It indicates that the data on the data on the data bus are to be are to be written into a selected memory or I/O location 16 . These lines are exclusively used for the most significant 8 bits of the 16 bits of the16 bit address bus.T3) these lines are used as a bidirectional data bus . This signal is mainly used to latch the low order address from the multiplexed bus and generate a separate set of eight address lines (A7-A0) (Read): This is an active low read control pin. The ALE=High indicates that the bits on AD7-AD0 are address bits. Its frequency is half the oscillator frequency Data bus and Address bus: AD0-AD7: These lines are Address/Data lines. During the remaining part of the machine cycle (T2. This signal indicates that the selected I/O or memory device is to be read and data are available on data bus. They are used as the low-order address bus as well as the data bus.CLK (OUT): This signal is used as a system clock for other devices. Pin Diagram of 8085 A A8-A0: These are the upper half of the 16 bit address lines. lower 8 bits of memory address or I/O address appear on the bus. Figure 5.

When it is high. RST 7. S1 and S0: These are status signals and they indicate the type of machine cycle in progress during execution of an instruction. The execution time is denoted by T-states. So. the system is in reset i.5 and INTR: These are the interrupt signals which are externally initiated. When the signal on this pin goes low. SOD: Serial output Data pin is used by the microprocessor to output data serially to the external devices. One Tstate is equal to the time period of the internal clock signal of the microprocessor 17 .5. Serial data is sent out of the microprocessor by executing SIM instruction. RST 7.e.5: It is a restart interrupt pin. the microprocessor will know whether peripheral device is ready or not for data transfer. It has higher priority than RST 6. A high on this pin indicates that.5. It has higher priority. RST 6. a peripheral like DMA controller is requesting the use of address and data buses. Interrupt signals: TRAP. it indicates an I/O operation and when it is low. the address & data buses are tristated.5 and INTR. this pin helps to synchronize slow devices to the microprocessor. INTR (Interrupt Request): This is used as a general purpose interrupt. RST5.IO/ : This is a status signal used to differentiate between IO and memory operations.5: These two are maskable vectored interrupt with higher priority than INTR. the program counter is set to zero. : It is an active low signal. This signal is combined with and signals to generate I/O and memory control signals. READY (Input): Through this pin. It is a maskable vectored interrupt. RST5. If the device is not ready the processor waits. TRAP: It is a non-maskable vectored interrupt. Serial input/ Output signals: SID: Serial input Data is a pin through which serial data are brought into the micro processor accumulator after the RIM instruction is executed. This will acknowledge the receival of interrupt request to the peripheral device.5. The most significant bit of accumulator should have the serial bit and D 6 bit of the accumulator must be made high to enable the serial data transfer. (Output): It is an active low interrupt acknowledge pin. it indicates a memory operation. RST 6. DMA Signals: Hold: This pin is used during the Direct Memory Access. Timing Diagram : The graphical representation of the time taken for the execution of each instruction by a microprocessor is known as timing diagram. It has a lowest priority and it is the only non-vectored interrupt. HLDA (Output): A high on this p in acknowledges the hold request from peripheral.5 and RST5. RESETOUT: This signal is used to Reset other devices in microprocessor system.

SPHL. One byte instructions which operate on 16-bit data are executed in T5 and T6 states. The opcode tells us what the operation is and the operand is the necessary information required for the instruction. RAL etc…. in 8085 microprocessor. The timing diagram for execution of MVI A. 8085 also sends status signals IO/ .C (80) is placed on the A8-A15 lines. DCRC. the microprocessor activates the ALE (Address Latch Enable) pin which is used to latch the low-order byte of the address in external latch before it vanishes. 25 machine cycle is shown in Fig 6 as shown in the timing diagram. In opcode fetch machine cycle status signals are IO/ =0. All the one byte instructions which operate on 8-bit data like MOV A. During this time the opcode is fetched from memory and returned on the data bus to the microprocessor. During T1-T3 states the address is placed on the address bus and the opcode is returned on the data bus.are executed T4 state. ADDB.states The first machine cycle is every instruction is the op-code fetch. (333 nano seconds nearly) As far as execution of instructions is concerned. The memory device then places the contents of the addressed memory location on the data bus (AD0-AD7) During T3 state. The 8085 machine cycles are divided into following six types.. They are Opcode fetch Memory read Memory write I/O read I/O write Interrupt acknowledge Opcode fetch Machine cycle: The first operation in every instruction is the opcode fetch. 5DCXH etc.For Ex: If the internal clock frequency of 8085 microprocessor is 3 MHZ.C(00) is placed on the AD0-AD7 line which stays only on only during T1. The opcode fetch cycle is called the M1 machine cycle and is usually for four T-states or clock cycles (certain instructions may also have 6T states in their opcode fetch machine cycle). The T4-state is used to decode and execute the opcode.333x10-6sec=333x10-9sec. The IO/ signal specifies whether the operation is read or write. Each instruction is divided into machine cycles and each machine cycle is divided into clock cycles or T. B. During T 1 state. So. The operand may be either data or an address or other information required for the instruction. M3------) that follow depend upon what the instruction actually is. the lower order address disappears from AD0-AD7 lines and 8085 sends signal low to enable the addressed memory location. each instruction is divided into two parts: The operation code (opcode) and the operand. The next machine cycles (M2. One T-state is equal to = =0. the 8085 places the contents of the program counter o n the address bus. the microprocessor loads the data from the data bus in its instruction register and raises to high which disables the memory device In T4 state. in T1 state. For example: INXH. The high order byte of the P. S1 =1 and S0=0 In T2 state. S1 and S0. the microprocessor decodes the opcode and based on the instruction it decides whether to T0 state T5 or to enter state T1of the next machine cycle (M2). The loworder byte of the P. 18 .

In the third read cycle. The third read cycle is needed to read the data located at the address previously retrieved. after the opcode fetch cycle. IO/ goes low at the beginning of the opcode fetch cycle and remains low during the next three cycles. This data is then loaded into accumulator. The timing diagram for memory read cycle [For Ex: LDA 2020H] is shown in Fig 7. . 19 . on the other hand goes low each time data on the data bus is to be read into the microprocessor. As shown in the memory read timing diagram. The first two cycles are to get the memory address. the address of the instruction just read from memory (2020H) is sent back over the address bus in T1 and then data from that memory location is returned over the data bus in T2-T3. the instruction LDA 8900H which is a 3-byte instruction has three memory read cycles immediately after the opcode fetch cycle. the first two read cycles have the address going out over the address bus first for the low-order of the address (2001H) and then for the high-order of the address(2002H). For example.Figure 6 Timing diagram for Opcode fetch Machine cycle Memory Read cycle: Memory read machine cycle is a machine cycle during which memory is read. in two 8-bit groups (the low-order part of the address and then the high-order address).

after fetching the opcode. This operation requires 7-T states for opcode fetch and three –T states for the memory write. Because. This instruction requires two machine cycles-an opcode fetch machine cycle followed by one write cycle.Figure 7. Timing diagram for Memory Read machine cycle Memory Write cycle: This memory write cycle is used when the microprocessor needs to send data out from accumulator or specific register and then write into the memory. As an example let us consider the instruction MOV M. A (50H). the instruction has to write the data in the accumulator out to memory at the address location in the H-L register. 20 .

shows the timing diagram of the instruction IN 80H. and have their usual meaning as shown in the timing diagram. The Fig 9. The opcode fetch cycle.A (50H) returning over the data bus. The remaining signals like ALE. a memory read cycle and an I/O read cycle.Timing diagram for Memory Write machine cycle The timing diagram of the instruction MOV A. The memory read cycle (M2) displays the address of the second byte of the instruction (8001H) going out over the address bus and the port address (80H) returning on the data bus. Here 80H is the port address of the device being read. The three machine cycles combinedly taken 10-states. there are three machine cycles. During the I/O read cycle. the port address of the device being read is sent over the address bus and the lower 8-bits carry the same 8-bit port address and the data from the input device is returned on the data bus during T2-T3. the address that was stored in the H-L pair goes out from the microprocessor during T 1 and data to be written from the accumulator goes out during T2-T3. During the write cycle (M2). The opcode fetch cycle shows the address [2000H] going out over the address bus and the opcode for the MOV M. 21 . The opcode fetch cycle shows the address of the instruction (2000H) going out over t he address bus and the opcode (DBH) for the IN instruction returning on the data bus.8. In the case of IN PORT. M is shown in Fig . I/O Read cycle: This I/O read cycle occurs when the microprocessor executes IN instruction and during the I/O read cycle. IO/ .Figure 8 . data is read in from an I/O device.

The second machine cycle shows the address of the second byte of the instruction (2001H) going out over the address bus with the port address (84H) returning over the data bus. From the timing diagram it is clear that. The Fig 10 Shows the timing diagram for OUT 04H instruction.Figure 9. The first one is opcode fetch cycle. In the third machine cycle the port address (84H) is sent out over both the upper and lower parts of the address bus. The out port instruction has three machine cycles. similar to I/O read cycle whenever the microprocessor addresses an I/O device. The OUT command writes the data stored in the accumulator over the data bus to the device whose port address was sent out over the address bus. It is also to be noted that the data in the accumulator is being written to the output device and goes out over the data bus during T2 -T3 states after the port address has been sent over the two parts of the address bus during T1 of the I/O write cycle 22 . 04H is the address of the output device The opcode fetch cycle sends the address of the instruction (2000H) over the address bus while the opcode (D3H) for the OUT instruction is returns on the data bus. The three machine cycle that forms the outport command has a total of ten T-states. Timing diagram for I/O Read machine cycle I/O write cycle: During this I/O write cycle DATA is written into I/O device specified by the port address from the accumulator. second one is memory read to get the port address and the third cycle is an I/O write cycle. the port address of the device being read is sent out over both the lower and higher order parts of the address bus.

The microprocessor fetches one instruction from the memory at a time & executes it. Another difference is. The time required to fetch an opcode (fetch cycle) is a fixed slot of time while the time required to execute an instruction (execute cycle) is variable which depends on the type of instruction to be executed. Program & data are stored in the memory. fetch and execute cycles Instruction cycle An instruction is a command given to the microprocessor to perform a specific operation on the given data. the interrupt acknowledge is six-T states whereas opcode fetch is only four T-states Instruction cycle. Sequence of instructions written for a processor to perform a particular task is called a program. It is same as an opcode fetch except that it 0sends out an signal instead of an signal and the status lines IO/ . S0 and S1 are 111 instead 011. It executes all the instructions of the program one by one to produce the final result.Figure 10 Timing diagram for I/O Write machine cycle Interrupt Acknowledge This Interrupt acknowledge machine cycle is a special machine cycle that is used in place of opcode fetch cycle in the RST (restart) instruction. Machine cycle. an instruction cycle is defined as the time required completing the execution of an instruction. An instruction cycle consists of a fetch cycle and an execute cycle. 23 . The necessary steps that a microprocessor carries out to fetch an instruction & necessary data from the memory & to execute it constitute an instruction cycle. In other words.

In case of a read cycle the quantity received from the memory are data or operand address instead of an op-code. The T-state is defined as one sub-division of the operation performed in one clock period. The other bytes are data or operand address. The entire operation of fetching an op-code takes three clock cycles. After receiving the data it performs execute operation. Instruction set of 8085 An Instruction is a command given to the microprocessor to perform a given task on specified data. 24 . Fetch operation: The first byte of an instruction is its op-code.Instruction cycle(IC) = Fetch cycle(FC) + Execute cycle(EC) This is shown diagrammatically in the Fig. which is the address of the memory location where op-code is available. In the 8085. Thus we see that in some cases an execute cycle may involve one or more read or write cycles or both. In the beginning of a fetch cycle the content of the program counter.In every machine cycle the first operation is op-code fetch and the remaining will be read or write from memory or IO devices. These sub-divisions are internal states synchronized with the system clock. In some instructions write operation is performed.11 Figure 11 Instruction cycle Machine cycle: Machine cycle is defined as the time required for completing the operation of accessing either memory or I/O device. The time taken for decoding and execution is one clock cycle. The program counter (PC) keeps the memory address of the next instruction to be executed. An instruction may be more than one byte long. Execute operation: The op-code fetched from the memory goes to the instruction register (IR). known as operand. The operand or data can be specified in various ways. the microprocessor has to perform some read operations to get the desired data. If an instruction contains data or operand and address which are still in the memory. The memory places the op-code on the data bus so as to transfer it to the microprocessor. A read cycle is similar to a fetch cycle. If the operand is in general purpose registers execution is immediately performed. Each instruction has two parts one is the task to be performed called the operation code (op-code) and the second is the data to be operated on. In write cycle data are sent from the microprocessor to the memory or an output device. the machine cycle may consist of three to six T states. is sent to the memory. execution begins. After the instruction is decoded.3. From the instruction register it goes to the decoder circuitry which decodes the instruction.

A signed integer is either a positive or a negative number. (b)Two byte instructions. But it is very difficult to understand these binary numbers by a common user. ADD B. BCD. MOV C. JMP 9567 4. 07 (two bytes) Hex code = 97. the largest number that can be processed at one time is FFH.LDA 8509 3. Ex: 1. An integer without a sign can be represented by all the 8-bits in a microprocessor register. 95 (Three bytes) Hex code = 32. 09 (two bytes) Hex code = 80. CLASSIFICATION OF INSTRUCTIONS 25 . One–byte instructions: An instruction with only opcode and do not require any dat or address is called a one byte instruction. In 8085 microprocessor the most significant bit D7 is used for the sign. 67. we have to code these binary numbers into different data formats. 35. The commonly known data formats are ASCII. (c) Three byte instructions. They are (a) One byte (single) instructions. SUB A. A 2. 07 3. 32 bits can be processed by dividing them in groups of 8-bits. English alphabets and certain special characters. So. Ex: 1. ADD B 3. 24. used for decimal numbers from 0-9. 09. The ASCII stands for ”American Standard code for Information Interchange” The term BCD stands for binary coded decimal.Instruction and data formats: The format of a typical instruction is composed of two parts: an operation code or op-code and an operand. 05 (two bytes) Three–byte instructions: A three byte instruction contains an opcode plus a 16 – bit address. 8509 2 . 09. 85 (Three bytes) Hex code = 3A. Ex: 1. So.LXI H.An 8bit register can store two BCD numbers. According to the word or byte size the 8085 instructions are classified into three types. Here 0 denotes positive sign and 1 denotes the negative sign. signed integers and unsigned integers. 05 Hex code = 3E. The numbers larger than 8-bits like 16. CMA Hex code = 4FH (one byte) Hex code = 80H (one byte) Hex code = 2FH (one byte) Two–byte instructions: At wo byte instruction is one which contains an 8-bit op-code and 8-bit operand (Data). MVI A. Every instruction needs an op-code to specify what the operation of the instruction is and then an operand that gives the appropriate data needed for that particular operation code. 85 (Three bytes) Hex code = C3. 25 (Three bytes) DATA FORMATS: The 8085 is an 8-bit microprocessor which process only binary numbers. 09 2. The ASCII code is a 7-bit alphanumeric code that represents decimal numbers. STA 3525 Hex code = 21.

C . LDA (Load Accumulator). The INR and DCR instructions affect all flags except the carry flag. Decrement the C register contents by one bit. the data transfer instruction performs basically ‘copy’ operation. The entire group of instructions. Logical Group of Instructions: 26 . STA (Store Accumulator). This instruction set includes all the 8080A instructions plus two additional instructions namely SIM and RIM. Move the data 55H into Accumulator MOV B. write data to an output port(01H is the port address) LXIH 8570H . Load H-L pair by address 8570H. SUB (Subtract). determines what functions the microprocessor can perform. from memory to register or register to memory but not from one memory location to another memory location. INR (Increment). MVI (Move Immediate). Arithmetic group Logic group Branch control group Machine control and I/O group. SHLD (Store H-L pair direct). . Data transfer (copy) instructions The data transfer instructions are used to transfer data from one register to another register. ADD. LXI (Load Immediate HL Pair). But. Copies the contents of ‘C’ register into ‘B’ register IN 00H . Actually this data transfer instruction copies the data from source to destination and the contents of the source are not altered.An instruction is a binary pattern designed inside a microprocessor to perform a specific function. Add the contents of B register to the B register contents . Arithmetic instructions modify all the flags according to the data conditions of the result. LHLD (Load H-L pair direct). C ADI 08 SUB A. The instruction set of 8085 microprocessor is classified into five groups. Arithmetic Instructions The arithmetic operations like addition. increment and decrement are performed by the 8085 microprocessor using the following arithmetic instructions. The 8085 microprocessor instruction set has 74 operation codes that result in 246 instructions. Add the data 08 to the accumulator. B SUI 05 INR B DCR C . subtraction.Subtract immediate the 8-bit data from accumulator . Ex:ADD B. data transfer instructions do not affect any flags. ADI (Add Immediate). Increment the B register contents by one bit . DCR (Decrement) etc… The arithmetic operations Add and subtract are performed in relation to the contents of the accumulator. Read the Input port(00H is the port address) OUT 01H . SUI (Subtract Immediate). called the instruction set. 55H . the increment or the decrement operations can be performed in any register. Subtract the contents of B register from accumulator. They are: Data transfer (copy) group. Examples of data transfer instructions are MOV. So. In the 8085 microprocessor. . XCHG (Exchange the contents of H-L pair with D-E pair) etc… Ex: MVI A.

Since the microprocessor is a programmable logic chip, it can be perform all the logic functions of the hard-wired logic through its instruction set. The 8085 processor can perform the logic instructions like, AND, OR, NOT (Complement) and X-OR (Exclusive OR) etc… The mnemonics of these instructions are given below. ANA : ANI : ORA : OR : XRA : XRI : CMA : Logically AND the contents of a register Logically AND immediate the 8-bit data. Logically OR the contents of a register. Logically OR immediate the 8-bit data. Exclusive-OR the contents of a register. Immediate Exclusive-OR the 8-bit data Complement the accumulator

All the logic operations are performed in relation to the contents of the accumulator. The CMA instruction does not affect any flags. The executions of the logical instruction do not affect the contents of the operand register. Branch Instructions These instructions are very important because they allow the microprocessor to change the sequence of a program either conditionally or unconditionally. The conditional branch instructions transfer the program to the specified label when certain condition is satisfied. The unconditional branch instructions transfer the program to the specified location unconditionally. We know that the microprocessor is a sequential machine. So, it executes machine codes from one memory location to the next. Branch instructions instruct the microprocessor to go to a different memory location and the processor continues executing machine codes from the new location. The address of the new locations either specified explicitly or provided by the microprocessor or some times by additional hardware. The Branch instructions are classified into three categories. They are (a). Jump instructions (b). Call and return instructions (c). Restart instructions. Jump instructions specify memory locations explicitly and they are 3-byte instructions. These Jump instructions are of two types. They are , Unconditional Jump and Conditional Jump. Unconditional Jump: This is similar to Unconditional Go to statement in BASIC. When this instruction is executed the 16-bit address available immediately in the instruction is loaded into the program counter , so that the next sequence of instruction execution starts from this location. This Unconditional Jump instruction enables the programmer to create continuous loops. JMP (16 bit address). So, this is a 3-byte instruction where the first byte is opcode and the second, third bytes specify memory address. For example, the instruction JMP 8500H, instructs the microprocessor to go to the memory location8500H unconditionally. Sometimes, the jump location is specified using a label also. Conditional Jump:

27

This instruction allows the microprocessor to make decision depending on certain conditions indicated by flags. The 8085 processor Jump instruction is associated with four flags. Namely Carry flag (CY), Zero flag (Z), Sign flag (S) and Parity flag (P). The following instructions shown in Table 3.3 transfer the program sequence to the memory location specified under the given conditions. S. No 1 2 3 4 5 6 7 8 Instruction JC (16 bit Addr) JNC (16 bit Addr) JZ (16 bit Addr) JNZ (16 bit Addr) JP (16 bit Addr) JM (16 bit Addr) JPE (16 bit Addr) JPO (16 bit Addr) Description Jump on carry (if CY=1) Jump on no carry (if CY=0) Jump on Zero (if Z=1) Jump on no Zero (if Z=0) Jump on plus (if D7=0; S=0) Jump on minus (if D7=1; S=1) Jump on Even Parity (if P=1) Jump on Odd Parity (if P=0)

Table 3 various conditional jump instructions To understand the instructions, let us consider the instruction JC (16 bit address). The meaning of this instruction is, the microprocessor is instructed to jump the specified 16 bit memory location if there exists a carry after the arithmetic operation else it will execute the next instruction in the sequence. CALL and RETURN Instructions The microprocessor uses the two instructions CALL and RETURN to implement subroutines. Here CALL instruction calls a subroutine program which is not a part of the main program and the RET instruction at the end of the subroutine program to return the control to the main program. Ex: CALL (16 bit memory address) RET RESET (RST) Instruction The 8085 processor provides eight RST instructions to transfer the program control to a specific location on page 00H. These instructions are 1-byte instructions. The various RST instructions and their call locations are given in the following Table 3.4 S. No 1 2 3 4 5 6 7 8 Mnemonics RST 0 RST1 RST2 RST3 RST4 RST5 RST6 RST7 Hex code C7 CF D7 DF E7 EF F7 FF Call location In Hex 0000 0008 0010 0018 0020 0028 0030 0038 28

Table 4 Various RST instructions and their call locations

29

RIM (Read Interrupt Mask): This instruction copies the status of the interrupts into the accumulator. It takes three machine cycles and takes 10 states. They are IN (port address) OUT (port address) This port address is an 8-bit address. The op-code is DBH. DI (Disable Interrupt): This is a one byte instruction which resets the interrupt enable flag to disable all the interrupts except TRAP. This instruction is used to enable the interrupts when the microprocessor is reset or the interrupt enable flag is reset after interrupt acknowledge. 30 . It is a one byte instruction whose opcode is 00H. The op-code is FBH. This instruction will copy the contents into the Accumulator through the port whose address is 01H. The op-code is F3H. The processor can be restarted by a valid interrupt or by applying a RESET signal. The microprocessor takes 5T states to implement the halt instruction. This NOP instruction is also very useful when we are required to insert a few instructions in the main program additionally . This is a dual purpose instruction. the microprocessor performs nothing. I/O instructions: There are two important instructions to input the data into the microprocessor’s accumulator through the input port and output the data from the accumulator to the output port. It is also used to read the serial data through the SID pin HLT (Halt): After execution of this instruction the microprocessor goes into the halt state.This instruction is normally used to generate very small time delays of the order of few micro seconds.Machine control and I/O Instructions There are six basic machine control instructions. They are EI (Enable Interrupt) DI (Disable Interrupt) NOP (No Operation) SIM (Set Interrupt Mask) RIM (Read Interrupt Mask) HLT (Halt) EI (Enable Interrupt): This is a one byte instruction used to enable the interrupt. This instruction takes one machine cycle with four states. Ex: (i) IN 01H. It takes one machine cycle with four states. SIM (Set Interrupt Mask): This instruction masks the interrupt as desired. Microprocessor spends four states doing nothing. The first purpose is to set or reset the mask of the maskable interrupt. NOP (No Operation): when this instruction is executed. In both these instructions the default register is Accumulator. The second purpose is to send the data out through the SOD pin at pin number 4 of the microprocessor.

DETAILED INSTRUCTION SET DATA TRANSFER INSTRUCTIONS 31 .(ii)OUT 02H. It is a two byte instruction which requires 10 states. This instruction sends the contents of Accumulator to the outport whose address is 02H. The op-code for this instruction is D3H.

32 .

ARITHMATIC INSTRUCTIONS 33 .

34 .

35 .

36 .

37 .

38 .

39 .

40 .

41 .

42 .

Move the data 08 H immediately to the accumulator (4).e. Load the contents of memory location into Accumulator. Add the contents of C register to the contents of B register. Immediate addressing mode (ii).5 – Reset RST7.5 is enabled D2=1 RST7. (2).it enables the serial output. Register addressing mode. the instruction will be of two bytes. (v).D1 and D0. Add immediate the data to the contents of the accumulator. This is a 3-byte instruction. the address of the operand (data) is available in the instruction itself. XXX – Don’t care condition R7.Bit D7 of accumulator is latched in to the SOD output line made available to serial peripheral if bit D6 =1 . Implicit addressing mode.If this bit =1 . (i). (3). SUB D. ADDRESSING MODES Majority of the instructions of 8085 microprocessor requires an operand (either data or address) on which the intended operation can be performed. is known as the register addressing mode. Register addressing modes: The mode. Register indirect addressing mode.5 flip-flop is reset . Store the contents of the Accumulator in the location 8000H (3).5 is masked or disabled M6. If the immediate data is 8-bit. 43 .If this bit is high .5 masked or disabled.RST 7.SOD – Serial output Data .5 MSE – Mask set Enable. Some instructions may require only one operand and some other instructions require two operands for its instruction execution. (iv).If this bit = 1 . Immediate Addressing mode: The mode of addressing in which the operand is a part of the instruction itself is known as Immediate Addressing mode. MVI 08H . The scheme involved in identifying the position of operands in an instruction is known as addressing mode.5 is enabled D1=1 RST 6. the instruction is of 3 bytes. SUI 05H . (2). STA 8000H .. M7.5 is enabled D0=1 RST 5. Move the contents of B register to A register.This is a master control over all the interrupt masking bits.This is an additional control to reset RST7. If the immediate data is 16 bit. The speed of execution mainly depends on the position of the operand in the instruction. SOE – Serial output enable.5.5 – D2=0 . Subtract immediately the data 05H from the accumulator (ii) Direct Addressing mode: The mode of addressing in which the 16-bit address of the operand is directly available in the instruction itself is called Direct Addressing mode. ADI DATA . Ex: (1). ADD B. There are five addressing modes 8085 processor.5 – D0=0 RST5. i. in which the operand is in one of the general purpose registers.LXIH 8500H : Load immediate the H-L pair with the operand 8500H (3). (2).They are (i).RST7. Ex: (1).5 is disabled or masked. C. MOV A.it enables the function of bits D2.5 – D1=0 RST6. (iii). M5. Read the data from port whose address is 01H. LDA 9525H . Direct addressing mode (iii). B. Subtract the contents of D register from Accumulator. Ex: (1). IN 01H .

The sum of the two numbers is 8-bits only. Set carry. : Add the contents of memory indicated by memory pointer to accumulator. Rotate Accumulator left by one bit (4). XX01). : Initialize H-L pair with memory address XX00 (say: 9000). Complement carry (3). the operand is automatically considered to be in the Accumulator. Step7. complement the contents of Accumulator (2). Ex: (1).e. : Increment memory pointer (i. Register indirect addressing modes: The 16-bit address location of the operand stored in a register pair (H-L) is given in the instruction. Rotate Accumulator right by one bit (5). : Clear accumulator. ASSEMBLY LANGUAGE PROGRAMMING EXAMPLES: Addition Programs Example 1: Addition of two 8-bit numbers whose sum is 8-bits. : Halt PROGRAM: 44 . The address of the operand is given in an indirect way with the help of a register pair.CMC.e. Step4. ALGORITHM: Step1. Step3. RLC. Move the contents of the memory location pointed by the H-L pair to accumulator (v). RRC.The necessary algorithm and flow charts are given below. is known as implicit addressing mode. LXIH 9570H . : Store the contents of accumulator in 9002. : Add contents of memory location M to accumulator. Load immediate the H-L pair with the address of the location 9570H MOV A. M . Explanation: This assembly language program adds two 8-bit numbers stored in two memory locations . Step5.CMA.. Implicit Addressing mode: The mode of instruction which do not specify the operand in the instruction but it is implicated. Hence it is called Register indirect addressing mode Ex: (1). STC. Step2. i. Step6.(iv).

00 A. The 2nd number is added to contents of accumulator The contents of accumulator are stored in memory location 9002. 9000 A. 45 . M 9002 Initialise memory pointer to point the first data location 9000.0 8003 8004 8005 8006 8007 8008 8009 800A 3E 00 86 23 86 32 02 90 Label Mnemonics OpOperand Comments LXI MVI ADD INX ADD STA H. Clear accumulator The first number is added to accumulator [A]  [A] + M Increment the memory pointer to next location of the Data. M H A.Address Hex of the me mo ry loc ati on 8000 21.

800B 76 HLT Stop the execution 46 .

Step4. 8501). : Increment memory pointer (i. Step3. : Add contents of memory location M to accumulator.e.Add these two numbers and check for carry.Ex: Input: Ex: (i) 9000 – 29 H 9001 – 16 H Result: Ex: (i) 9002 – 3F H Ex :(ii) 9000 –49 H 9001 –32 H Ex :( ii) 9002 – 7B Flow Chart Start Initialise H-L Pair with XX00 Clear Accumulator (00)  A Add contents of M to Accumulator # Increment memory pointer(XX01) # Add contents of M to A Copy the contents of Reg. Step5. ALGORITHM: Step1. 47 . Store the LSB of the sum in one memory location (8502) and the MSB (carry) in the other location(8503). Explanation: The first 8-bit number is stored in one memory location (say 8500) and the second 8-bit number is stored in the next location (8501). A to memory location XX02 Stop Fig 3. : Initialize H-L pair with memory address X (say: 8500). Step2. : Clear accumulator.18 Example 2: Addition of two 8-bit numbers whose sum is 16 bits. : Add the contents of memory indicated by memory pointer to accumulator.

Step6. Step8 : Store the Carry in 8503 location Step 9 : Halt Flow Chart Start Initialise H-L Pair with XX00 Clear Accumulator (00)  A Add contents of M to Accumulator # Increment memory pointer(XX01) & # Add contents of M to A Store the sum in the location xx02 Is Carry exists ? Yes No Store Zero in the XX03 location Store carry in the XX03 location Stop Fig 3. : Check for Carry Step 7 : Store the sum in 8502.19 48 .

PROGRAM: 49 .

C 8503 H Store the carry at 8503 location 50 . The 2nd number is added to contents of accumulator Is Carry exists ? No.00 A.go to the label FWD Make carry =1 The sum is stored in memory location 8502.Address Hex of the me mor y loca tion 8000 21. M FWD Comments Initialise memory pointer to point the first data location 9000. 8500 H A. FW INR STA C 8502 H MOV STA A.00 H A.00 8003 8004 8005 8006 8007 8008 8009 800A 800B 800C 800D 800E 800F 8010 8011 8012 8013 8014 3E 00 86 0E 00 23 86 32 0E 80 0C 32 02 85 79 32 03 85 Lab Mnemonics OpOperand c o d e LXI MVI ADD MVI INX ADD JNC H. Clear accumulator The first number is added to accumulator [A] [A]+M Initial value of Carry is 0 Increment the memory pointer to next location of the Data. M C.

8015 76 HLT Stop the execution 51 .

Step2. ALGORITHM: Step1. Explanation: Decimal addition of two 8-bit numbers is same as that of two 8-bit numbers program. Step4. : Initialize H-L pair with memory address XXXX (say: 8500). Step9: Store the Carry in XX03 location Step10: Halt Flow Chart Start Initialise H-L Pair with XX00 Clear Carry register (00) C Add contents of M to Accumulator # Increment memory pointer(XX01) & # Add contents of M to A Apply DAA instruction to convert Hex data to decimal form 52 . 8501). Except that the use of DAA instruction.Ex: Input: Ex : 8500 – 97 H 8501 – 98H RESULT: 8502 – 32 H 8503 -. Also check for carry. Step6. : Add the contents of memory indicated by memory pointer to accumulator. : Clear Carry register C.e. : Move contents of memory location M to accumulator.Add these two numbers and use the DAA instruction to get the result in decimal. Step3. The first 8-bit number is stored in one memory location (say 8500) and the second 8-bit number is stored in the next location(8501). Step5. Store the LSB of the sum in one memory location(8502) and the MSB (carry) in the other location(8503).01 H Example 3: Decimal addition of two 8-bit numbers whose sum is 16 bits. : Apply the instruction DAA(Decimal adjust after addition) Step7: Check for Carry Step8: Store the sum in XX02. : Increment memory pointer (i.

Store the sum in the location XX02 Is Carry Exists? Yes No Store Zero in the XX03 location Stores carry in the XX03 location Stop Fig . 00 Clear accumulator MOV INX ADD DAA JNC A.20 PROGRAM Address of the mem ory locat ion 8000 8003 8004 8005 8006 8007 8008 8009 Hex Label Mnemonics Comments OpOperand c o d e LXI H. C 8503 H 53 . Carry is moved to accumulator A Carry is stored in the location 8503 21. M H A. 0E 00 7E 23 86 27 D2 0D 80 0C 32 02 85 79 32 03 85 800C 800D 800E 800F 8010 8011 8012 8013 FWD INR STA C 8502 H MOV STA A. 8500 Initialise memory pointer to point H the first data location 9000. The 2nd number is added to contents of accumulator Is Carry exists? No. MVI C. M FWD The first number is added to accumulator [A] [A]+M Increment the memory pointer to next location of the Data. go to the label FWD Make carry =1 The contents of accumulator are stored in memory location 8502.

8014 76 HLT Stop the execution 54 .

Ex: Input: Ex : 8500 – 67 D 8501 – 85 D RESULT: 8502 – 52 D 8503 – 01 (Carry) Example 4: Addition of two 16-bit numbers whose sum is 16 bits or more Explanation: First 16-bit number is stored in two consecutive locations (Ex 8500 &8501) because in each location we can store only one 8-bit number. Step6: Halt Flow Chart Start Initialise H-L Pair with 8500 Load the first 16-bit number in to H-L Pair Exchange this number in to D-E pair Load the second 16-bit number in to H-L pair Add the LSB of Ist number to the LSB of the second number & MSB of the second number to MSB of the second number using DAD instruction 55 . Step4: Sum is stored in locations 8504 & 8505.Add the LSB of the first number to the LSB of the second number and the MSB of the first number to the MSB of the second number using the DAD instruction. Store the second 16-bit number in the next two consecutive locations (For Ex: 8502 &8503). Store the sum in the next two locations and the carry (if any) in the third location ALGORITHM: Step1: First 16 bit number is in locations 8500 & 8501 respectively Step2: Second 16-bit number is in locations 8502 & 8503 Step3: Add the two 16-bit numbers using DAD Instruction. Step5: Carry (if any) is stored in the location 8506.

Store the LSBs of the sum in 8504 & 8505 locations Is Carry Set? Yes No Store “0” in the location 8506 Store”1” in the 8506 location Stop Fig 21 PROGRAM: 56 .

85 00 85 EB 2A 02 85 0E 00 19 D2 0E 80 OC 22 04 85 79 32 06 85 8500 H First 16-bit number in H-L pair Exchange first number to D-E Pair 8502 H 00 D FWD C 8504 H A.00.Else go to the 800E LOCATION Increment carry Store the LSB of the Sum in 8504 & MSB in 8505 locations MSBs of the sum is in Accumulator Store the MSB (Carry) of the result in 8506 location FWD 57 .ADDRESS HEX – C O D E LABEL MNEMONIC COMMENTS OPCO D E LHLD XCHG LHLD MVI DAD JNC INR SHLD MOV STA OPERAND 8000 8001 8002 8003 8004 8005 8006 8007 8008 8009 800A 800B 800C 800D 800E 800F 8010 8011 8012 8013 8014 2A.C 8506 H MSB of the sum is initially 00 Add two 16 –bit numbers Is Carry? If yes go to the next line .

8015 76 HLT Stop execution 58 .

ALGORITHM: Step1. Step6.12 H LSB of the Ist Number 8501. Step5.13 H MSB of the Ist Number 8502 -13 H LSB of the IInd Number 8503 -12H MSB of the IInd number RESULT : 8504 . : Initialise H-L pair with the address of minuend. : Stop the execution Flow Chart Start Initialise H-L Pair with XX00 Move the contents of M to Accumulator Increment memory pointer(XX01) Subtract the subtrahend in memory location M from the minuend in A Store the result in the location XX02 Stop 59 . Subtraction Programs: Example 5: Subtraction of two 8-bit numbers without borrows. : Store the result in XX02.Use the SUB instruction and store the result in the XX02 location. : Move the minuend into accumulator Step3. The first 8-bit number is stored in XX00 memory location and the second 8-bit number is stored in the XX01 location . : Increment H-L pair Step4. : Subtract the subtrahend in memory location M from the minuend. except that we use the instruction SUB instead of ADD.25H LSB of the Sum 8505 – 25H MSB of the Sum 8506 -.Ex: INPUT: 8500.bit numbers.00 Carry . Explanation: It’s a simple program similar to addition of two 8. Step2.

M H M H M.Figure 22 PROGRAM: ADDRESS HEX C O D E 8000 8001 8002 8003 8004 8005 8006 8007 8008 21 00 85 7E 23 96 23 77 76 LABEL MNEMONIC OPCOD OPERAN E D LXI H.A [A]  [M] [M+1]  [M] A  [A] – [M] Next memory location Store the result in the location 8502 Stop the execution 60 . 8500 COMMENTS Initialise H-L pair and get the First number in to 8500 location MOV INX SUB INX MOV HLT A.

Step2.59H 8501. for decimal subtraction the number which is to be subtracted is converted to 10’s complement and then DAA is applied. : Add the first number to the 10’s complement of second number. : Store the result in XX02.INPUT: Ex : 8500. Explanation: In this program we can’t use the DAA instruction after SUB or SBB instruction because it is decimal adjust after addition only. So. Step5.30H Result: 8502 – 29H Example 6: Subtraction of two 8-bit Decimal numbers. : Stop the execution Flow Chart Start Initialise H-L Pair with XX01 and get the second number Find it’s 10’s complement Add first number to the 10’s complement of the second number Apply the DAA instruction to get decimal result Store the result in the location XX02 Stop Figure 23 61 . : Find its ten’s complement Step3. : Decrement the H-L pair for the first number (XX00) Step4. Step6. : Initialise H-L pair with the address of second number (XX01). ALGORITHM: Step1.

PROGRAM: 62 .

8500 Initialise H-L pair and get theSecond number in to 8501 location MVI SUB INR DCX ADD DAA STA A.ADDRESS HEX C O D E LAB MNEMONIC COMMENTS OPCODE OPERAND 8000 8001 8002 8003 8004 8005 8006 8007 8008 8009 800A 800B 800C 800D 21 00 85 3E 99 96 3C 2B 86 27 32 02 85 76 LXI H.99 M A H M [A]  99 9’s complement of second number 10’s complement of second number Address of the first number Add first number to 10’s complement of second number Store the result in the location 8502 Stop the execution 8502 HLT 63 .

: Store the borrow in location 8506 Step 7: Stop the execution Flow Chart Start Initialize H-L Pair with XX00 Load the first 16-bit number in to H-L Pair A Exchange this number in to D-E pair Load the second 16-bit number in to H-L pair Subtract LSB of 2 nd number from the LSB of the Ist number & MSB of the 2 nd number from MSB of the first number 64 .The result is stored in different locations. : Store the result in locations 8504 & 8505.Ex: Input: 8500 -76 D 8501. : Subtract the second number from the first number with borrow. : Store the second number in the locations 8502 &8503. Explanation: It is very similar to the addition of two 16-bit numers. : Store the first number in the locations 8500 & 8501. Step5. Step2. ALGORITHM: Step1.41 D Example 6: Subtraction of two 16 –bit numbers.35 D Result: 8502 .The first 16-bit number is stored in two consecutive locations and the second 16-bit number is stored in the next two consecutive locations. Step6. Step4.The lsbs are subtracted using SUB instruction and the MSBs aare subtracted using SBB instruction.Here we use SUB &SBB instructions to get the result .

Store the result in XX04 & XX05 locations Is borrow Set ? Yes No Store “0” in the location XX06 Store ”1” in the XX06 location No Stop Fig 24 PROGRAM: 65 .

E L L. When multiplicand is multiplied by 1 the product is equal to the multiplicand. Go to step 4 Step 8 : Store the product i.FF H MSB of the Ist Number 8502 -EE H LSB of the IInd Number 8503 –EE H MSB of the IInd number Multiplication Programs Example 7: Multiplication of two 8-bit numbers. Step 4 : Shift the multiplier left by one bit.register Get higher byte of the first number Subtract higher byte of second number with borrow Store the result in memory locations with LSB in 8504 & MSB in 8505 8502 H MOV SUB MOV MOV SBB MOV SHLD A.e. If the bit of the multiplier is 0 . Step 3 : Load the multiplier in Accumulator.11H LSB 8505 – 11 H MSB 8500. This process is done for all the 8-bits of the multiplier. A 8504 800D 80OE 80OF Ex: INPUT : 04 85 76 HLT Stop execution RESULT: 8504 . but when it is multiplied by zero. so that multiplicand is in D-E pair. the product is simply shifted left by one bit. Explanation: The multiplication of two binary numbers is done by successive addition.(say 8500) Step 2 : Exchange the H-L pair by D-E pair. Step 6 : Decrement the count. Step 7 : If count ≠ 0. A A. the product is zero.ADDRESS 8000 8003 8004 8005 8006 8007 8008 8009 800A 800A 800B 800C HEX 2A. D H H. Product is 16-bits. result in memory location. Step 5 : If there is carry add multiplicand to product.FF H LSB of the Ist Number 8501 . EB 2A 02 85 7B 95 6F 9C 67 22 LABE MNEMONIC OPCOD OPERAN E D LHLD 8500 H XCHG LHLD COMMENTS First 16-bit number in H-L pair Exchange first number to D-E Pair Get the second 16-bit number in H-L pair Get the lower byte of the First number in to Accumulator Subtract the lower byte of the second number Store the result in L.If the bit of the multiplier is 1 the multiplicand is added to the product and the product is shifted to left by one bit. ALGORITHM: Step 1 : Initialise H-L pair with the address of multiplicand. So. each bit of the multiplier is taken one by one and checked whether it is 1 or 0 . Step 9 : Stop the execution 66 .

Flow Chart Start Load the multiplier in to Accumulator & multiplicand in D-E pair Initial value of product=00. Count=08 Shift product left by one bit &Shift multiplier left by one bit No Is carry exists from multiplier ? Yes Product = Product + Multiplicand Count = count -1 No Is count =0? Yes Store result Stop Figure 25 67 .

PROGRAM: 68 .

0000 C. 8500 8502 H.ADDRESS HEX LABE MNEMONIC COMMENTS 8000 8003 8004 8005 8006 8007 8008 8009 800A 800B 800C 800D 800E 800F 8010 8011 8012 8013 8014 8015 8016 8017 8018 2A. Rotate multiplier left by one bit Is Multiplier bit =1? No go to label FWD Product =Product +Multiplicand COUNT=COUNT-1 FWD Store the result in the locations 8503 & 8504 69 .0 EB 3A 02 85 21 00 00 0E 08 29 17 D2 12 80 19 0D C2 0C 80 22 03 85 OPCOD E LHLD XCHG LDA LXI MVI LOO DAD RAL JNC DAD DCR JNZ SHLD OPERAND H.08 H FWD D C LOOP 8503 Load the multiplicand in to H-L pair Exchange the multiplicand in to D-E pair Multiplier in Accumulator Initial value in H-L pair is 00 Count =08 Shift the partial product left by one bit.

8019 76 HLT Stop the execution 70 .

INPUT : 71 .

Address 8500 8501 8502 Result: 8503 Data 8AH – LSB of Multiplicand 00 H – MSB of Multiplicand 52 H .Multiplier 34 H – LSB of Product 72 .

8504 2C H – MSB of Product 73 .

In the present example the dividend is a 16-bit number and the divisor is a 8-bit number. ALGORTHM: STEP1. STEP2.The vacancy arised due to shifting is occupied by the quotient . : If carry = 1 : goto step 8 else step7.For correct subtraction process the dividend is shifted left by one bit before each subtraction.The quotient is stored at 8503 and the remainder is stored at 8504 locations. 74 .bit number by a 8-bit number.Similarly the divisor is in the location 8502.Division Programs Example 7: Division of a 16. the bit of the quotient is set to 1 else 0. : Increment quotient register. The dividend is in locations 8500 &8501. STEP8. : If count not equal to zero go to step 4 STEP10: Store the quotient in 8503 STEP11: Store the remainder in 8504 STEP12: Stop execution. Explanation: The division of a 16/8-bit number by a 8-bit number follows the successive subtraction method. : Initialise H-L pair with address of dividend. The dividend and quotient are in a pair of register H-L.If a borrow occurs. The divisor is subtracted from the MSBs of the dividend .B STEP3. : Get the divisor from 8502 to register A & then to Reg. : Shift dividend and divisor left by one bit STEP 5: Subtract divisor from dividend. STEP7. : Decrement count in C STEP9. STEP6. : Make count C=08 STEP4.

26 75 . A Move the divisor in to Reg.Flowchart START Initialise H-L pair with address of dividend Copy the divisor in to Reg. B Move count =08 in to C register # Shift dividend left by one bit # Shift Quotient left by one No Is MSBs of Dividend > Divisor ? Yes Quotient = Quotient +1 8 MSBs of dividend = 8 MSBs of dividend -divisor Count = Count-1 No Is Coun t =0? Yes store th quotient in 8503 &remainder in 8504 Stop Fig.

H Increment quotient Decrement count If count is not zero jump to8009 location Store quotient in 8503 and remainder in 8504 locations Stop execution Ex: Input & Result Address 8500 8501 8502 8503 8504 Data 64  LSB of Dividend 00  MSB of Dividend 07  Divisor 0E  Quotient 02  Remainder 76 .A L C BACK 8503H COMMENTS 8000 8001 8002 8003 8004 8005 8006 8007 8008 8009 800A 800B 800C 800D 800E 800F 8010 8011 8012 8013 8014 8015 8016 8017 8018 Initialize the H-L pair for dividend Load the divisor from location 8502 to accumulator Move Divisor to Reg.goto label FWD MSB of the dividend in Reg. 8500 8502 H B.A C.H B FWD H.B from A Count =08 Shift dividend and quotient left by one bit MSB of dividend in to accumulator Subtract divisor from MSB bits of divisor Is MSB part of dividend > divisor ? No.PROGRAM: ADD HEX – LABEL C O D E 21 00 85 3A 02 85 47 0E 08 29 7C 90 DA 11 80 67 2C 0D C2 09 80 22 03 85 76 FWD MNEMONIC OPCOD OPERAN E D LHLD LDA MOV MVI BACK DAD MOV SUB JC MOV INR DCR JNZ SHLD HLT H.08 H A.

Largest & Smallest numbers in an Array Example 8: To find the largest number in a data array 77 .

The process is repeated until the count is zero. Step 8: Final result is stored in memory location. (8501…. Step 7. ALGORTHM: Step1: Store the count in the Memory location pointed by H-L register. Step2: Move the I st number of the data array in to accumulator Step3: Compare this with the second number in Memory location. Step 9: Stop the execution 78 .onwards).85XX. And the largest number is kept in the accumulator. Using the count. this process is completed . Now the third number in the memory location is again compared with the accumulator. The larger of the two is stored in Accumulator. until all the numbers are compared .Finally the accumulator stores the smallest number and this number is stored in the memory location.The first number is copied to Accumulator and it is compared with the second number in the memory location. Step4: The larger in the two is placed in Accumulator Step5: The number in Accumulator is compared with the next number in memory . Step 6: The larger number is stored in Accumulator.Explanation: To find the largest number in a data array of N numbers (say)first the count is placed in memory location (8500H) and the data are stored in consecutive locations.

Flow Chart START 79 .

Initialise H-L pair Get the count in Register C Get first number in Accumulator Yes Is Number in Accumulator> Next number ? No No Get Larger number in Accumulator Decrement Count No Is count = 0 ? Yes store the result in the location 85XX STOP Fig 27 80 .

PROGRAM 81 .

go to the loop2 If.ADD HEX 8000 8003 8004 8005 8006 8007 8008 8009 800A 800B 800C 800D 800E 800F 8011 8012 8013 8014 8015 – LABEL C O D E 21.M C LOOP1 STA 85XX Store the largest number in the location 85XX 82 .yes move the large number in to Accumulator Decrement the count If count not equal to zero.8 5 7E 23 4E 0D 91 BE D2 0D 80 7E 0D C2 07 80 78 32 XX 85 LOOP2 LOOP1 MNEMONIC OPCOD OPERAN E D LXI MOV INX MOV DCR INX CMP JNC H.M C H M LOOP2 COMMENTS INITIALISE H-L PAIR Count in the C register First number in H-L pair Move first number in to Accumulator Decrement the count Get the next number Compare the next number with previous number Is next number >previous maximum?No.repeat MOV DCR JNZ A.00.M H A. 8500 C.

N(Say N=7 ) 8501-05 8502-0A 8503-08 8504-14 8505 -7F 8506-25 8507-2D Stop the execution Result : 8508 .8016 76 HLT 8500.7F Ex : Input : 83 .

The first number is copied to Accumulator and it is compared with the second number in the memory location. ALGORTHM : Step1: Store the count in the Memory location pointed by H-L register.and the smallest number is kept in the accumulator. Step2: Move the I st number of the data array in to accumulator Step3: Compare this with the second number in Memory location.85XX.onwards). Explanation: To find the smallest number in a data array of N numbers (say)first the count is placed in memory location (8500H) and the data are stored in consecutive locations. The process is repeated until the count is zero. Step 7. Step 9: Stop the execution 84 .this process is completed until all the numbers are compared . Step 6: The smaller number is stored in Accumulator. Step 8: Final result is stored in memory location.Example 9 : To find the smallest number in a data array.The smaller of the two is stored in Accumulator. Step4: The smaller in the two is placed in Accumulator Step5: The number in Accumulator is compared with the next number in memory .Using the count.Now the third number in the memory location is again compared with the accumulator.Finally the accumulator stores the smallest number and this number is stored in the memory location. (8501….

Flow Chart 85 .

28 86 .START Initialise H-L pair Get the count in Register C Get first number in to Accumulator Yes Is Number in Accumulator< Next number ? No Get smaller number in Accumulator Decrement Count Is count = 0 ? No Yes store the result at 85xx STOP Fig.

PROGRAM 87 .

M C LOOP1 STA 85XX Store the smallest number in the location 85XX 88 . Count in the C register First number in H-L pair Move first number in to Accumulator Decrement the count Get the next number Compare the next number with previous number Is next number <previous smallest ?If yes go to the loop2 No.move the smaller number in to Accumulator Decrement the count If count not equal to zero. 8500 C.M H A.M C H M LOOP2 COMMENTS Initialise the H-L pair.ADD 8000 8001 8002 8003 8004 8005 8006 8007 8008 8009 800A 800B 800C 800D 800E 800F 8011 8012 8013 8014 8015 HEX – LABEL C O D E 21 00 85 7E 23 4E 0D 91 BE D2 0D 80 7E 0D C2 07 80 78 32 XX 85 LOOP2 LOOP1 MNEMONIC OPCOD OPERAN E D LXI MOV INX MOV DCR INX CMP JC H.repeat MOV DCR JNZ A.

. A special purpose register known as stack pointer (SP) points to the top of the stack. stack operations are also very fast The stack may also be used for storing local variables of subroutine and for the transfer of parameter addresses to a subroutine.2 Stack operation: Operations on stack are performed using the two instructions namely PUSH and POP. a block of RAM area is allocated to the stack. as the stack has no fixed address. Similarly if the POP operation is performed. In the first case. In this case the data do not move but SP is incremented or decremented as a result of push or pop operations respectively. the data written first can be accessed last. We can store data (PUSH) in it with out destroying previously stored data.29 89 . 3. The whole block of data moves up or down as a result of push and pop operations respectively. This facilitates the implementation of re-entrant subroutines which is a very important software property. The main advantage of the stack is that. One can put the data on the top of the stack by a special operation known as PUSH.1 Application of Stack: Stack provides a powerful data structure which has applications in many situations. it is difficult to debug and document a program that uses stack.3. i. Data can be read or taken out from the top of the stack by another special instruction known as POP. the data are taken out of the location pointed at by SP and SP is incremented by one.8016 76 HLT 8500 .14.e. This is not true in the case of other registers and memory locations. a set of registers is arranged in a shift register organization. In the second case. This is stored in the 16bit Stack pointer register as shown in Fig. The disadvantage is. Stack is implemented in two ways. The contents of the stack are moved to certain memory locations after PUSH instruction. the data are stored at the location pointed to by SP and it is decremented by one. 3. Whenever the stack is empty. Similarly.N((Say N=7) 8501-09 8502-0A 8503-08 8504-14 8505 -7F 8506-04 8507-2D Stop the execution Result : 8508 – 04 Ex: Input : Stack and Subroutines Stack is a set of memory locations in the Read/Write memory which is used for temporary storage of binary information during the execution of a program. It is implemented in the Last-in-first-out (LIFO) manner. For example let us consider a Stack whose stack top is 4506 H. If a PUSH operation is performed. the contents of the memory are transferred back to registers by POP instruction. One can PUSH or POP data from the top register. it points to the bottom address.14.

C 25 62 90 .29 The PUSH operation of the Stack Let us consider two registers (register pair) B & C whose contents are 25 & 62. B Reg.Figure. Reg.

32 explains before and after the POP operation in detail .30 After PUSH operation the status of the stack Let us now consider POP operation: The Figs 3. 91 .After PUSH operation the status of the Stack is as shown in Fig 3.31 & 3.30 Figure .

2565 H H CALL Comments Initialize Stack pointer . H Push the conten ts. . . .This is shown in Fig.Figure 3. .3. Memory Location 8000 8003 8006 8007 .32 Programming Example FOR PUSH & POP Write a program to initialize the stack pointer (SP) and store the contents of the register pair H-L on stack by using PUSH instruction. 92 . Use the contents of the register pair for delay counter and at the end of the delay retrieve the contents of H-L using POP. POP . . 8. .00A Label Mnemonics LXI LXI PUSH DELAY Operand SP.31 The POP operation of the Stack Figure 32 After POP operation the status of the stack Before the operation the data 15 and 1C are in the locations 4502 & 4503 and after the pop operation the data is copied to B-C pair and now the SP register points to 4504 location. . 4506 H H.

93 .

For example. it comes back to main program at 8021 H as shown in the following Fig. Diagrammatic representation Let us assume that the execution of the main program started at 8000 H. the entire program will become lengthy and complex. After executing this RET. So. Then the program execution transfers to 8070 H. which is the address of the instruction following the CALL instruction is stored on the stack and the program execution is transferred to the subroutine address. in any main program if these operations are needed more than once. At the end of the subroutine 807B H. They are CALL and RET. So. we can write a subroutine program called ‘delay’ and can be called any number of times we need Similarly. The CALL instruction is used in the main program to call a subroutine and RET instruction is used at the end of the subroutine to return to the main program. This can be done any number of times. we write subroutine programs MUL & DIV separately from main program and use the instruction CALL MUL (or) CALL DIV in the main program. in 8085 microprocessor we do not find the instructions for multiplication and division. the contents of the program counter.34 Fig.Subroutine: It is a set of instructions written separately from the main program to execute a function that occurs repeatedly in the main program. 3. The RET instruction is present. For this purpose we write separate programs.33 Diagrammatic representation of subroutine program execution 94 . let us assume that a delay is needed three times in a program. the memory address stored on the stack is retrieved and the sequence of execution is resumed in the main program. So. At the end of every subroutine program there must be an instruction called ‘RET’. The 8085 microprocessor has two instructions to implement the subroutines. When the RET instruction is executed at the end of the subroutine. It continues until a CALL subroutine instruction at 8020 H is encountered. This will take the control back to main program. Writing delay programs for three times in a main program is nothing but repetition. When a subroutine is called.

Mnemonics LXI Operand SP. (It is a three by Instruction) The address of the next instruction following CALL instruction. 8400 H Comments Initialize the Stack pointer at 8400 H Subroutine Program: Memory Address Mnemonics Operand Comments 95 . Program Example: Memory Address 8000 | | | 8020 8021 8022 8023 | | | 802F CALL Next instruction | | | HLT 8070 H Call a subroutine program stored at the location 8070 H. End of the main program .The same is explained using the assembly language program example.

8070 | | | | 807B 807C Instructions Beginning of the Subroutine. RET 807F 96 . RET Next Subroutine End of the program Instructions of next subroutine if any End of the subroutine.

a delay is needed between every two excitation signals applied to the motor. Hence it is called delay sub-routine program. The delay can be produced by either hardware chip like 8253 or by writing a software program using registers of the processor. we have constructed a display system where the LEDs receive the input from a microprocessor. the display can be visualized clearly. a register is loaded with a number and then decremented by using the instruction DCR until it becomes zero. Delay Subroutine with one register: Program 97 . The time of execution of the microprocessor is equal to the delay time produced. if you provide some delay between two input signals.Delay programs: In many situations it may be desired to provide some delay between the execution of two instructions by a microprocessor. Since the microprocessor is a very fast device it sends the signal at very high speeds there by our eye cannot recognize the display pattern. For small delays we can use only one register. The technique involved here is. This delay program is not a part of the main program. But for longer delays one has to use two or three registers. For example. So. Here we will discuss the software delay program. Similarly to observe the rotations of a stepper motor.

Has the content of register B becomes zero? No. 98 . FF A LOOP Comments Get FF in register A Decrement register A. Yes. proceed ahead.Address Label 9000 9002 9003 LOOP Machine code Mnemonics MVI DCR JNZ Operand A. jump to LOOP.

9006 RET Return to main program 99 .

The number of states required for the execution of each instruction is as follows: 100 .Calculation of Delay time for the above program: In the above program register A is loaded by FFH B(255 decimal) and it is decremented in a loop until it becomes zero. The delay produced by this program is as follows We should know the number of times each instruction of the above program is being executed.

Instructions MVI A. FFH (loop) DCR A JNZ loop States 7 4 7/10 101 .

RET 10 102 .

Total T States=3584 The time required for one T-state in INTEL 8085 microprocessor is nearly 330n.sec

Delay time is= 3584 x 333n.sec = 3.584 x 0.333 x 10-3 seconds = 1.18272 x 10-3 seconds = 1. 193472 milliseconds
Delay Subroutine with two registers Program:

103

Address Label 8400 8402 8404 8405 8408 8409 LOOP1 LOOP2

Machine Mnemonic Operand Comments Code MVI MVI DCR JNZ DCR JNZ B, 10H C, 56H C LOOP2 B LOOP1 Get desired number in register B Get desired number in register Decrement C. Is [C] zero? No, go to LOOP2. Yes, proceed further Decrement register B Is [B] zero? No, go to LOOP1. Yes, proceed further

104

840C

RET

Return to main program.

Delay Subroutine using register pair Program:

Addres s 8000

Label

Machin e Code

Mnemonic Operand LXI D, FFFF D A, D E LOOP

Comments Get FFFF in register pair D-E Decrement count Move the contents of register D to accumulator Check if D and E are zero. If D-E is not zero, jump to LOOP Return to main program

LOOP

DCX MOV ORA JNZ RET

Delay Subroutine using three registers Program:

105

From the above discussion it is clear that with increase of T-states required for a delay subroutine .the delay time also increases. 50H C. 98H 03 B. 01 01 Comments Get control word Initialize port foe LED Display Delay Subroutine registers with three Output for LED Stop. FFH D LOOP3 C LOOP2 B LOOP1 A. FFH D.Addres s 8400 8402 8404 8406 8408 840A 840B 840E 840F 8412 8413 8416 8418 8419 Label Machin e Code Mnemonic MVI OUT MVI MVI MVI DCR JNZ DCR JNZ DCR JNZ MVI OUT HLT Operand A. -----------------x------------------ 106 .

107 .

108 .

Sign up to vote on this title
UsefulNot useful