SlideShare a Scribd company logo
Microprocessor 8085 Prac Course File
Practical Course File
For
Microprocessor
(IT 473)
B.Tech (IT) IV-SEM
Department of IT
University Institute of Engineering & Technology
Panjab University, Chandigarh
UIET, Panjab University
Page 1
Microprocessor 8085 Prac Course File
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
UIET, Panjab University
Page 2
Microprocessor 8085 Prac Course File
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
UIET, Panjab University
Page 3
Microprocessor 8085 Prac Course File
INTRODUCTION
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.
UIET, Panjab University
Page 4
Microprocessor 8085 Prac Course File
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, Set HL pointer for source
XX50 memory
LXI D, Set DE pointer for destination
XX70 memory
MVI B,10 Set B as a byte counter
NEXT: Get data from source memory
MOV A,M
STAX D Store data in destination
memory
INX H
INX D Get ready for next byte
UIET, Panjab University
Page 5
Microprocessor 8085 Prac Course File
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:
UIET, Panjab University
Page 6
Microprocessor 8085 Prac Course File
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.
UIET, Panjab University
Page 7
Microprocessor 8085 Prac Course File
 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)
UIET, Panjab University
Page 8
Microprocessor 8085 Prac Course File
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:
UIET, Panjab University
Page 9
Microprocessor 8085 Prac Course File
- Parallel I/O using 8255
- Serial I/O using 8251/8253
- Keyboard/Display using 8279
- ADC/DAC using 8255 / Latch -373
 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:
UIET, Panjab University
Page 10
Microprocessor 8085 Prac Course File
How to run/execute the program on kits
SI-Single step execution
. (stop) . (stop)
GO (means run) SI
Enter the beginning address of prog Enter the beginning address of prog
Press next, next, next……… till the end of
prog
.(stop running) .(stop running)
Examine mem/reg Examine mem/reg
UIET, Panjab University
Page 11
Microprocessor 8085 Prac Course File
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.
UIET, Panjab University
Page 12
Microprocessor 8085 Prac Course File
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
UIET, Panjab University
Page 13
Microprocessor 8085 Prac Course File
EXPERIMENT-3: 2’s complement of an 8-bit number.
AIM: WAP to find 2’s complement of an 8-bit number.
UIET, Panjab University
Page 14
Microprocessor 8085 Prac Course File
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
UIET, Panjab University
Page 15
Microprocessor 8085 Prac Course File
EXPERIMENT-4: 1’s complement of 16-bit number.
AIM: WAP to find 1’s complement of 16-bit number.
UIET, Panjab University
Page 16
Microprocessor 8085 Prac Course File
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
UIET, Panjab University
Page 17
Microprocessor 8085 Prac Course File
EXPERIMENT-5: 2’s complement of 16-bit number.
AIM: WAP to find 2’s complement of 16-bit number.
UIET, Panjab University
Page 18
Microprocessor 8085 Prac Course File
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
UIET, Panjab University
Page 19
Microprocessor 8085 Prac Course File
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.
UIET, Panjab University
Page 20
Microprocessor 8085 Prac Course File
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
UIET, Panjab University
Page 21
Microprocessor 8085 Prac Course File
EXPERIMENT-7: Shift right 8-bit number by 1 bit.
AIM: WAP to Shift right 8-bit number by 1 bit.
UIET, Panjab University
Page 22
Microprocessor 8085 Prac Course File
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
UIET, Panjab University
Page 23
Microprocessor 8085 Prac Course File
EXPERIMENT-8: Mask the lower nibble of an 8-bit number.
AIM: WAP to mask the lower nibble of an 8-bit number.
Explanation:
UIET, Panjab University
Page 24
Microprocessor 8085 Prac Course File
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
UIET, Panjab University
Page 25
Microprocessor 8085 Prac Course File
EXPERIMENT-9: Mask the higher nibble of an 8-bit number.
AIM: WAP to mask the higher nibble of an 8-bit number.
UIET, Panjab University
Page 26
Microprocessor 8085 Prac Course File
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
UIET, Panjab University
Page 27
Microprocessor 8085 Prac Course File
EXPERIMENT-10: Add two 8-bit numbers without considering the carry.
AIM: WAP to add two 8-bit numbers without considering the carry
UIET, Panjab University
Page 28
Microprocessor 8085 Prac Course File
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
UIET, Panjab University
Page 29
Microprocessor 8085 Prac Course File
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.
UIET, Panjab University
Page 30
Microprocessor 8085 Prac Course File
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
UIET, Panjab University
Page 31
Microprocessor 8085 Prac Course File
location 3003H
Output:
Before Execution:
3000H: FAH
3001H: 28H
After Execution:
3002H: 22H
3003H: 01H
UIET, Panjab University
Page 32
Microprocessor 8085 Prac Course File
EXPERIMENT-12: Subtract two 8-bit numbers without considering
borrow.
AIM: WAP to subtract two 8-bit numbers without considering borrow.
UIET, Panjab University
Page 33
Microprocessor 8085 Prac Course File
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
UIET, Panjab University
Page 34
Microprocessor 8085 Prac Course File
EXPERIMENT-13: Subtract two 8-bit numbers along with considering the
borrow.
AIM: WAP to Subtract two 8-bit numbers by considering the borrow
UIET, Panjab University
Page 35
Microprocessor 8085 Prac Course File
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
UIET, Panjab University
Page 36
Microprocessor 8085 Prac Course File
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
UIET, Panjab University
Page 37
Microprocessor 8085 Prac Course File
EXPERIMENT-14: Add two 16-bit numbers without considering the
carry.
AIM: WAP to add two 16-bit numbers without considering the carry.
UIET, Panjab University
Page 38
Microprocessor 8085 Prac Course File
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
UIET, Panjab University
Page 39
Microprocessor 8085 Prac Course File
EXPERIMENT-15: Subtract two 16-bit numbers without considering
borrow.
AIM: WAP to subtract two 16-bit numbers without considering borrow.
UIET, Panjab University
Page 40
Microprocessor 8085 Prac Course File
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.
UIET, Panjab University
Page 41
Microprocessor 8085 Prac Course File
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
UIET, Panjab University
Page 42
Microprocessor 8085 Prac Course File
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.
UIET, Panjab University
Page 43
Microprocessor 8085 Prac Course File
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.
UIET, Panjab University
Page 44
Microprocessor 8085 Prac Course File
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
UIET, Panjab University
Page 45
Microprocessor 8085 Prac Course File
EXPERIMENT-17: Multiply two 8-bit numbers.
AIM: WAP to multiply two 8-bit numbers.
UIET, Panjab University
Page 46
Microprocessor 8085 Prac Course File
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.
UIET, Panjab University
Page 47
Microprocessor 8085 Prac Course File
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
UIET, Panjab University
Page 48
Microprocessor 8085 Prac Course File
EXPERIMENT-18: Find square of an 8-bit number.
AIM: WAP to find square of an 8-bit number
UIET, Panjab University
Page 49
Explanation:
Microprocessor 8085 Prac Course File
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
UIET, Panjab University
Page 50
Microprocessor 8085 Prac Course File
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
UIET, Panjab University
Page 51
Microprocessor 8085 Prac Course File
EXPERIMENT-19: Larger of two 8-bit numbers.
AIM: WAP to find larger of two 8-bit numbers.
UIET, Panjab University
Page 52
Explanation:
Microprocessor 8085 Prac Course File
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.
UIET, Panjab University
Page 53
Microprocessor 8085 Prac Course File
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
UIET, Panjab University
Page 54
Microprocessor 8085 Prac Course File
EXPERIMENT-20: Smaller of two 8-bit numbers.
AIM: WAP to find smaller of two 8-bit numbers.
UIET, Panjab University
Page 55
Microprocessor 8085 Prac Course File
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.
UIET, Panjab University
Page 56
Microprocessor 8085 Prac Course File
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
UIET, Panjab University
Page 57
Microprocessor 8085 Prac Course File
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 Register Pair Initialization
MOV R,M Memory Read
MOV M,R Memory Write
INX Rp Pointer Increment
ADD M Addition with Memory Contents
MVI R, 8 bit data Register initialization
JNC 16-bit address Branching Instruction
DCR R Decrement 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.
UIET, Panjab University
Page 58
Microprocessor 8085 Prac Course File
EXPERIMENT-22: Find no. of negative elements in a block of data
Instruction Used with description
UIET, Panjab University
Page 59
Microprocessor 8085 Prac Course File
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 : Initialize counter
START : LXI H, 2200H : Initialize memory pointer
MVI C, 09H : Initialize counter 2
BACK: MOV A, M : Get the number
UIET, Panjab University
Page 60
Microprocessor 8085 Prac Course File
INX H
CMP M
: Increment memory pointer
: Compare number with next number
JC SKIP : If less, don't interchange
JZ SKIP : 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
UIET, Panjab University
Page 61
Microprocessor 8085 Prac Course File
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 : Save flags on stack
POP H : Retrieve flags in 'L'
MOV A, L :Flags in accumulator
CMA :Complement accumulator
MOV L, A :Accumulator in 'L'
PUSH H :Save on stack
POP PSW :Back to flag register
HLT :Terminate program execution
UIET, Panjab University
Page 62
Microprocessor 8085 Prac Course File
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:
UIET, Panjab University
Page 63
Microprocessor 8085 Prac Course File
Before Execution:
4200H = 04H
4201H = 10H
4202H = 45H
4203H = 33H
4204H = 22H
After Execution:
Result = 10 +41 + 30 + 12 = H
4300H = H
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
UIET, Panjab University
Page 64
Microprocessor 8085 Prac Course File
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
UIET, Panjab University
Page 65
Microprocessor 8085 Prac Course File
BACK: MOV A, L
SUB C : Subtract divisor
MOV L, A : Save partial result
JNC SKIP : if CY 1 jump
DCR H : Subtract borrow of previous subtraction
SKIP: INX D : Increment quotient
MOV A, H
CPI, 00 : Check if dividend < divisor
JNZ BACK : if no repeat
MOV A, L
CMP C
JNC BACK
SHLD 2302H : Store the remainder
XCHG
SHLD 2300H : Store the quotient
HLT : 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
UIET, Panjab University
Page 66
Microprocessor 8085 Prac Course File
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
UIET, Panjab University
Page 67
Microprocessor 8085 Prac Course File
BACK:
LXI H, 2201H
MOV A, M
: Initialize pointer
: Get the number
ANI 80H : Check for MSB
JZ SKIP : If MSB = 1
INR B
SKIP: INX H
: Increment negative number count
: Increment pointer
DCR C : Decrement count
JNZ BACK
MOV A, B
: If count 0 repeat
STA 2300H : Store the result
HLT : 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
UIET, Panjab University
Page 68
Microprocessor 8085 Prac Course File
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 : Store maximum number
HLT : Terminate program execution
Output:
Before Execution:
(2200H) = 04
(2201H) = 34H
(2202H) = A9H
(2203H) = 78H
(2204H) =56H
After Execution:
Result = (2202H) = A9H
UIET, Panjab University
Page 69
Microprocessor 8085 Prac Course File
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.
Source program :
Flowchart
MVI B, 00H
MVI C, 08H
MOV A, D
BACK: RAR
JNC SKIP
UIET, Panjab University
Page 70
Microprocessor 8085 Prac Course File
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
UIET, Panjab University
Page 71
Microprocessor 8085 Prac Course File
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
: Initialize counter
: Initialize source memory pointer 3l4FH
LXI D, 314FH : Initialize destination memory pointer
BACK: MOV A, M : Get byte from source memory block
STAX D : Store byte in the destination memory block
DCX H : Decrement source memory pointer
DCX SP : Decrement destination memory pointer
DCR C : Decrement counter
JNZ BACK
HLT
: If counter 0 repeat
: Stop execution
UIET, Panjab University
Page 72
Microprocessor 8085 Prac Course File
Appendix -1 : OPCODES TABLE OF INTEL 8085 in Alphabetical order
UIET, Panjab University
Page 73
Microprocessor 8085 Prac Course File
UIET, Panjab University
Page 74
Microprocessor 8085 Prac Course File
UIET, Panjab University
Page 75
Microprocessor 8085 Prac Course File
UIET, Panjab University
Page 76
Microprocessor 8085 Prac Course File
UIET, Panjab University
Page 77
Microprocessor 8085 Prac Course File
UIET, Panjab University
Page 78
Microprocessor 8085 Prac Course File
Reference: www.eazynotes.com
UIET, Panjab University
Page 79

More Related Content

Similar to Lab Manual.pdf

My seminar new 28
My seminar new 28My seminar new 28
My seminar new 28
rajeshkvdn
 
EEE226a.ppt
EEE226a.pptEEE226a.ppt
EEE226a.ppt
SaifulAhmad27
 
Ec6504 microprocessor and microcontroller
Ec6504 microprocessor and microcontrollerEc6504 microprocessor and microcontroller
Ec6504 microprocessor and microcontroller
Senthil Kumar
 
8 bit Microprocessor with Single Vectored Interrupt
8 bit Microprocessor with Single Vectored Interrupt8 bit Microprocessor with Single Vectored Interrupt
8 bit Microprocessor with Single Vectored Interrupt
Hardik Manocha
 
Rodrigo Almeida - Microkernel development from project to implementation
Rodrigo Almeida - Microkernel development from project to implementationRodrigo Almeida - Microkernel development from project to implementation
Rodrigo Almeida - Microkernel development from project to implementation
Felipe Prado
 
NIE2206 Electronic LogbookNamexxxStudent IDUxxxTe.docx
NIE2206 Electronic LogbookNamexxxStudent IDUxxxTe.docxNIE2206 Electronic LogbookNamexxxStudent IDUxxxTe.docx
NIE2206 Electronic LogbookNamexxxStudent IDUxxxTe.docx
curwenmichaela
 
GOWTHAM REPORT
GOWTHAM REPORTGOWTHAM REPORT
GOWTHAM REPORT
gowtham sekar
 
EELE 5331 Digital ASIC DesignLab ManualDr. Yushi Zhou.docx
EELE 5331 Digital ASIC DesignLab ManualDr. Yushi Zhou.docxEELE 5331 Digital ASIC DesignLab ManualDr. Yushi Zhou.docx
EELE 5331 Digital ASIC DesignLab ManualDr. Yushi Zhou.docx
toltonkendal
 
Programming the ARM CORTEX M3 based STM32F100RBT6 Value Line Discovery Board
Programming the ARM CORTEX M3 based STM32F100RBT6 Value Line Discovery BoardProgramming the ARM CORTEX M3 based STM32F100RBT6 Value Line Discovery Board
Programming the ARM CORTEX M3 based STM32F100RBT6 Value Line Discovery Board
Gaurav Verma
 
Question bank malp 3340302
Question bank malp 3340302Question bank malp 3340302
Question bank malp 3340302
SHAH JAINAM
 
Freertos based environmental data acquisition using arm cortex m4 f core
Freertos based environmental data acquisition using arm cortex m4 f coreFreertos based environmental data acquisition using arm cortex m4 f core
Freertos based environmental data acquisition using arm cortex m4 f core
eSAT Journals
 
16-bit Microprocessor Design (2005)
16-bit Microprocessor Design (2005)16-bit Microprocessor Design (2005)
16-bit Microprocessor Design (2005)
Susam Pal
 
Session plan microprocessor &amp; interfacing new
Session plan microprocessor &amp; interfacing newSession plan microprocessor &amp; interfacing new
Session plan microprocessor &amp; interfacing new
Sumeet Sehrawat
 
Introduction to 8085_by_adi_ppt
Introduction to 8085_by_adi_pptIntroduction to 8085_by_adi_ppt
Introduction to 8085_by_adi_ppt
AdiseshaK
 
Introduction to 8085 Microprocessor
Introduction to 8085 MicroprocessorIntroduction to 8085 Microprocessor
Introduction to 8085 Microprocessor
Prof. Dr. K. Adisesha
 
learning STM -32
learning STM -32 learning STM -32
learning STM -32
SeoTechnoscripts
 
STM -32
STM -32STM -32
Unit-2-Stack_basic_Input_Output-4-12-2022-8am.ppt
Unit-2-Stack_basic_Input_Output-4-12-2022-8am.pptUnit-2-Stack_basic_Input_Output-4-12-2022-8am.ppt
Unit-2-Stack_basic_Input_Output-4-12-2022-8am.ppt
IronMan665214
 
An integrated approach for designing and testing specific processors
An integrated approach for designing and testing specific processorsAn integrated approach for designing and testing specific processors
An integrated approach for designing and testing specific processors
VLSICS Design
 
Larson and toubro
Larson and toubroLarson and toubro
Larson and toubro
anoopc1998
 

Similar to Lab Manual.pdf (20)

My seminar new 28
My seminar new 28My seminar new 28
My seminar new 28
 
EEE226a.ppt
EEE226a.pptEEE226a.ppt
EEE226a.ppt
 
Ec6504 microprocessor and microcontroller
Ec6504 microprocessor and microcontrollerEc6504 microprocessor and microcontroller
Ec6504 microprocessor and microcontroller
 
8 bit Microprocessor with Single Vectored Interrupt
8 bit Microprocessor with Single Vectored Interrupt8 bit Microprocessor with Single Vectored Interrupt
8 bit Microprocessor with Single Vectored Interrupt
 
Rodrigo Almeida - Microkernel development from project to implementation
Rodrigo Almeida - Microkernel development from project to implementationRodrigo Almeida - Microkernel development from project to implementation
Rodrigo Almeida - Microkernel development from project to implementation
 
NIE2206 Electronic LogbookNamexxxStudent IDUxxxTe.docx
NIE2206 Electronic LogbookNamexxxStudent IDUxxxTe.docxNIE2206 Electronic LogbookNamexxxStudent IDUxxxTe.docx
NIE2206 Electronic LogbookNamexxxStudent IDUxxxTe.docx
 
GOWTHAM REPORT
GOWTHAM REPORTGOWTHAM REPORT
GOWTHAM REPORT
 
EELE 5331 Digital ASIC DesignLab ManualDr. Yushi Zhou.docx
EELE 5331 Digital ASIC DesignLab ManualDr. Yushi Zhou.docxEELE 5331 Digital ASIC DesignLab ManualDr. Yushi Zhou.docx
EELE 5331 Digital ASIC DesignLab ManualDr. Yushi Zhou.docx
 
Programming the ARM CORTEX M3 based STM32F100RBT6 Value Line Discovery Board
Programming the ARM CORTEX M3 based STM32F100RBT6 Value Line Discovery BoardProgramming the ARM CORTEX M3 based STM32F100RBT6 Value Line Discovery Board
Programming the ARM CORTEX M3 based STM32F100RBT6 Value Line Discovery Board
 
Question bank malp 3340302
Question bank malp 3340302Question bank malp 3340302
Question bank malp 3340302
 
Freertos based environmental data acquisition using arm cortex m4 f core
Freertos based environmental data acquisition using arm cortex m4 f coreFreertos based environmental data acquisition using arm cortex m4 f core
Freertos based environmental data acquisition using arm cortex m4 f core
 
16-bit Microprocessor Design (2005)
16-bit Microprocessor Design (2005)16-bit Microprocessor Design (2005)
16-bit Microprocessor Design (2005)
 
Session plan microprocessor &amp; interfacing new
Session plan microprocessor &amp; interfacing newSession plan microprocessor &amp; interfacing new
Session plan microprocessor &amp; interfacing new
 
Introduction to 8085_by_adi_ppt
Introduction to 8085_by_adi_pptIntroduction to 8085_by_adi_ppt
Introduction to 8085_by_adi_ppt
 
Introduction to 8085 Microprocessor
Introduction to 8085 MicroprocessorIntroduction to 8085 Microprocessor
Introduction to 8085 Microprocessor
 
learning STM -32
learning STM -32 learning STM -32
learning STM -32
 
STM -32
STM -32STM -32
STM -32
 
Unit-2-Stack_basic_Input_Output-4-12-2022-8am.ppt
Unit-2-Stack_basic_Input_Output-4-12-2022-8am.pptUnit-2-Stack_basic_Input_Output-4-12-2022-8am.ppt
Unit-2-Stack_basic_Input_Output-4-12-2022-8am.ppt
 
An integrated approach for designing and testing specific processors
An integrated approach for designing and testing specific processorsAn integrated approach for designing and testing specific processors
An integrated approach for designing and testing specific processors
 
Larson and toubro
Larson and toubroLarson and toubro
Larson and toubro
 

Recently uploaded

快速办理(napier毕业证书)英国龙比亚大学毕业证在读证明一模一样
快速办理(napier毕业证书)英国龙比亚大学毕业证在读证明一模一样快速办理(napier毕业证书)英国龙比亚大学毕业证在读证明一模一样
快速办理(napier毕业证书)英国龙比亚大学毕业证在读证明一模一样
78tq3hi2
 
原版制作(澳洲WSU毕业证书)西悉尼大学毕业证文凭证书一模一样
原版制作(澳洲WSU毕业证书)西悉尼大学毕业证文凭证书一模一样原版制作(澳洲WSU毕业证书)西悉尼大学毕业证文凭证书一模一样
原版制作(澳洲WSU毕业证书)西悉尼大学毕业证文凭证书一模一样
g1inbfro
 
Expanding Access to Affordable At-Home EV Charging by Vanessa Warheit
Expanding Access to Affordable At-Home EV Charging by Vanessa WarheitExpanding Access to Affordable At-Home EV Charging by Vanessa Warheit
Expanding Access to Affordable At-Home EV Charging by Vanessa Warheit
Forth
 
Catalytic Converter theft prevention - NYC.pptx
Catalytic Converter theft prevention - NYC.pptxCatalytic Converter theft prevention - NYC.pptx
Catalytic Converter theft prevention - NYC.pptx
Blue Star Brothers
 
EV Charging at MFH Properties by Whitaker Jamieson
EV Charging at MFH Properties by Whitaker JamiesonEV Charging at MFH Properties by Whitaker Jamieson
EV Charging at MFH Properties by Whitaker Jamieson
Forth
 
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证如何办理
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证如何办理一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证如何办理
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证如何办理
u2cz10zq
 
一比一原版(WashU文凭证书)圣路易斯华盛顿大学毕业证如何办理
一比一原版(WashU文凭证书)圣路易斯华盛顿大学毕业证如何办理一比一原版(WashU文凭证书)圣路易斯华盛顿大学毕业证如何办理
一比一原版(WashU文凭证书)圣路易斯华盛顿大学毕业证如何办理
afkxen
 
Dahua Security Camera System Guide esetia
Dahua Security Camera System Guide esetiaDahua Security Camera System Guide esetia
Dahua Security Camera System Guide esetia
Esentia Systems
 
原版定做(mmu学位证书)英国曼彻斯特城市大学毕业证本科文凭原版一模一样
原版定做(mmu学位证书)英国曼彻斯特城市大学毕业证本科文凭原版一模一样原版定做(mmu学位证书)英国曼彻斯特城市大学毕业证本科文凭原版一模一样
原版定做(mmu学位证书)英国曼彻斯特城市大学毕业证本科文凭原版一模一样
utuvvas
 
Charging and Fueling Infrastructure Grant: Round 2 by Brandt Hertenstein
Charging and Fueling Infrastructure Grant: Round 2 by Brandt HertensteinCharging and Fueling Infrastructure Grant: Round 2 by Brandt Hertenstein
Charging and Fueling Infrastructure Grant: Round 2 by Brandt Hertenstein
Forth
 
一比一原版(Columbia文凭证书)哥伦比亚大学毕业证如何办理
一比一原版(Columbia文凭证书)哥伦比亚大学毕业证如何办理一比一原版(Columbia文凭证书)哥伦比亚大学毕业证如何办理
一比一原版(Columbia文凭证书)哥伦比亚大学毕业证如何办理
afkxen
 
Charging Fueling & Infrastructure (CFI) Program by Kevin Miller
Charging Fueling & Infrastructure (CFI) Program  by Kevin MillerCharging Fueling & Infrastructure (CFI) Program  by Kevin Miller
Charging Fueling & Infrastructure (CFI) Program by Kevin Miller
Forth
 
原版制作(Exeter毕业证书)埃克塞特大学毕业证完成信一模一样
原版制作(Exeter毕业证书)埃克塞特大学毕业证完成信一模一样原版制作(Exeter毕业证书)埃克塞特大学毕业证完成信一模一样
原版制作(Exeter毕业证书)埃克塞特大学毕业证完成信一模一样
78tq3hi2
 
按照学校原版(UniSA文凭证书)南澳大学毕业证快速办理
按照学校原版(UniSA文凭证书)南澳大学毕业证快速办理按照学校原版(UniSA文凭证书)南澳大学毕业证快速办理
按照学校原版(UniSA文凭证书)南澳大学毕业证快速办理
ggany
 
Here's Why Every Semi-Truck Should Have ELDs
Here's Why Every Semi-Truck Should Have ELDsHere's Why Every Semi-Truck Should Have ELDs
Here's Why Every Semi-Truck Should Have ELDs
jennifermiller8137
 
53286592-Global-Entrepreneurship-and-the-Successful-Growth-Strategies-of-Earl...
53286592-Global-Entrepreneurship-and-the-Successful-Growth-Strategies-of-Earl...53286592-Global-Entrepreneurship-and-the-Successful-Growth-Strategies-of-Earl...
53286592-Global-Entrepreneurship-and-the-Successful-Growth-Strategies-of-Earl...
MarynaYurchenko2
 
Charging Fueling & Infrastructure (CFI) Program Resources by Cat Plein
Charging Fueling & Infrastructure (CFI) Program Resources by Cat PleinCharging Fueling & Infrastructure (CFI) Program Resources by Cat Plein
Charging Fueling & Infrastructure (CFI) Program Resources by Cat Plein
Forth
 
EV Charging at Multifamily Properties by Kevin Donnelly
EV Charging at Multifamily Properties by Kevin DonnellyEV Charging at Multifamily Properties by Kevin Donnelly
EV Charging at Multifamily Properties by Kevin Donnelly
Forth
 

Recently uploaded (18)

快速办理(napier毕业证书)英国龙比亚大学毕业证在读证明一模一样
快速办理(napier毕业证书)英国龙比亚大学毕业证在读证明一模一样快速办理(napier毕业证书)英国龙比亚大学毕业证在读证明一模一样
快速办理(napier毕业证书)英国龙比亚大学毕业证在读证明一模一样
 
原版制作(澳洲WSU毕业证书)西悉尼大学毕业证文凭证书一模一样
原版制作(澳洲WSU毕业证书)西悉尼大学毕业证文凭证书一模一样原版制作(澳洲WSU毕业证书)西悉尼大学毕业证文凭证书一模一样
原版制作(澳洲WSU毕业证书)西悉尼大学毕业证文凭证书一模一样
 
Expanding Access to Affordable At-Home EV Charging by Vanessa Warheit
Expanding Access to Affordable At-Home EV Charging by Vanessa WarheitExpanding Access to Affordable At-Home EV Charging by Vanessa Warheit
Expanding Access to Affordable At-Home EV Charging by Vanessa Warheit
 
Catalytic Converter theft prevention - NYC.pptx
Catalytic Converter theft prevention - NYC.pptxCatalytic Converter theft prevention - NYC.pptx
Catalytic Converter theft prevention - NYC.pptx
 
EV Charging at MFH Properties by Whitaker Jamieson
EV Charging at MFH Properties by Whitaker JamiesonEV Charging at MFH Properties by Whitaker Jamieson
EV Charging at MFH Properties by Whitaker Jamieson
 
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证如何办理
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证如何办理一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证如何办理
一比一原版(UMich毕业证)密歇根大学|安娜堡分校毕业证如何办理
 
一比一原版(WashU文凭证书)圣路易斯华盛顿大学毕业证如何办理
一比一原版(WashU文凭证书)圣路易斯华盛顿大学毕业证如何办理一比一原版(WashU文凭证书)圣路易斯华盛顿大学毕业证如何办理
一比一原版(WashU文凭证书)圣路易斯华盛顿大学毕业证如何办理
 
Dahua Security Camera System Guide esetia
Dahua Security Camera System Guide esetiaDahua Security Camera System Guide esetia
Dahua Security Camera System Guide esetia
 
原版定做(mmu学位证书)英国曼彻斯特城市大学毕业证本科文凭原版一模一样
原版定做(mmu学位证书)英国曼彻斯特城市大学毕业证本科文凭原版一模一样原版定做(mmu学位证书)英国曼彻斯特城市大学毕业证本科文凭原版一模一样
原版定做(mmu学位证书)英国曼彻斯特城市大学毕业证本科文凭原版一模一样
 
Charging and Fueling Infrastructure Grant: Round 2 by Brandt Hertenstein
Charging and Fueling Infrastructure Grant: Round 2 by Brandt HertensteinCharging and Fueling Infrastructure Grant: Round 2 by Brandt Hertenstein
Charging and Fueling Infrastructure Grant: Round 2 by Brandt Hertenstein
 
一比一原版(Columbia文凭证书)哥伦比亚大学毕业证如何办理
一比一原版(Columbia文凭证书)哥伦比亚大学毕业证如何办理一比一原版(Columbia文凭证书)哥伦比亚大学毕业证如何办理
一比一原版(Columbia文凭证书)哥伦比亚大学毕业证如何办理
 
Charging Fueling & Infrastructure (CFI) Program by Kevin Miller
Charging Fueling & Infrastructure (CFI) Program  by Kevin MillerCharging Fueling & Infrastructure (CFI) Program  by Kevin Miller
Charging Fueling & Infrastructure (CFI) Program by Kevin Miller
 
原版制作(Exeter毕业证书)埃克塞特大学毕业证完成信一模一样
原版制作(Exeter毕业证书)埃克塞特大学毕业证完成信一模一样原版制作(Exeter毕业证书)埃克塞特大学毕业证完成信一模一样
原版制作(Exeter毕业证书)埃克塞特大学毕业证完成信一模一样
 
按照学校原版(UniSA文凭证书)南澳大学毕业证快速办理
按照学校原版(UniSA文凭证书)南澳大学毕业证快速办理按照学校原版(UniSA文凭证书)南澳大学毕业证快速办理
按照学校原版(UniSA文凭证书)南澳大学毕业证快速办理
 
Here's Why Every Semi-Truck Should Have ELDs
Here's Why Every Semi-Truck Should Have ELDsHere's Why Every Semi-Truck Should Have ELDs
Here's Why Every Semi-Truck Should Have ELDs
 
53286592-Global-Entrepreneurship-and-the-Successful-Growth-Strategies-of-Earl...
53286592-Global-Entrepreneurship-and-the-Successful-Growth-Strategies-of-Earl...53286592-Global-Entrepreneurship-and-the-Successful-Growth-Strategies-of-Earl...
53286592-Global-Entrepreneurship-and-the-Successful-Growth-Strategies-of-Earl...
 
Charging Fueling & Infrastructure (CFI) Program Resources by Cat Plein
Charging Fueling & Infrastructure (CFI) Program Resources by Cat PleinCharging Fueling & Infrastructure (CFI) Program Resources by Cat Plein
Charging Fueling & Infrastructure (CFI) Program Resources by Cat Plein
 
EV Charging at Multifamily Properties by Kevin Donnelly
EV Charging at Multifamily Properties by Kevin DonnellyEV Charging at Multifamily Properties by Kevin Donnelly
EV Charging at Multifamily Properties by Kevin Donnelly
 

Lab Manual.pdf

  • 1. Microprocessor 8085 Prac Course File Practical Course File For Microprocessor (IT 473) B.Tech (IT) IV-SEM Department of IT University Institute of Engineering & Technology Panjab University, Chandigarh UIET, Panjab University Page 1
  • 2. Microprocessor 8085 Prac Course File 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 UIET, Panjab University Page 2
  • 3. Microprocessor 8085 Prac Course File 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 UIET, Panjab University Page 3
  • 4. Microprocessor 8085 Prac Course File INTRODUCTION 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. UIET, Panjab University Page 4
  • 5. Microprocessor 8085 Prac Course File 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, Set HL pointer for source XX50 memory LXI D, Set DE pointer for destination XX70 memory MVI B,10 Set B as a byte counter NEXT: Get data from source memory MOV A,M STAX D Store data in destination memory INX H INX D Get ready for next byte UIET, Panjab University Page 5
  • 6. Microprocessor 8085 Prac Course File 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: UIET, Panjab University Page 6
  • 7. Microprocessor 8085 Prac Course File 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. UIET, Panjab University Page 7
  • 8. Microprocessor 8085 Prac Course File  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) UIET, Panjab University Page 8
  • 9. Microprocessor 8085 Prac Course File 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: UIET, Panjab University Page 9
  • 10. Microprocessor 8085 Prac Course File - Parallel I/O using 8255 - Serial I/O using 8251/8253 - Keyboard/Display using 8279 - ADC/DAC using 8255 / Latch -373  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: UIET, Panjab University Page 10
  • 11. Microprocessor 8085 Prac Course File How to run/execute the program on kits SI-Single step execution . (stop) . (stop) GO (means run) SI Enter the beginning address of prog Enter the beginning address of prog Press next, next, next……… till the end of prog .(stop running) .(stop running) Examine mem/reg Examine mem/reg UIET, Panjab University Page 11
  • 12. Microprocessor 8085 Prac Course File 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. UIET, Panjab University Page 12
  • 13. Microprocessor 8085 Prac Course File 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 UIET, Panjab University Page 13
  • 14. Microprocessor 8085 Prac Course File EXPERIMENT-3: 2’s complement of an 8-bit number. AIM: WAP to find 2’s complement of an 8-bit number. UIET, Panjab University Page 14
  • 15. Microprocessor 8085 Prac Course File 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 UIET, Panjab University Page 15
  • 16. Microprocessor 8085 Prac Course File EXPERIMENT-4: 1’s complement of 16-bit number. AIM: WAP to find 1’s complement of 16-bit number. UIET, Panjab University Page 16
  • 17. Microprocessor 8085 Prac Course File 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 UIET, Panjab University Page 17
  • 18. Microprocessor 8085 Prac Course File EXPERIMENT-5: 2’s complement of 16-bit number. AIM: WAP to find 2’s complement of 16-bit number. UIET, Panjab University Page 18
  • 19. Microprocessor 8085 Prac Course File 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 UIET, Panjab University Page 19
  • 20. Microprocessor 8085 Prac Course File 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. UIET, Panjab University Page 20
  • 21. Microprocessor 8085 Prac Course File 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 UIET, Panjab University Page 21
  • 22. Microprocessor 8085 Prac Course File EXPERIMENT-7: Shift right 8-bit number by 1 bit. AIM: WAP to Shift right 8-bit number by 1 bit. UIET, Panjab University Page 22
  • 23. Microprocessor 8085 Prac Course File 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 UIET, Panjab University Page 23
  • 24. Microprocessor 8085 Prac Course File EXPERIMENT-8: Mask the lower nibble of an 8-bit number. AIM: WAP to mask the lower nibble of an 8-bit number. Explanation: UIET, Panjab University Page 24
  • 25. Microprocessor 8085 Prac Course File 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 UIET, Panjab University Page 25
  • 26. Microprocessor 8085 Prac Course File EXPERIMENT-9: Mask the higher nibble of an 8-bit number. AIM: WAP to mask the higher nibble of an 8-bit number. UIET, Panjab University Page 26
  • 27. Microprocessor 8085 Prac Course File 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 UIET, Panjab University Page 27
  • 28. Microprocessor 8085 Prac Course File EXPERIMENT-10: Add two 8-bit numbers without considering the carry. AIM: WAP to add two 8-bit numbers without considering the carry UIET, Panjab University Page 28
  • 29. Microprocessor 8085 Prac Course File 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 UIET, Panjab University Page 29
  • 30. Microprocessor 8085 Prac Course File 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. UIET, Panjab University Page 30
  • 31. Microprocessor 8085 Prac Course File 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 UIET, Panjab University Page 31
  • 32. Microprocessor 8085 Prac Course File location 3003H Output: Before Execution: 3000H: FAH 3001H: 28H After Execution: 3002H: 22H 3003H: 01H UIET, Panjab University Page 32
  • 33. Microprocessor 8085 Prac Course File EXPERIMENT-12: Subtract two 8-bit numbers without considering borrow. AIM: WAP to subtract two 8-bit numbers without considering borrow. UIET, Panjab University Page 33
  • 34. Microprocessor 8085 Prac Course File 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 UIET, Panjab University Page 34
  • 35. Microprocessor 8085 Prac Course File EXPERIMENT-13: Subtract two 8-bit numbers along with considering the borrow. AIM: WAP to Subtract two 8-bit numbers by considering the borrow UIET, Panjab University Page 35
  • 36. Microprocessor 8085 Prac Course File 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 UIET, Panjab University Page 36
  • 37. Microprocessor 8085 Prac Course File 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 UIET, Panjab University Page 37
  • 38. Microprocessor 8085 Prac Course File EXPERIMENT-14: Add two 16-bit numbers without considering the carry. AIM: WAP to add two 16-bit numbers without considering the carry. UIET, Panjab University Page 38
  • 39. Microprocessor 8085 Prac Course File 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 UIET, Panjab University Page 39
  • 40. Microprocessor 8085 Prac Course File EXPERIMENT-15: Subtract two 16-bit numbers without considering borrow. AIM: WAP to subtract two 16-bit numbers without considering borrow. UIET, Panjab University Page 40
  • 41. Microprocessor 8085 Prac Course File 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. UIET, Panjab University Page 41
  • 42. Microprocessor 8085 Prac Course File 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 UIET, Panjab University Page 42
  • 43. Microprocessor 8085 Prac Course File 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. UIET, Panjab University Page 43
  • 44. Microprocessor 8085 Prac Course File 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. UIET, Panjab University Page 44
  • 45. Microprocessor 8085 Prac Course File 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 UIET, Panjab University Page 45
  • 46. Microprocessor 8085 Prac Course File EXPERIMENT-17: Multiply two 8-bit numbers. AIM: WAP to multiply two 8-bit numbers. UIET, Panjab University Page 46
  • 47. Microprocessor 8085 Prac Course File 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. UIET, Panjab University Page 47
  • 48. Microprocessor 8085 Prac Course File 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 UIET, Panjab University Page 48
  • 49. Microprocessor 8085 Prac Course File EXPERIMENT-18: Find square of an 8-bit number. AIM: WAP to find square of an 8-bit number UIET, Panjab University Page 49
  • 50. Explanation: Microprocessor 8085 Prac Course File 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 UIET, Panjab University Page 50
  • 51. Microprocessor 8085 Prac Course File 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 UIET, Panjab University Page 51
  • 52. Microprocessor 8085 Prac Course File EXPERIMENT-19: Larger of two 8-bit numbers. AIM: WAP to find larger of two 8-bit numbers. UIET, Panjab University Page 52
  • 53. Explanation: Microprocessor 8085 Prac Course File 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. UIET, Panjab University Page 53
  • 54. Microprocessor 8085 Prac Course File 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 UIET, Panjab University Page 54
  • 55. Microprocessor 8085 Prac Course File EXPERIMENT-20: Smaller of two 8-bit numbers. AIM: WAP to find smaller of two 8-bit numbers. UIET, Panjab University Page 55
  • 56. Microprocessor 8085 Prac Course File 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. UIET, Panjab University Page 56
  • 57. Microprocessor 8085 Prac Course File 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 UIET, Panjab University Page 57
  • 58. Microprocessor 8085 Prac Course File 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 Register Pair Initialization MOV R,M Memory Read MOV M,R Memory Write INX Rp Pointer Increment ADD M Addition with Memory Contents MVI R, 8 bit data Register initialization JNC 16-bit address Branching Instruction DCR R Decrement 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. UIET, Panjab University Page 58
  • 59. Microprocessor 8085 Prac Course File EXPERIMENT-22: Find no. of negative elements in a block of data Instruction Used with description UIET, Panjab University Page 59
  • 60. Microprocessor 8085 Prac Course File 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 : Initialize counter START : LXI H, 2200H : Initialize memory pointer MVI C, 09H : Initialize counter 2 BACK: MOV A, M : Get the number UIET, Panjab University Page 60
  • 61. Microprocessor 8085 Prac Course File INX H CMP M : Increment memory pointer : Compare number with next number JC SKIP : If less, don't interchange JZ SKIP : 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 UIET, Panjab University Page 61
  • 62. Microprocessor 8085 Prac Course File 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 : Save flags on stack POP H : Retrieve flags in 'L' MOV A, L :Flags in accumulator CMA :Complement accumulator MOV L, A :Accumulator in 'L' PUSH H :Save on stack POP PSW :Back to flag register HLT :Terminate program execution UIET, Panjab University Page 62
  • 63. Microprocessor 8085 Prac Course File 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: UIET, Panjab University Page 63
  • 64. Microprocessor 8085 Prac Course File Before Execution: 4200H = 04H 4201H = 10H 4202H = 45H 4203H = 33H 4204H = 22H After Execution: Result = 10 +41 + 30 + 12 = H 4300H = H 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 UIET, Panjab University Page 64
  • 65. Microprocessor 8085 Prac Course File 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 UIET, Panjab University Page 65
  • 66. Microprocessor 8085 Prac Course File BACK: MOV A, L SUB C : Subtract divisor MOV L, A : Save partial result JNC SKIP : if CY 1 jump DCR H : Subtract borrow of previous subtraction SKIP: INX D : Increment quotient MOV A, H CPI, 00 : Check if dividend < divisor JNZ BACK : if no repeat MOV A, L CMP C JNC BACK SHLD 2302H : Store the remainder XCHG SHLD 2300H : Store the quotient HLT : 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 UIET, Panjab University Page 66
  • 67. Microprocessor 8085 Prac Course File 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 UIET, Panjab University Page 67
  • 68. Microprocessor 8085 Prac Course File BACK: LXI H, 2201H MOV A, M : Initialize pointer : Get the number ANI 80H : Check for MSB JZ SKIP : If MSB = 1 INR B SKIP: INX H : Increment negative number count : Increment pointer DCR C : Decrement count JNZ BACK MOV A, B : If count 0 repeat STA 2300H : Store the result HLT : 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 UIET, Panjab University Page 68
  • 69. Microprocessor 8085 Prac Course File 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 : Store maximum number HLT : Terminate program execution Output: Before Execution: (2200H) = 04 (2201H) = 34H (2202H) = A9H (2203H) = 78H (2204H) =56H After Execution: Result = (2202H) = A9H UIET, Panjab University Page 69
  • 70. Microprocessor 8085 Prac Course File 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. Source program : Flowchart MVI B, 00H MVI C, 08H MOV A, D BACK: RAR JNC SKIP UIET, Panjab University Page 70
  • 71. Microprocessor 8085 Prac Course File 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 UIET, Panjab University Page 71
  • 72. Microprocessor 8085 Prac Course File 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 : Initialize counter : Initialize source memory pointer 3l4FH LXI D, 314FH : Initialize destination memory pointer BACK: MOV A, M : Get byte from source memory block STAX D : Store byte in the destination memory block DCX H : Decrement source memory pointer DCX SP : Decrement destination memory pointer DCR C : Decrement counter JNZ BACK HLT : If counter 0 repeat : Stop execution UIET, Panjab University Page 72
  • 73. Microprocessor 8085 Prac Course File Appendix -1 : OPCODES TABLE OF INTEL 8085 in Alphabetical order UIET, Panjab University Page 73
  • 74. Microprocessor 8085 Prac Course File UIET, Panjab University Page 74
  • 75. Microprocessor 8085 Prac Course File UIET, Panjab University Page 75
  • 76. Microprocessor 8085 Prac Course File UIET, Panjab University Page 76
  • 77. Microprocessor 8085 Prac Course File UIET, Panjab University Page 77
  • 78. Microprocessor 8085 Prac Course File UIET, Panjab University Page 78
  • 79. Microprocessor 8085 Prac Course File Reference: www.eazynotes.com UIET, Panjab University Page 79