This document contains several 8085 assembly language programs with the following topics:
1. Programs 1-5 demonstrate arithmetic, logical, and branch instructions through programs that add numbers, find complements, multiply and add arrays.
2. Programs 6-7 set and reset the program status word register.
3. Program 8 exchanges blocks of memory between two locations.
4. The document provides the memory location of each instruction and flowcharts for several programs. It also includes exam questions about multiplication, division, addition with carry, and counting bits in an 8-bit number.
2. Looping
Topics to be covered
Writing 8085 assembly language programs
Decision making programs
Looping using data transfer programs
Arithmetic, logical and branch instructions programs
3.
4. Program-1
Write an ALP to add two 8-bit numbers. Add the value of carry to final
result and display the result to I/O port.
Start
Load A and B
with immediate
value
AA+B
Carry?
Increment
Result by 1
Display result to
I/O port
End
YES
NO
1. MVI A,3A
2. MVI B,20
3. ADD B
4. JC L1
5. JNC DISP
6.L1: INR A
7.DISP: OUT 02
8.END: HLT
5. Program-2
Write an ALP to display reverse counter at port 02H.
1. MVI A,0A ;counter
2.L1: OUT 02
3. DCR A ;A=A-1
4. JNZ L1 ;Z=0
5. HLT
Start
Load & Display
Counter
Decrement A
Z=1?
End
YES
NO
6. Program-3
Write an ALP to find 2’s compliment of M[2001] and store result at M[2002].
1. LDA 2001
2. CMA
3. ADI 01
4. STA 2002
5. HLT
Load AM[2001]
2’scomplement=
1’s complement +01
Complement
Accumulator
Store result
END
Start
7. Program-4
Write an ALP to multiply two 8-bit numbers stored at 2050H & 2051H using repetitive
addition method.
1. LXI H,2050
2. MVI A,00
3. MOV C,M; OP1
4. INX H
5. MOV B,M; OP2
6. L1: ADD C
7. DCR B
8. JNZ L1
9. HLT
Z=1 ?
End
Load HL 2050
Load A 00
YES
Decrement B
B B-1
Load
C M[2050](OP1)
B M[2051](OP2)
A A+C
NO
HL HL+1
8. Exam Questions
No Questions
1. Write assembly language program to do multiplication of two numbers. Specify the memory location
of each and every instruction and also draw flowchart.
9. Program-4
Write an ALP to multiply two 8-bit numbers stored at 2050H & 2051H using repetitive
addition method.
Z=1 ?
End
Load HL 2050
Load A 00
YES
Decrement B
B B-1
Load
C M[2050](OP1)
B M[2051](OP2)
A A+C
NO
HL HL+1
Line Program PC Byte
0. - 0000 -
1. LXI H,2050 0003 3
2. MVI A,00 0005 2
3. MOV C,M 0006 1
4. INX H 0007 1
5. MOV B,M 0008 1
6. L1: ADD C 0009 1
7. DCR B 000A 1
8. JNZ L1 0009/000D 3
9. HLT 1
10. Program-5
Write an ALP to add 10 blocks starting from 3001H to 300AH.
1. MVI A,00
2. MVI C,0A
3. LXI H,3001
4. L1:ADC M
5. INX H
6. DCR C
7. JNZ L1
8. HLT
Z=1 ?
Load A00
Load C 0A
Load HL 3001
YES
A A+M
NO
Increment
HLHL+1
END
Decrement Counter
CC-1
Start
11. Program-6
Write a program to Set PSW (Accumulator & 8-bit Flag register)
1. LXI H, FFFF
2. PUSH H
3. POP PSW ;lower 8-bit to flags,higher 8-bit to Accumulator
4. HLT
12. Program-7
Write a program to Reset PSW (Accumulator & 8-bit Flag register)
1. LXI H, 0000
2. PUSH H
3. POP PSW
4. HLT
13. Program-8
Write an ALP to exchange block of 10 numbers with starting location
M[2001] & M[3001] respectively.
1. LXI H,2001
2. LXI D,3001
3. MVI C,0A
4. L1:MOV B,M
5. LDAX D
6. MOV M,A
7. XCHG
8. MOV M,B
9. INX H
10. INX D
11. DCR C
12. JNZ L1
13. HLT
Load HL 2001
Load DE 3001
Load Counter_C 0A
Load B M[HL]
Load A M[DE]
Load M[HL] A
Exchange HL ⇋ DE
Load M[HL] B
HL HL+1
DE DE+1
Decrement Counter C
Z=1 ?
YES
END
NO
C HL DE B A Z
0
M[2001] M[3001]
M[2002] M[3002]
M[2003] M[3003]
11 AA
BB
22
CC
33
03 2001 3001 11 AA
AA 11
3002 2002
02 BB 22
22
BB
2003 3003
01 33 CC
CC 33
2004
3004
00 1
14. Exercise
Sr. Program
1. Write an 8085 program to add two 16-bit nos stored in memory locations 2100H and 2200H respectively.
15. Exam Questions
No Questions
1. Write assembly language program to do multiplication of two numbers. Specify the memory location of
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 every instruction and also draw flowchart.
3. Write assembly language program to do addition of two 8-bit numbers with carry. 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. Specify the memory
location of each and every instruction.
5. An array of Ten numbers is stored from memory location 2000H onwards. Write an 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 memory locations
2000H onwards in ascending/descending order.
16. References
Book: Microprocessor Architecture, Programming, and Applications with the 8085,
Ramesh S. Gaonkar Pub: Penram International
Mobile
Application
8085 and 8086 Microprocessor Opcodes app from Play Store:
http://tiny.cc/aopcodes