Chapter 5
Chapter 5
(MPI)
GTU # 3160712
Unit-5:
8085
Assembly
Language
Programs
Looping
Topics to be covered
Writing 8085 assembly language
programs
Decision making programs
Looping using data transfer programs
Arithmetic, logical and branch
instructions programs
Assembly Language
Programs
Program-1
Write an ALP to add two 8-bit numbers. Add the Start
value of carry to final result and display the result
to I/O port. Load A and
B with
1. MVI A,3A immediate
value
2. MVI B,20
3. ADD B AA+B
4. JC L1
5. JNC DISP Increment YES Carr
6. L1: INR A Result by 1 y?
7. DISP: OUT 02 NO
Display
8. END: HLT result to I/O
port
End
Program-2
Write an ALP to display reverse counter at port 02H.
Start
1. MVI A,0A ;counter
5. HLT
NO
Z=1?
YES
End
Program-3
Write an ALP to find 2’s compliment of M[2001] and store
result at M[2002]. Start
1. LDA 2001
Load AM[2001]
2. CMA
Complement
3. ADI 01
Accumulator
4. STA 2002 2’scomplement
=
5. HLT 1’s complement
+01
Store result
END
Program-4
Write an ALP to multiply two 8-bit numbers stored at 2050H Load HL 2050
& 2051H using repetitive addition method. Load A 00
1. LXI H,2050 Load
C M[2050]
2. MVI A,00
(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
GTU Exam Questions
Sr. Questions Marks Year
1. Write assembly language program to do multiplication of two numbers. Specify 7 W’19
the memory location of each and every instruction and also draw flowchart.
Program-5
Write an ALP to multiply two 8-bit numbers stored at 2050H Load HL 2050
& 2051H using repetitive addition method. Load A 00
Load
Lin Progra PC Byt C M[2050]
e m e (OP1)
0. - 0000 - B M[2051]
1. LXI 0003 3 (OP2)
H,2050 HL HL+1
2. MVI A,00 0005 2
A A+C
3. MOV C,M 0006 1
4. INX H 0007 1 Decrement B
5. MOV B,M 0008 1 B B-1
6. L1: ADD 0009 1
C NO Z=1
7. DCR B 000A 1 ?
8. JNZ L1 0009/00 3 YES
0D End
9. HLT 1
Program-6
Write an ALP to add 10 blocks starting from 3001H Start
to 300AH.
1. MVI A,00 Load A00
2. MVI C,0A Load C 0A
Load HL 3001
3. LXI H,3001
4. L1:ADC M A A+M
5. INX H Increment
6. DCR C HLHL+1
7. JNZ L1 Decrement
Counter CC-1
8. HLT
NO Z=1
?
YES
END
Program-7
Write a program to Set PSW (Accumulator & 8-bit Flag register)
1. LXI H, FFFF
2. PUSH H
4. HLT
Program-8
Write a program to Reset PSW (Accumulator & 8-bit Flag register)
1. LXI H, 0000
2. PUSH H
3. POP PSW
4. HLT
Program-9
Write an ALP to exchange block of 10 numbers Load HL 2001
with starting locationM[200
M[2001] M[300
& M[3001] Load DE 3001
11
AA AA
11 END
respectively. Load Counter_C
1] 1] 22
BB
BB
22 YES 0A
1. LXI H,2001
M[200 M[300 CC
33
33
CC NO
2. LXI D,3001 2] 2] Z=1
Load B M[HL]
3. MVI C,0A C HLM[200DE B M[300
A Z ?
4. L1:MOV B,M 3] 3]
03 2001 3001 11 AA 0 Decrement
Load A M[DE]
5. LDAX D Counter C
6. MOV M,A 02 3002 2002 BB 22
HL HL+1
7. XCHG Load M[HL] A
DE DE+1
8. MOV M,B 01 2003 3003 33 CC
Exchange HL ⇋
9. INX H Load M[HL] B
DE
10. INX D 00 3004 2004 1
11. DCR C
12. JNZ L1
13. HLT
Exercise
Sr. Program
1. Write an 8085 program to add two 16-bit nos stored in memory locations 2100H and 2200H
respectively.
Lab assignment
Sr Questions Marks
.
1. Write assembly language program to do multiplication of two numbers. Specify the 3
memory location of each and every instruction and also draw flowchart.
2. Write assembly language program to do division of two numbers. Specify the 3
memory location of each and every instruction and also draw flowchart.
3. Write assembly language program to do addition of two 8-bit numbers with carry. 3
Specify the memory location of each and every instruction.
4. Write assembly language program to count number of 1’s in given 8-bit number. 3
Specify the memory location of each and every instruction.
5. An array of Ten numbers is stored from memory location 2000H onwards. Write an 3
8085 assembly language program to separate out and store the EVEN and ODD
numbers on new arrays from 2100H and 2200H, respectively.
6. Write an 8085 assembly language program sort an array of twenty bytes stored on 3
memory locations 2000H onwards in ascending/descending order.
References
Book: Microprocessor Architecture, Programming, and Applications with
the 8085, Ramesh S. Gaonkar Pub: Penram International
Mobile 8085 and 8086 Microprocessor Opcodes app from Play Store:
Applicatio http://tiny.cc/aopcodes
n
Thank You