Practical Course File For

Similar documents
EXAMPLE PROGRAMS 8085

Assembly Language Programming of 8085

LIST OF PROGRAMS. Prg. Name of the Program. 1 Study of Pin Diagram of Study of Architecture of Study of 8085 Kit.

UNIT 1 REFERENCE 1 PREPARED BY S.RAVINDRAKUMAR, LECT/ECE, CHETTINAD COLLEGE OF ENGG AND TECH, KARUR

(2) Explain the addressing mode of OR What do you mean by addressing mode? Explain diff. addressing mode for 8085 with examples.

Assembly Language Programming of 8085

Introduction to Assembly Language Programming (Instruction Set) 1/18/2011 1

INSTRUCTION SET OF 8085


EXPERIMENT NO. 1 THE MKT 8085 MICROPROCESSOR TRAINER

8085 INSTRUCTION SET INSTRUCTION DETAILS

Subject Code: Model Answer Page No: /25

8085 Microprocessor Programs

MAHALAKSHMI ENGINEERING COLLEGE TIRUCHIRAPALLI

MSMF GATE CENTRE. Sub: MICROPROCESSORS. Time: 50min Date: Marks:33

Its Assembly language programming

Delhi Noida Bhopal Hyderabad Jaipur Lucknow Indore Pune Bhubaneswar Kolkata Patna Web: Ph:

INDEX. 1 Study of intel 8085 micropeocessor kit. 2 Program to find addition of two 8 bit no. 3 Program to find subtraction of two 8 bit no.

Assembly language Programming

Delhi Noida Bhopal Hyderabad Jaipur Lucknow Indore Pune Bhubaneswar Kolkata Patna Web: Ph:

GATE Exercises on Microprocessors

INSTITUTE OF ENGINEERING AND MANAGEMENT, KOLKATA Microprocessor

SIR C.R.REDDY COLLEGE OF ENGINEERING ELURU DIGITAL ELECTRONICS & MICROPROCESSOR LAB MANUAL 2/4 CSE: II- SEMESTER

MAHALAKSHMI ENGINEERING COLLEGE TIRUCHIRAPALLI UNIT I THE 8085 & 8086 MICROPROCESSORS. PART A (2 Marks)

EC2304-MICROPROCESSOR AND MICROCONROLLERS 2 marks questions and answers UNIT-I

ELECTRICAL ENGINEERING

Architecture & Instruction set of 8085 Microprocessor and 8051 Micro Controller

SAMPLE STUDY MATERIAL

CS2259-MICROPROCESSOR AND MICROCONTROLLER LABORATORY MANUAL

Programming of 8085 microprocessor and 8051 micro controller Study material

Instruction set of 8085

SIR.C.R.R.COLLEGE OF ENGINEERING DEPT. OF ELECTRONICS AND INSTRUMENTATION ENGG. EIE-328: MICROPROCESSOR LABORATORY 3/4 B.E. EIE: SECOND SEMESTER

LABORATORY MANUAL. PROGRAMME: B.Tech SEMESTER /YEAR: 3rd year 5th Semester SUBJECT CODE: CS592 SUBJECT NAME: Microprocessor & Microcontroller Lab

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION (Autonomous) (ISO/IEC Certified) MODEL ANSWER

The due date for submitting this assignment has passed. 1) How many times will the following loop be executed? Depends on the initial value of A

EKT222 Miroprocessor Systems Lab 5


MGM S Jawaharlal Nehru Engineering College

Valliammai Engineering College

8051 Overview and Instruction Set

EXPERIMENT-1 AIM: Familiarization of different keys of 8085 microprocessor kit and its memory map. APPARATUS: 8085 kit. DIAGRAM:

S.R.M. INSTITUTE OF SCIENCE & TECHNOLOGY SCHOOL OF ELECTRONICS & COMMUNICATION ENGINEERING

Delhi Noida Bhopal Hyderabad Jaipur Lucknow Indore Pune Bhubaneswar Kolkata Patna Web: Ph:

UNIT I. Differences between: Microcomputer, Microprocessor and Microcontroller

1-Operand instruction types 1 INC/ DEC/ NOT/NEG R/M. 2 PUSH/ POP R16/M16/SR/F 2 x ( ) = 74 opcodes 3 MUL/ IMUL/ DIV/ DIV R/M

م.م. ماجد عيدان. Introduction to microprocessor and microcomputer

PERIPHERAL INTERFACING Rev. 1.0

Microprocessor Micro Syllabus BSc. CSIT, IOST, TU. Microprocessor

XII HSC - BOARD - MARCH

Computer Organization

Unit 1 8 BIT MICROPROCESSOR ARCHITECTURE

Micro Processor & Micro Controllers

Microcontroller Intel [Instruction Set]

COPYRIGHT IS NOT RESERVED BY AUTHORS. AUTHORS ARE NOT RESPONSIBLE FOR ANY LEGAL ISSUES ARISING OUT OF ANY COPYRIGHT DEMANDS

Control Unit: The control unit provides the necessary timing and control Microprocessor resembles a CPU exactly.

1. What is Microprocessor? Give the power supply & clock frequency of 8085?

CHAPTER ASSEMBLY LANGUAGE PROGRAMMING

Microprocessors 1. The 8051 Instruction Set. Microprocessors 1 1. Msc. Ivan A. Escobar Broitman

The advantages of registers over memory locations are as follows:

Counters & Time Delays. Microprocessors & Interfacing 1

Syllabus for Bachelor of Technology. Computer Engineering. Subject Code: 01CE0501. Subject Name: Microprocessor Fundamentals & Programming

(2½ Hours) [Total Marks: 75]

Matrix Multiplication in 8085

1. INTRODUCTION TO MICROPROCESSOR AND MICROCOMPUTER ARCHITECTURE:

EE309: Computer Organization, Architecture and MicroProcessors. sumantra/courses/up/up.html GND HIGH ORDER ADDRESS BUS

ROEVER ENGINEERING COLLEGE

AE66/AC66/AT66/ AE108/AC108/AT108 MICROPROCESSORS & MICROCONTROLLERS

ET2640 Microprocessors

PERIPHERAL INTERFACING Rev. 1.0

MICROPROCESSOR BASICS AND RELATED TERMS

1. What is microprocessor? It is a program controlled semi conductor device (IC), which fetches, decodes and execute instructions.

ENE 334 Microprocessors

ET355 Microprocessors Thursday 6:00 pm 10:20 pm

Vidyalankar T.E. Sem. V [EXTC] Microprocessors and Microcontrollers I Prelim Question Paper Solution V SS (GND)

Memory organization Programming model - Program status word - register banks - Addressing modes - instruction set Programming examples.

LABORATORY 1 INTRODUCTION TO 8085 MICROPROCESSOR DEVELOPMENT SYSTEM BOARD

SN8F5000 Family Instruction Set

1. Internal Architecture of 8085 Microprocessor

UNIT 2 THE 8051 INSTRUCTION SET AND PROGRAMMING

DHANALAKSHMI COLLEGE OF ENGINEERING DEPARTMENT OF ELECTRICAL AND ELECTRONICS ENGINEERING YEAR : III SEM : VI

G. Pullaiah College of Engineering and Technology: Kurnool Department Of Electronics and Communication Engineering

Q. P. Code : b. Draw and explain the block dig of a computer with microprocessor as CPU.

VALLIAMMAI ENGINEERING COLLEGE

Arithmetic and Logic Instructions And Programs

BHARATHIDASAN ENGINEERING COLLEGE. III Year / V Semester / EEE MICROPROCESSORS AND MICROCONTROLLERS (R-2013)

Microprocessor and Microcontroller question bank. 1 Distinguish between microprocessor and microcontroller.

Microcontroller. Instruction set of 8051

EC 333 Microprocessor and Interfacing Techniques (3+1)


Lecture-12 INTERNAL ARCHITECTURE OF INTEL 8085: The Functional Block Diagram Of 8085 Is Shown In Fig 16.

Arithmetic Instructions

INSTRUCTOR: ABDULMUTTALIB A. H. ALDOURI

The 8085 Instruction Set

QUESTION BANK CS2252 MICROPROCESSOR AND MICROCONTROLLERS


Week /8086 Microprocessor Programming I

B.C.A 2017 MICROPROCESSOR AND ASSEMBLY LANGUAGE MODULE SPECIFICATION SHEET. Course Outline

CC411: Introduction To Microprocessors

Mnem. Meaning Format Operation Flags affected ADD Addition ADD D,S (D) (S)+(D) (CF) Carry ADC Add with ADC D,C (D) (S)+(D)+(CF) O,S,Z,A,P,C

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING LAB MANUAL. Academic Year: ODD SEMESTER

Transcription:

Practical Course File For Microprocessor (IT 473) B.Tech (IT) IV-SEM Department of IT University Institute of Engineering & Technology Panjab University, Chandigarh Page 1

INTRODUCTION... 4 EXPERIMENT-1: Introduction to Microprocessor Trainer Kit... 7 EXPERIMENT-2 : 1 s complement of an 8-bit number... 12 EXPERIMENT-3: 2 s complement of an 8-bit number.... 14 EXPERIMENT-4: 1 s complement of 16-bit number.... 16 EXPERIMENT-5: 2 s complement of 16-bit number.... 18 EXPERIMENT-6: Shift left 8-bit number by 1 bit... 20 EXPERIMENT-7: Shift right 8-bit number by 1 bit.... 22 EXPERIMENT-8: Mask the lower nibble of an 8-bit number.... 24 EXPERIMENT-9: Mask the higher nibble of an 8-bit number.... 26 EXPERIMENT-10: Add two 8-bit numbers without considering the carry... 28 EXPERIMENT-11: Add two 8-bit numbers along with considering the carry.... 30 EXPERIMENT-12: Subtract two 8-bit numbers without considering borrow... 33 EXPERIMENT-13: Subtract two 8-bit numbers along with considering the borrow.... 35 EXPERIMENT-14: Add two 16-bit numbers without considering the carry... 38 EXPERIMENT-15: Subtract two 16-bit numbers without considering borrow... 40 EXPERIMENT-16: Add two 8-bit numbers and show the result in decimal number system.... 43 Page 2

EXPERIMENT-17: Multiply two 8-bit numbers.... 46 EXPERIMENT-18: Find square of an 8-bit number.... 49 EXPERIMENT-19: Larger of two 8-bit numbers.... 52 EXPERIMENT-20: Smaller of two 8-bit numbers... 55 EXPERIMENT-21: Addition of ten 8-bit numbers stored in memory.... 58 EXPERIMENT-22: Find no. of negative elements in a block of data... 59 EXPERIMENT-23 : To sort numbers... 60 EXPERIMENT-24 : Alter the contents of flag register in 8085... 62 EXPERIMENT-25 : Calculate the sum of series of numbers... 63 EXPERIMENT-26 : Division of 16 bit number by 8 bit number... 65 EXPERIMENT-27 : Find the number of negative elements... 67 EXPERIMENT-28 : Find the largest of given numbers... 69 EXPERIMENT-29:Count number of l's in the contents of a register... 70 EXPERIMENT-30: Transfer contents to overlapping memory blocks... 72 Appendix -1 : OPCODES TABLE OF INTEL 8085 in Alphabetical order... 73 Page 3

INTRODUCTION Microprocessor 8085 Prac Course File In all Experimental Laboratory, student will follow following procedural steps : Step 1: Analyzing/Defining the Problem: The first step in writing a program is to think very carefully about the problem that you want the program to solve. In other words, ask yourself many times, what do I really want this program to do? It is good idea to write down exactly what you want the program to do and the order in which you want the program to do it. At this point student should not write down program statements, should write the operations in general terms. Step 2: Designing the solution/representing Program Operations: The formula or sequence of operations used to solve a programming problem is often called the algorithm of the program. Draw flowchart or use pseudo code to represent program which you want to write to solve your problem. In EXPERIMENT it is better to use flowchart. Step 3: Implementing the Solution 3.1 Define your Constant, Variables & Pointers for the program. 3.2 Finding the right instruction: After student prepare flowchart of a program, the next step is to determine the instruction statements required to do each part of the program. Student has to remember the complete instruction set for 8085.Each statement in flow chart could be implemented using one or more instructions. Standard program format for assembly language program : Student should finally write the program in following format : Memory Address Label Mnemonics Label Hex Code Comments 2100 start : MVI A, 55 3E, 55H ; Acc=55 3.3 Constructing the machine codes from 8085 instructions: Student will refer the table and manually convert its assembly language program into machine code. Page 4

Step 4: Loading/Running the solution: Student will use trainer kit to load his machine code program in RAM and run his program. Student will use debugging tools availed in EXPERIMENT kit to find out the software bugs in the program. Step 5: Testing the Solution Test the solution by observing the content of various registers and memory addresses. This is the standard procedure for all experiments, hence not required to write separate procedure for all experiments. The list of experiments is attached. Example: Move a block of 8-bit numbers from one place to other place. Data(H): 37, A2, F2, 82, 57, 5A, 7F, DA, E5, 8B, A7, C2, B8, 10, 19, 98 Step 1: By analyzing the problem statement, you require following things. i) Block size (How many number of 8-bit numbers you want to move) ii) Source Memory Pointer iii) Destination Memory Pointer Step 2: Designing the solution/representing Program Operations. (Flow Chart for block transfer) Step 3: Implementing the Solution 3.1 Define your Constant, Variables & Pointers 3.2 Finding the right instruction: LXI H, XX50 LXI D, XX70 MVI B,10 NEXT: MOV A,M STAX D INX H INX D Set HL pointer for source memory Set DE pointer for destination memory Set B as a byte counter Get data from source memory Store data in destination memory Get ready for next byte Page 5

DCR B JNZ NEXT Go back to next byte if counter is not equal to 0 3.3 Constructing the machine codes from 8085 instructions: Page 6

EXPERIMENT-1: Introduction to Microprocessor Trainer Kit AIM: Introduction to Microprocessor Trainer Kit Tools / Apparatus: 8085 microprocessor trainer kit Study of HEX Keypad: Study the functions of the following Keys: SAVE: This command is used to save the contents of specified block on to a audio cassette for permanent storage. LOAD: This command is opposite to save command. The contents of audio cassette block is loaded (retrieved back) in the system RAM from a given DS (file name) CODE: When this command key is pressed the address field remains blank, Data field shows a dot indicating that it expects a code. User is provided with a table of codes, indicating the meaning and Prerequisites of each code. User loads the appropriate code and executes it by pressing EXEC. The monitor branches to the appropriate sub-routines pointed by the code. STEP: Mere running a program with RUN is done whenever the program development is complete i.e. to run a final working program. During the program development stage some sort of aid to execute the part of program at a time and then test its success is required. The STEP command helps you to do the above. There are two ways of stepping the program. Page 7

SINGLE STEPPING: to execute single instruction at a time, using STEP command. The STEP command requires a start address, break address and the no.of times the br should occur. BREAK POINT: set a software breakpoint RST1. This software breakpoint can be done using the RUN command. It requires RST1 (CFH) to be inserted to a location where you want to break. The disadvantage of this method is that you have to insert and remove 'CF' and you have to operate in the RAM area only. VI: This key causes immediate recognition of RST 7.5 interrupt and control passes to location 003C in the monitor. This location has a jump to location 20CE in user RAM. You can put any instruction or jump in 20CE to 20D0 - Interrupts must be enabled (EI) instruction. - RST 7.5 must be unmasked (mask reset by SIM instruction) RUN: This command is used to execute your programs or subroutines from a Specified address. EXEC: Pressing EXEC will place the data field contents into the named register and terminate the command. REG: This command allows you to display and optionally modify the contents of 8085 CPU registers. The various registers are A, B, C, D, E, F, I, H, L, SPH, SPL, PCH, PCL. (H higher byte, L lower byte) RES: On RES, the display shows MP 85 as a sign on message, indicating that the monitor is ready to accept a command. Pressing any non-command key generates Err message. After - Err user can immediately give a valid command. SET: It is used to SET the address of a required memory location. A dot in the address field of display indicated that the entry will be displayed in the address field. INC: Pressing INC, first time will shift the dot to the data field of display. Data field will show the contents of the memory location pointed by the address set. One can modify or retain the data field to any value. DEC: DEC acts as similar to INC, except the address field is decremented, pointing to previous memory locations. SPH: Stack pointer Register (Higher byte) SPL: Stack pointer Register (Lower byte) Page 8

PCH: Program Counter Register (Higher byte) PCL: Program Counter Register (Lower byte) 0 F: Hex Keypad H,L: Registers H & L Study of following Devices: 1. IC 8251 (Programmable Synchronous and asynchronous serial data transmitter) 2. IC 8253 (Programmable interval Timer /Counter) 3. IC 8255 (Programmable Parallel IO Device) 4. IC 8279 (Keyboard Display Interface) 5. IC 6264 (RAM) 6. IC 2764 (EPROM) 7. ADC 8. DAC 9. IC 8085 (Microprocessor) Study of Memory Address Space: ROM :0000 1FFF RAM :2000 3FFF Memory Address Space Used by Firmware Program: 2000 20FF Students should not use this address range for their program or do not modify the content of these locations. Memory is expandable to 64K Bytes by interfacing appropriate RAM IC in the empty sockets. Crystal Frequency: Crystal Frequency = 6.144 MHz Study of Onboard Interfaces: The kit has following onboard Interfaces: Page 9

- Parallel I/O using 8255 - Serial I/O using 8251/8253 - Keyboard/Display using 8279 - ADC/DAC using 8255 / Latch -373 Microprocessor 8085 Prac Course File Study of Interrupts: The Kit uses following interrupts - RST 7.5 - VI - RST 5.5-8279 - NMI - Counter 0 output - RST 6.5 - Used to implement Single Step - INTR - Used to implement Single Step Pin Diagram of 8085: Page 10

How to run/execute the program on kits SI-Single step execution. (stop). (stop) GO (means run) Enter the beginning address of prog SI Enter the beginning address of prog Press next, next, next till the end of prog.(stop running) Examine mem/reg.(stop running) Examine mem/reg Page 11

EXPERIMENT-2 : 1 s complement of an 8-bit number AIM: WAP to find 1 s complement of an 8-bit number. Explanation: This program finds the 1 s complement of an 8-bit number stored in memory location 3000H. Page 12

Let us assume that the operand stored at memory location 3000H is 85H. The operand is moved to accumulator from memory location 3000H. Then, its complement is found by using CMA instruction. The result is stored at memory location 3001H. Output: Before Execution: 3000H: 85H After Execution: 3001H: 7AH Page 13

EXPERIMENT-3: 2 s complement of an 8-bit number. AIM: WAP to find 2 s complement of an 8-bit number. Page 14

Explanation: This program finds the 2 s complement of an 8-bit number stored in memory location 3000H. Let us assume that the operand stored at memory location 3000H is 85H. The operand is moved to accumulator from memory location 3000H. Then, its complement is found by using CMA instruction. One is added to accumulator by incrementing it to find its 2 s complement. The result is stored at memory location 3001H. Output: Before Execution: 3000H: 85H After Execution: 3001H: 7BH Page 15

EXPERIMENT-4: 1 s complement of 16-bit number. AIM: WAP to find 1 s complement of 16-bit number. Page 16

Explanation: This program finds the 1 s complement of 16-bit number stored in memory 3000H-3001H. There is no direct way to find 1 s complement of 16-bit number. Therefore, this can be accomplished by finding the 1 s complement of two 8-bit numbers. Let us assume that the operand stored at memory locations 3000H-3001H is 45H-6AH. The operand is loaded into H-L pair from memory locations 3000H-3001H. The lower-order is moved from register L to accumulator. Its complement is found by using CMA instruction. The result obtained is moved back to register L. Then, the higher-order is moved from register H to accumulator. Its complement is found by using CMA instruction. The result obtained is moved back to register H. Now, the final result is in H-L pair. The result is stored from H-L pair to memory locations 3002H-3003H. Output: Before Execution: After Execution: 3000H: 45H 3002H: BAH 3001H: 6AH 3003H: 95H Page 17

EXPERIMENT-5: 2 s complement of 16-bit number. AIM: WAP to find 2 s complement of 16-bit number. Page 18

Explanation: This program finds the 2 s complement of 16-bit number stored in memory locations 3000H- 3001H. There is no direct way to find 2 s complement of 16-bit number. Therefore, this can be accomplished by finding the 1 s complement of two 8-bit numbers and then incrementing it to get 2 s complement. Let us assume that the operand stored at memory locations 3000H-3001H is 12H-05H. The operand is loaded into H-L pair from memory locations 3000H-3001H. The lower-order is moved from register L to accumulator. Its complement is found by using CMA instruction. The result obtained is moved back to register L. Then, the higher-order is moved from register H to accumulator. Its complement is found by using CMA instruction. The result obtained is moved back to register H. H-L pair is incremented to get 2 s complement. Now, the final result is in H-L pair. The result is stored from H-L pair to memory locations 3002H-3003H. Output: Before Execution: After Execution: 3000H: 12H 3002H: EEH 3001H: 05H 3003H: FAH Page 19

EXPERIMENT-6: Shift left 8-bit number by 1 bit AIM: WAP to Shift left 8-bit number by 1 bit. Explanation: This program performs the left shift operation on an 8-bit number by one bit stored in memory location 3000H. Let us assume that the operand stored at memory location 3000H is 05H. The operand is moved to accumulator from memory location 3000H. Page 20

Then, shift left operation is done by using RAL instruction. The result is stored at memory location 3001H. Output: Before Execution: 3000H: 05H After Execution: 3001H: 0AH Page 21

EXPERIMENT-7: Shift right 8-bit number by 1 bit. AIM: WAP to Shift right 8-bit number by 1 bit. Page 22

Explanation: This program performs the right shift operation on an 8-bit number by one bit stored in memory location 3000H. Let us assume that the operand stored at memory location 3000H is 04H. The operand is moved to accumulator from memory location 3000H. Then, shift right operation is done by using RAR instruction. The result is stored at memory location 3001H. Output: Before Execution: 3000H: 04H After Execution: 3001H: 02H Page 23

EXPERIMENT-8: Mask the lower nibble of an 8-bit number. AIM: WAP to mask the lower nibble of an 8-bit number. Explanation: Page 24

This program masks the lower nibble of an 8-bit number stored in memory location 3000H. Let us assume that the operand stored at memory location 3000H is 45H. The operand is moved to accumulator from memory location 3000H. Then, AND operation of F0H is performed with accumulator. This results in the masking of lower nibble. The result is stored at memory location 3001H. Output: Before Execution: 3000H: 45H After Execution: 3001H: 40H Page 25

EXPERIMENT-9: Mask the higher nibble of an 8-bit number. AIM: WAP to mask the higher nibble of an 8-bit number. Page 26

Explanation: This program masks the higher nibble of an 8-bit number stored in memory location 3000H. Let us assume that the operand stored at memory location 3000H is 45H. The operand is moved to accumulator from memory location 3000H. Then, AND operation of 0FH is performed with accumulator. This results in the masking of higher nibble. The result is stored at memory location 3001H. Output: Before Execution: 3000H: 45H After Execution: 3001H: 05H Page 27

EXPERIMENT-10: Add two 8-bit numbers without considering the carry. AIM: WAP to add two 8-bit numbers without considering the carry Page 28

Explanation: This program adds two operands stored in memory location 3000H and 3001H, without considering the carry produced (if any). Let us assume that the operands stored at memory location 3000H is 04H and 3001H is 02H. Initially, H-L pair is loaded with the address of first memory location. The first operand is moved to accumulator from memory location 3000H and H-L pair is incremented to point to next memory location. The second operand is moved to register B from memory location 3001H. The two operands are added and the result is stored in accumulator. H-L pair is again incremented and the result is moved from accumulator to memory location 3002H. Output: Before Execution: 3000H: 04H 3001H: 02H After Execution: 3002H: 06H Page 29

EXPERIMENT-11: Add two 8-bit numbers along with considering the carry. AIM: WAP to add two 8-bit numbers along with considering the carry. Page 30

Explanation: This program adds two operands stored in memory location 3000H and 3001H, along with considering the carry produced (if any). Let us assume that the operands stored at memory location 3000H is FAH and 3001H is 28H. Initially, H-L pair is loaded with the address of first memory location. The first operand is moved to accumulator from memory location 3000H and H-L pair is incremented to point to next memory location. The second operand is moved to register B from memory location 3001H. Register C is initialized to 00H. It stores the carry (if any). The two operands stored in register A and B are added and the result is stored in accumulator. Then, carry flag is checked for carry. If there is a carry, C register is incremented. H-L pair is incremented and the result is moved from accumulator to memory 3002H. H-L pair is again incremented and carry (either 0 or 1) is moved from register C to memory Page 31

location 3003H Output: Before Execution: 3000H: FAH 3001H: 28H After Execution: 3002H: 22H 3003H: 01H Page 32

EXPERIMENT-12: Subtract two 8-bit numbers without considering borrow. AIM: WAP to subtract two 8-bit numbers without considering borrow. Page 33

Explanation: This program subtracts two operands stored in memory location 3000H and 3001H, without considering the borrow taken (if any). Let us assume that the operands stored at memory location 3000H is 05H and 3001H is 02H. Initially, H-L pair is loaded with the address of first memory location. The first operand is moved to accumulator from memory location 3000H and H-L pair is incremented to point to next memory location. The second operand is moved to register B from memory location 3001H. The two operands are subtracted and the result is stored in accumulator. H-L pair is again incremented and the result is moved from accumulator to memory location 3002H. Output: Before Execution: 3000H: 05H 3001H: 02H After Execution: 3002H: 03H Page 34

EXPERIMENT-13: Subtract two 8-bit numbers along with considering the borrow. AIM: WAP to Subtract two 8-bit numbers by considering the borrow Page 35

Explanation: This program subtracts two operands stored in memory location 3000H and 3001H, along with considering the borrow taken (if any). Let us assume that the operands stored at memory location 3000H is 05H and 3001H is 02H. Initially, H-L pair is loaded with the address of first memory location. The first operand is moved to accumulator from memory location 3000H and H-L pair is incremented to point to next memory location. The second operand is moved to register B from memory location 3001H. Register C is initialized to 00H. It stores the borrow (if any). The two operands stored in register A and B are subtracted and the result is stored in accumulator. Then, carry flag is checked for borrow. If there is a borrow, C register is incremented. H-L pair is incremented and the result is moved from accumulator to memory location Page 36

3002H. H-L pair is again incremented and borrow (either 0 or 1) is moved from register C to memory location 3003H. Output: Before Execution: 3000H: 05H 3001H: 02H After Execution: 3002H: 03H 3003H: 00H Page 37

EXPERIMENT-14: Add two 16-bit numbers without considering the carry. AIM: WAP to add two 16-bit numbers without considering the carry. Page 38

Explanation: This program adds two 16-bit operands stored in memory locations 3000H-3001H and 3002H-3003H, without considering the carry produced (if any). Let us assume that the operands stored at memory locations 3000H-3001H is 02H-04H and 3002H-3003H is 04H-03H. The H-L pair is loaded with the first 16-bit operand 0204H from memory locations 3000H- 3001H. Then, the first 16-bit operand is moved to D-E pair. The second 16-bit operand 0403H is loaded to H-L pair from memory locations 3002H- 3003H. The two operands are added and the result is stored in H-L pair. The result is stored from H-L pair to memory locations 3004H-3005H. Output: Before Execution: After Execution: 3000H: 02H 3004H: 06H 3001H: 04H 3005H: 07H 3002H: 04H 3003H: 03H Page 39

EXPERIMENT-15: Subtract two 16-bit numbers without considering borrow. AIM: WAP to subtract two 16-bit numbers without considering borrow. Page 40

Explanation: This program subtracts two 16-bit operands stored in memory locations 3000H-3001H and 3002H-3003H, without considering the borrow taken (if any). Let us assume that the operands stored at memory locations 3000H-3001H is 08H-06H and 3002H-3003H is 05H-04H. The H-L pair is loaded with the first 16-bit operand 0806H from memory locations 3000H- 3001H. Then, the first 16-bit operand is moved to D-E pair. The second 16-bit operand 0504H is loaded to H-L pair from memory locations 3002H- 3003H. Page 41

The lower-order of first number is moved from register E to accumulator. The lower-order of 2nd number in register L is subtracted from lower-order of 1st number in accumulator. The result of subtraction is moved from accumulator to register L. Then, the higher-order of 1st number is moved from register D to accumulator. The higher-order of 2nd number in register H is subtracted from higher-order of first number in accumulator, along with the borrow from the previous subtraction. The result of subtraction is moved from accumulator to register H. Now, the final result is in H-L pair. The result is stored from H-L pair to memory locations 3004H-3005H. Output: Before Execution: After Execution: 3000H: 08H 3004H: 03H 3001H: 06H 3005H: 02H 3002H: 05H 3003H: 04H Page 42

EXPERIMENT-16: Add two 8-bit numbers and show the result in decimal number system. AIM: WAP to add two 8-bit numbers and show the result in decimal number system. Page 43

Explanation: This program adds two operands stored in memory location 3000H and 3001H, and shows the result in decimal number system. Let us assume that the operands stored at memory location 3000H is 08H and 3001H is 05H. After addition, instead of showing the result in hexadecimal as 0DH, it shows the result in decimal as 13. Initially, H-L pair is loaded with the address of first memory location. The first operand is moved to accumulator from memory location 3000H and H-L pair is incremented to point to next memory location. The second operand is moved to register B from memory location 3001H. Register C is initialized to 00H. It stores the carry (if any). The two operands stored in register A and B are added and the result is stored in accumulator. Page 44

The result is converted to decimal by using the DAA instruction. Then, carry flag is checked for carry. If there is a carry, C register is incremented. H-L pair is incremented and the result is moved from accumulator to memory location 3002H. H-L pair is again incremented and carry (either 0 or 1) is moved from register C to memory location 3003H. Output: Before Execution: 3000H: 08H 3001H: 05H After Execution: 3002H: 13 3003H: 00H Page 45

EXPERIMENT-17: Multiply two 8-bit numbers. AIM: WAP to multiply two 8-bit numbers. Page 46

Explanation: This program multiplies two operands stored in memory location 3000H and 3001H, using successive addition method. In successive addition method, the second operand is considered as counter, and the first number is added with itself until counter decrements to zero. Let us assume that the operands stored at memory location 3000H is 02H and 3001H is 05H. Then, by using successive addition method, we get 02H + 02H + 02H + 02H + 02H = 0AH. Initially, H-L pair is loaded with the address of first memory location. The first operand is moved to register B from memory location 3000H and H-L pair is incremented to point to next memory location. The second operand is moved to register C from memory location 3001H to act as counter. Accumulator is initialized to 00H. Register B is added with accumulator and the result is stored in accumulator. Register C (counter) is decremented by 1. Page 47

Then, counter is checked for zero. If it hasn t become zero yet, then register B is again added with accumulator, and counter is again checked for zero. If counter becomes zero, then H-L pair is incremented and the result is moved from accumulator to memory location 3002H. Output: Before Execution: 3000H: 02H 3001H: 05H After Execution: 3002H: 0AH Page 48

EXPERIMENT-18: Find square of an 8-bit number. AIM: WAP to find square of an 8-bit number Page 49

Explanation: This program finds the square of an 8-bit number stored in memory location 3000H. The square of a number is found by multiplying it by itself. Therefore, the number is added with itself and is also used as counter. Let us assume that the operands stored at memory location 3000H is 03H. Then, by using successive addition method, we get 03H + 03H + 03H = 09H. Initially, H-L pair is loaded with the address of the operand. The operand is moved to register B from memory location 3000H and then it is copied to register C. Accumulator is initialized to 00H. Register B is added with accumulator and the result is stored in accumulator. Register C (counter) is decremented by 1. Then, counter is checked for zero. If it hasn t become zero yet, then register B is again added Page 50

with accumulator, and counter is again checked for zero. If counter becomes zero, then H-L pair is incremented and the result is moved from accumulator to memory location 3001H. Output: Before Execution: 3000H: 03H After Execution: 3001H: 09H Page 51

EXPERIMENT-19: Larger of two 8-bit numbers. AIM: WAP to find larger of two 8-bit numbers. Page 52

Explanation: This program compares the two operands to find the largest out of them. After comparison, the largest of two must be in accumulator. If it is already in accumulator, then it is moved to memory. If it is not in accumulator, then first it is moved to accumulator and then from there, it is moved to memory. Let us assume that the operands stored at memory location 3000H is 25H and 3001H is 15H. Initially, H-L pair is loaded with the address of first memory location. The first operand is moved to accumulator from memory location 3000H and H-L pair is incremented to point to next memory location. The second operand is moved to register B from memory location 3001H. The two operands are compared. After comparison, if A > B, then CF = 0, and if A < B, then CF = 1. Carry flag is checked for carry. If there is a carry, it means B is greater than A and it is moved to accumulator. Page 53

At last, H-L pair is incremented and the largest number is moved from accumulator to memory location 3002H. Output: Before Execution: 3000H: 25H 3001H: 15H After Execution: 3002H: 25H Page 54

EXPERIMENT-20: Smaller of two 8-bit numbers. AIM: WAP to find smaller of two 8-bit numbers. Page 55

Explanation: This program compares two operands to find the smallest out of them. After comparison, the smallest of two must be in accumulator. If it is already in accumulator, then it is moved to memory. If it is not in accumulator, then first it is moved to accumulator and then from there, it is moved to memory. Let us assume that the operands stored at memory location 3000H is 25H and 3001H is 15H. Initially, H-L pair is loaded with the address of first memory location. The first operand is moved to accumulator from memory location 3000H and H-L pair is incremented to point to next memory location. The second operand is moved to register B from memory location 3001H. The two operands are compared. After comparison, if A > B, then CF = 0, and if A < B, then CF = 1. Carry flag is checked for carry. If there is no carry, it means B is smaller than A and it is moved to accumulator. Page 56

At last, H-L pair is incremented and the smallest number is moved from accumulator to memory location 3002H. Output: Before Execution: 3000H: 25H 3001H: 15H After Execution: 3002H: 15H Based on the format followed for the above programs, perform the rest of the experiments Page 57

EXPERIMENT-21: Addition of ten 8-bit numbers stored in memory. AIM: WAP to add ten 8-bit numbers stored in memory Instruction Used with description LXI Rp MOV R,M MOV M,R INX Rp ADD M MVI R, 8 bit data JNC 16-bit address DCR R Decrement Register Pair Initialization Memory Read Memory Write Pointer Increment Addition with Memory Contents Register initialization Branching Instruction Register Contents Study the above instructions from the book. As per the common procedure specified in this manual, perform the experiments. Testing: Test the program with worst case values. Page 58

EXPERIMENT-22: Find no. of negative elements in a block of data Instruction Used with description Page 59

EXPERIMENT-23 : To sort numbers AIM: Write a program to sort given 10 numbers from memory location 2200H in the ascending order. Source program : MVI B, 09 START : LXI H, 2200H : Initialize counter : Initialize memory pointer MVI C, 09H : Initialize counter 2 BACK: MOV A, M : Get the number Page 60

INX H CMP M JC SKIP JZ SKIP : Increment memory pointer : Compare number with next number : If less, don't interchange : If equal, don't interchange MOV D, M MOV M, A DCX H MOV M, D INX H : Interchange two numbers SKIP: DCR C : Decrement counter 2 JNZ BACK DCR B : If not zero, repeat : Decrement counter 1 JNZ START HLT : Terminate program execution Page 61

EXPERIMENT-24 : Alter the contents of flag register in 8085. AIM: Write a set of instructions to alter the contents of flag register in 8085. PUSH PSW POP H MOV A, L : Save flags on stack : Retrieve flags in 'L' :Flags in accumulator CMA MOV L, A PUSH H :Complement accumulator :Accumulator in 'L' :Save on stack POP PSW :Back to flag register HLT :Terminate program execution Page 62

EXPERIMENT-25 : Calculate the sum of series of numbers AIM: Calculate the sum of series of numbers. The length of the series is in memory location 4200H and the series begins from memory location 4201H. a. Consider the sum to be 8 bit number. So, ignore carries. Store the sum at memory location 4300H. b. Consider the sum to be 16 bit number. Store the sum at memory locations 4300H and 4301H. Flowchart for Source program1 Program 1: LDA 4200H MOV C, A : Initialize counter SUB A : sum = 0 LXI H, 420lH : Initialize pointer BACK: ADD M : SUM = SUM + data INX H : increment pointer DCR C : Decrement counter JNZ BACK : if counter 0 repeat STA 4300H : Store sum HLT :Terminate program execution Output: Page 63

Before Execution: 4200H = 04H 4201H = 10H 4202H = 45H 4203H = 33H 4204H = 22H After Execution: Result = 10 +41 + 30 + 12 = H 4300H = H Microprocessor 8085 Prac Course File Program 2 LDA 4200H MOV C, A : Initialize counter LXI H, 4201H : Initialize pointer SUB A :Sum low = 0 MOV B, A : Sum high = 0 BACK: ADD M : Sum = sum + data JNC SKIP INR B : Add carry to MSB of SUM SKIP: INX H : Increment pointer DCR C : Decrement counter JNZ BACK : Check if counter 0 repeat STA 4300H : Store lower byte MOV A, B STA 4301H : Store higher byte HLT :Terminate program execution Output: Before Execution: 4200H = 04H 420lH = 9AH 4202H = 52H 4203H = 89H 4204H = 3EH After Execution: Result = 9AH + 52H + 89H + 3EH = H 4300H = B3H Lower byte 4301H = 0lH Higher byte Page 64

EXPERIMENT-26 : Division of 16 bit number by 8 bit number AIM: Divide 16 bit number stored in memory locations 2200H and 2201H by the 8 bit number stored at memory location 2202H. Store the quotient in memory locations 2300H and 2301H and remainder in memory locations 2302H and 2303H. Flowchart Program: LHLD 2200H : Get the dividend LDA 2202H : Get the divisor MOV C, A LXI D, 0000H : Quotient = 0 Page 65

BACK: MOV A, L SUB C MOV L, A JNC SKIP DCR H SKIP: INX D MOV A, H CPI, 00 JNZ BACK MOV A, L CMP C JNC BACK SHLD 2302H XCHG SHLD 2300H HLT : Subtract divisor : Save partial result : if CY 1 jump : Subtract borrow of previous subtraction : Increment quotient : Check if dividend < divisor : if no repeat : Store the remainder : Store the quotient : Terminate program execution Output: Before Execution: (2200H) = 60H (2201H) = A0H (2202H) = l2h After Execution: Result = A060H/12H = 8E8H Quotient and 10H remainder (2300H) = E8H (2301H) = 08H (2302H= 10H (2303H) 00H Page 66

EXPERIMENT-27 : Find the number of negative elements AIM: Find the number of negative elements (most significant bit 1) in a block of data. The length of the block is in memory location 2200H and the block itself begins in memory location 2201H. Store the number of negative elements in memory location 2300H Flowchart Program: LDA 2200H MOV C, A : Initialize count MVI B, 00 : Negative number = 0 Page 67

BACK: LXI H, 2201H MOV A, M ANI 80H : Initialize pointer : Get the number : Check for MSB JZ SKIP : If MSB = 1 INR B SKIP: INX H DCR C JNZ BACK : Increment negative number count : Increment pointer : Decrement count : If count 0 repeat MOV A, B STA 2300H HLT : Store the result : Terminate program execution Output: Before Execution: (2200H) = 04H (2201H) = 56H (2202H) = A9H (2203H) = 73H (2204H) = 82H After Execution: Result = 02 since 2202H and 2204H contain numbers with a MSB of 1 Page 68

EXPERIMENT-28 : Find the largest of given numbers AIM: Find the largest number in a block of data. The length of the block is in memory location 2200H and the block itself starts from memory location 2201H. Store the maximum number in memory location 2300H. Assume that the numbers in the block are all 8 bit unsigned binary numbers. Source program : LDA 2200H MOV C, A : Initialize counter XRA A : Maximum = Minimum possible value = 0 LXI H, 2201H : Initialize pointer BACK: CMP M : Is number> maximum JNC SKIP : Yes, replace maximum MOV A, M SKIP: INX H DCR C JNZ BACK STA 2300H HLT : Store maximum number : Terminate program execution Output: Before Execution: (2200H) = 04 (2201H) = 34H (2202H) = A9H (2203H) = 78H (2204H) =56H After Execution: Result = (2202H) = A9H Page 69

EXPERIMENT-29:Count number of l's in the contents of a register AIM: WAP to count number of l's in the contents of D register and store the count in the B register. Flowchart Source program : MVI B, 00H MVI C, 08H MOV A, D BACK: RAR JNC SKIP Page 70

INR B SKIP: DCR C JNZ BACK HLT Output: Before Execution: (2200H) = 04 (2201H) = 34H (2202H) = A9H (2203H) = 78H (2204H) =56H After Execution: Result = (2202H) = A9H Page 71

EXPERIMENT-30: Transfer contents to overlapping memory blocks AIM: A block of data consisting of 256 bytes is stored in memory starting at 3000H. This block is to be shifted (relocated) in memory from 3050H onwards. Do not shift the block or part of the block anywhere else in the memory. Two blocks (3000-30FF and 3050-314F) are overlapping. Therefore it is necessary to transfer last byte first and first byte last. Source Program: MVI C, FFH LX I H, 30FFH LXI D, 314FH : Initialize counter : Initialize source memory pointer 3l4FH : Initialize destination memory pointer BACK: MOV A, M : Get byte from source memory block STAX D DCX H DCX SP DCR C JNZ BACK HLT : Store byte in the destination memory block : Decrement source memory pointer : Decrement destination memory pointer : Decrement counter : If counter 0 repeat : Stop execution Page 72

Appendix -1 : OPCODES TABLE OF INTEL 8085 in Alphabetical order Page 73

Page 74

Page 75

Page 76

Page 77

Page 78

Reference: www.eazynotes.com Page 79