Microprocessor and Interfacing
(MPI)
GTU # 3160712
Unit-5:
8085 Assembly
Language Programs
Positive Vibes:MPI is the interesting, easiest and scoring subject.
Prof. Swati R Sharma
Computer Engineering Department
Darshan Institute of Engineering & Technology, Rajkot
[email protected] (O) 9727747317
Subject Overview
Positive Vibes:MPI is the interesting, easiest and scoring subject.
Sr. No. Unit % Weightage
1 Introduction to Microprocessor 8%
2 Microprocessor Architecture and Operations 7%
3 8085 Microprocessor 12%
4 Assembly Language Programming Basics 13%
5 8085 Assembly Language Programs 12%
6 Stack & Subroutines 13%
7 I/O Interfacing 20%
8 Advanced Microprocessors 15%
Prof. Swati R Sharma Unit 5 – 8085 Assembly Language Programs 2
Topics
Loopingto be covered
Positive Vibes:MPI is the interesting, easiest and scoring subject.
Writing 8085 assembly language programs
Decision making programs
Looping using data transfer programs
Arithmetic, logical and branch instructions programs
Positive Vibes:MPI is the interesting, easiest and scoring subject.
Assembly Language Programs
Program-1
Write an ALP to add two 8-bit numbers. Add the value of carry to final Start
Positive Vibes:MPI is the interesting, easiest and scoring subject.
result and display the result to I/O port.
Load A and B
1. MVI A,3A with immediate
value
2. MVI B,20
3. ADD B AA+B
4. JC L1
5. JNC DISP Increment YES
Carry?
6. L1: INR A Result by 1
7. DISP: OUT 02 NO
Display result to
8. END: HLT I/O port
End
Prof. Swati R Sharma Unit 5 – 8085 Assembly Language Programs 5
Program-2
Write an ALP to display reverse counter at port 02H. Positive Vibes:MPI is the interesting, easiest and scoring subject.
Start
1. MVI A,0A ;counter
2. L1: OUT 02 Load & Display
Counter
3. DCR A ;A=A-1
4. JNZ L1 ;Z=0 Decrement A
5. HLT
NO
Z=1?
YES
End
Prof. Swati R Sharma Unit 5 – 8085 Assembly Language Programs 6
Program-3
Write an ALP to find 2’s compliment of M[2001]H and store result at M[2002]H.Positive Vibes:MPI is the interesting, easiest and scoring subject.
Start
1. LDA 2001
2. CMA Load AM[2001]
3. ADI 01
Complement
Accumulator
4. STA 2002
5. HLT 2’scomplement=
1’s complement +01
Store result
END
Prof. Swati R Sharma Unit 5 – 8085 Assembly Language Programs 7
Program-4
Write an ALP to multiply two 8-bit numbers stored at 2050H & 2051H using repetitive Load HL 2050
addition method. Positive Vibes:MPI is the interesting, easiest and scoring subject.
Load A 00
1. LXI H,2050
Load
2. MVI A,00
C M[2050](OP1)
3. MOV C,M; OP1 B M[2051](OP2)
4. INX H
HL HL+1
5. MOV B,M; OP2
6. L1: ADD C A A+C
7. DCR B Decrement B
8. JNZ L1 B B-1
9. HLT
NO
Z=1 ?
YES
End
Prof. Swati R Sharma Unit 5 – 8085 Assembly Language Programs 8
GTU Exam Questions
Sr. Questions Marks
Positive Vibes:MPI is the interesting, easiest and scoring subject. Year
1. Write assembly language program to do multiplication of two numbers. Specify the memory location of 7 W’19
each and every instruction and also draw flowchart.
Prof. Swati R Sharma Unit 5 – 8085 Assembly Language Programs 9
Program-4
Write an ALP to multiply two 8-bit numbers stored at 2050H & 2051H using repetitive Load HL 2050
addition method. Positive Vibes:MPI is the interesting, easiest and scoring subject.
Load A 00
Line Program PC Byte Load
0. - 0000 - C M[2050](OP1)
B M[2051](OP2)
1. LXI H,2050 0003 3
2. MVI A,00 0005 2
HL HL+1
3. MOV C,M 0006 1
4. INX H 0007 1 A A+C
5. MOV B,M 0008 1
Decrement B
6. L1: ADD C 0009 1
B B-1
7. DCR B 000A 1
8. JNZ L1 0008/000D 3 NO
9. HLT 1 Z=1 ?
YES
End
Prof. Swati R Sharma Unit 5 – 8085 Assembly Language Programs 10
Program-5
Write an ALP to add 10 blocks starting from 3001H to 300AH. Start
Positive Vibes:MPI is the interesting, easiest and scoring subject.
1. MVI A,00
2. MVI C,0A Load A00
Load C 0A
3. LXI H,3001 Load HL 3001
4. L1:ADC M
A A+M
5. INX H
6. DCR C Increment
HLHL+1
7. JNZ L1
Decrement Counter
8. HLT CC-1
NO
Z=1 ?
YES
END
Prof. Swati R Sharma Unit 5 – 8085 Assembly Language Programs 11
Program-6
Write a program to Set PSW (Accumulator & 8-bit Flag register)
Positive Vibes:MPI is the interesting, easiest and scoring subject.
1. LXI H, FFFF
2. PUSH H
3. POP PSW ;lower 8-bit to flags,higher 8-bit to Accumulator
4. HLT
Prof. Swati R Sharma Unit 5 – 8085 Assembly Language Programs 12
Program-7
Write a program to Reset PSW (Accumulator & 8-bit Flag register)
Positive Vibes:MPI is the interesting, easiest and scoring subject.
1. LXI H, 0000
2. PUSH H
3. POP PSW
4. HLT
Prof. Swati R Sharma Unit 5 – 8085 Assembly Language Programs 13
Program-8
Write an ALP to exchange block of 10 numbers with starting location Load HL 2001
Positive Vibes:MPI is the interesting, easiest and scoring subject.
M[2001] & M[3001] respectively. Load DE 3001
M[2001] 11
AA M[3001] AA
11 END
1. LXI H,2001
BB
22 Load Counter_C 0A
M[2002] BB
22 M[3002] YES
2. LXI D,3001
M[2003] 33
CC M[3003] CC
33 NO
3. MVI C,0A Z=1 ? Load B M[HL]
4. L1:MOV B,M C HL DE B A Z
5. LDAX D 03 2001 3001 11 AA 0
Decrement Counter C Load A M[DE]
6. MOV M,A
7. XCHG 02 3002 2002 BB 22
HL HL+1
Load M[HL] A
8. MOV M,B DE DE+1
9. INX H 01 2003 3003 33 CC
10. INX D Load M[HL] B Exchange HL ⇋ DE
11. DCR C 00 3004 2004 1
12. JNZ L1
13. HLT
Prof. Swati R Sharma Unit 5 – 8085 Assembly Language Programs 14
Exercise
Sr. Program Positive Vibes:MPI is the interesting, easiest and scoring subject.
1. Write an 8085 program to add two 16-bit nos stored in memory locations 2100H and 2200H respectively.
Prof. Swati R Sharma Unit 5 – 8085 Assembly Language Programs 15
GTU Exam Questions
Sr. Questions Marks
Positive Vibes:MPI is the interesting, easiest and scoring subject. Year
1. Write assembly language program to do multiplication of two numbers. Specify the memory location of 7 W’19
each and every instruction and also draw flowchart.
2. Write assembly language program to do division of two numbers. Specify the memory location of each and 7 W’19
every instruction and also draw flowchart.
3. Write assembly language program to do addition of two 8-bit numbers with carry. Specify the memory 7 W’19
location of each and every instruction.
4. Write assembly language program to count number of 1’s in given 8-bit number. Specify the memory 7 W’19
location of each and every instruction.
5. An array of Ten numbers is stored from memory location 2000H onwards. Write an 8085 assembly 7 S’19
language program to separate out and store the EVEN and ODD numbers on new arrays from 2100H and S’17
2200H, respectively. W’15
6. Write an 8085 assembly language program sort an array of twenty bytes stored on memory locations 7 S’19
2000H onwards in ascending/descending order. S’17
W’17
Prof. Swati R Sharma Unit 5 – 8085 Assembly Language Programs 16
References
Book: Microprocessor Architecture, Programming, and Applications with the
Positive 8085,
Vibes:MPI is the interesting, easiest and scoring subject.
Ramesh S. Gaonkar Pub: Penram International
Mobile 8085 and 8086 Microprocessor Opcodes app from Play Store:
Application http://tiny.cc/aopcodes
Prof. Swati R Sharma Unit 5 – 8085 Assembly Language Programs 17
Positive Vibes:MPI is the interesting, easiest and scoring subject.
Thank You