8085 programming
Write an assembly language program to add two 8 bit numbers
stored at address 2050 and address 2051
Algorithm
1. Load the first number from memory location 2050 to
accumulator.
2. Move the content of accumulator to register H.
3. Load the second number from memory location 2051 to
accumulator.
4. Then add the content of register H and accumulator using
“ADD” instruction and storing result at 3050
5. The carry generated is recovered using “ADC” command and is
stored at memory location 3051
pg. 1 By Prof.Panchal Ashok S. 9673610505 | 9763610505 12th 8085 Programming
Memory
Address Mnemonics Comment
2000 LDA 2050 A<-[2050]
2003 MOV H, A H<-A
2004 LDA 2051 A<-[2051]
2007 ADD H A<-A+H
2008 MOV L, A L←A
2009 MVI A 00 A←00
200B ADC A A←A+A+carry
200C MOV H, A H←A
H→3051,
200D SHLD 3050
L→3050
2010 HLT Stop
pg. 2 By Prof.Panchal Ashok S. 9673610505 | 9763610505 12th 8085 Programming
Write an assembly language program in 8085 microprocessor
to reverse 8-bit numbers.
Assume that number to be reversed is stored at memory location
2050, and reversed number is stored at memory location 3050.
Algorithm –
1. Load content of memory location 2050 in accumulator A
2. Use RLC instruction to shift the content of A by 1 bit without
carry. Use this instruction 4 times to reverse the content of A
3. Store content of A in memory location 3050
pg. 3 By Prof.Panchal Ashok S. 9673610505 | 9763610505 12th 8085 Programming
MEMORY MNEMONICS COMMENT
ADDRESS
2000 LDA 2050 A <- M[2050]
2003 RLC Rotate content of accumulator
left by 1 bit
2004 RLC Rotate content of accumulator
left by 1 bit
2005 RLC Rotate content of accumulator
left by 1 bit
2006 RLC Rotate content of accumulator
left by 1 bit
2007 STA 3050 M[2050] <- A
200A HLT END
Write an assembly language program in 8085 microprocessor
to reverse 16 bit number.
Assume 16 bit number is stored at memory location 2050 and 2051.
Algorithm –
1. Load contents of memory location 2050 in register L and
contents of memory location 2051 in register H
pg. 4 By Prof.Panchal Ashok S. 9673610505 | 9763610505 12th 8085 Programming
2. Move contents of L in accumulator A
3. Reverse the contents of A by executing RLC instruction 4 times
4. Move the contents of A in L
5. Move the contents of H in A
6. Reverse the contents of A by executing RLC instruction 4 times
7. Move the contents of L in H
8. Move the contents of A in L
9. Store the content of L in memory location 2050 and contents
of H in memory location 2051
pg. 5 By Prof.Panchal Ashok S. 9673610505 | 9763610505 12th 8085 Programming
MEMORY
ADDRESS MNEMONICS COMMENT
2000 LHLD 2050 L <- M[2050], H <- M[2051]
2003 MOV A, L A <- L
Rotate accumulator content left by 1
2004 RLC
bit without carry
Rotate accumulator content left by 1
2005 RLC
bit without carry
Rotate accumulator content left by 1
2006 RLC
bit without carry
Rotate accumulator content left by 1
2007 RLC
bit without carry
2008 MOV L, A L <- A
2009 MOV A, H A <- H
pg. 6 By Prof.Panchal Ashok S. 9673610505 | 9763610505 12th 8085 Programming
Rotate accumulator content left by 1
200A RLC
bit without carry
Rotate accumulator content left by 1
200B RLC
bit without carry
Rotate accumulator content left by 1
200C RLC
bit without carry
Rotate accumulator content left by 1
200D RLC
bit without carry
200E MOV H, L H <- L
200F MOV L, A L <- A
2010 SHLD 2050 M[2050] <- L, M[2051] <- H
2013 HLT END
pg. 7 By Prof.Panchal Ashok S. 9673610505 | 9763610505 12th 8085 Programming
Write an assembly language program in 8085 microprocessor to
check whether the 8 bit number which is stored at memory
location 2050 is even or odd. If even, store 22 at memory location
3050 otherwise store 11 at memory location 3050.
MEMORY ADDRESS MNEMONICS COMMENT
2000 LDA 2050 A <- M[2050]
2003 ANI 01 A <- A (AND) 01
2005 JZ 200D Jump if ZF = 1
2008 MVI A 11 A <- 11
200A JMP 200F Jump to memory location
200D MVI A 22 A <- 22
200F STA 3050 M[3050] <- A
2012 HLT END
Write an assembly language program in 8085 microprocessor to
find square of 8 bit number
pg. 8 By Prof.Panchal Ashok S. 9673610505 | 9763610505 12th 8085 Programming
MEMORY ADDRESS MNEMONICS COMMENT
2000 MVI H 20 H <- 20
2002 MVI L 50 L <- 50
2004 MVI A 00 A <- 00
2006 MOV B, M B <- M
2007 ADD M A <- A + M
2008 DCR B B <- B – 01
2009 JNZ 2007 Jump if ZF = 0
200C STA 3050 M[3050] <- A
200F HLT END
Write an assembly language program to find smallest
number between two number’s.
pg. 9 By Prof.Panchal Ashok S. 9673610505 | 9763610505 12th 8085 Programming
Algorithm –
1. Load the content from memory location
2. Move content of Accumulator into Register B
3. Load the content from Memory location
4. Compare the content of Register B
pg. 10 By Prof.Panchal Ashok S. 9673610505 | 9763610505 12th 8085 Programming
5. If carry flag is equal to 1 go to step 7
6. Move content of Register B into Accumulator
7. Store the content into Memory
8. End of program
Memory Mnemonics Use Operand Comments
2000 LDA [2500] [A]<-[2500]
2003 MOV B, A [B]<-[A]
2004 LDA 2501 [A]<-[2501]
2007 CMP B [A]<-[A]-[B]
2008 JC * [200C] jump carry
200B MOV A, B [A]<-[B]
200C STA [2502] [A]->[2502]
200F HLT STOP
pg. 11 By Prof.Panchal Ashok S. 9673610505 | 9763610505 12th 8085 Programming
Write a program to find 1’s and 2’s complement of 16-bit number
where starting address is 2000 and the number is stored
at 3000 memory address and store result
into 3002 and 3004 memory address.
Algorithm –
1. Load a 16-bit number from memory 3000 into a register pair
(H-L)
2. Move content of register L to accumulator
3. Complement content of accumulator
4. Move content of accumulator to register L
5. Move content of register H to accumulator
6. Complement content of accumulator
7. Move content of accumulator to register H
8. Store content of register pair in memory 3002
(1’s complement)
pg. 12 By Prof.Panchal Ashok S. 9673610505 | 9763610505 12th 8085 Programming
9. Increment content of register pair by 1
10. Store content of register pair in memory 3004
(2’s complement)
11. Stop
Memory Mnemonics Operands Comment
2000 LHLD [3000] [H-L] <- [3000]
2003 MOV A, L [A] <- [L]
2004 CMA [A] <- [A^]
2005 MOV L, A [L] <- [A]
2006 MOV A, H [A] <- [H]
2007 CMA [A] <- [A^]
2008 MOV H, A [H] <- [A]
2009 SHLD [3002] 1’s complement
200C INX H [H-L] <- [H-L] + 1
200D SHLD [3004] 2’s complement
2010 HLT Stop
pg. 13 By Prof.Panchal Ashok S. 9673610505 | 9763610505 12th 8085 Programming
pg. 14 By Prof.Panchal Ashok S. 9673610505 | 9763610505 12th 8085 Programming
Write a program to add 2-BCD numbers where starting address
is 2000 and the numbers is stored at 2500 and 2501 memory
addresses and store sum into 2502 and carry into 2503 memory
address.
Algorithm –
1. Load 00H in a register (for carry)
2. Load content from memory into register pair
3. Move content from L register to accumulator
4. Add content of H register with accumulator
5. Add 06H if sum is greater than 9 or Auxiliary Carry is not zero
6. If carry flag is not equal to 1, go to step 8
7. Increment carry register by 1
8. Store content of accumulator into memory
9. Move content from carry register to accumulator
10. Store content of accumulator into memory
11. Stop
pg. 15 By Prof.Panchal Ashok S. 9673610505 | 9763610505 12th 8085 Programming
Memory Mnemonics Operands Comment
2000 MVI C, 00H [C] <- 00H, carry
2002 LHLD [2500] [H-L] <- [2500]
2005 MOV A, L [A] <- [L]
2006 ADD H [A] <- [A] + [H]
2007 DAA Add 06 if sum > 9 or AC = 1
2008 JNC 200C Jump if no carry
200B INR C [C] <- [C] + 1
200C STA [2502] [A] -> [2502], sum
200F MOV A, C [A] <- [C]
2010 STA [2503] [A] -> [2503], carry
2013 HLT Stop
Write an assembly language program for calculating the factorial
of a number using 8085 microprocessor.
Algorithm –
pg. 16 By Prof.Panchal Ashok S. 9673610505 | 9763610505 12th 8085 Programming
1. Load the data into register B
2. To start multiplication set D to 01H
3. Jump to step 7
4. Decrements B to multiply previous number
5. Jump to step 3 till value of B>0
6. Take memory pointer to next location and store result
7. Load E with contents of B and clear accumulator
8. Repeatedly add contents of D to accumulator E times
9. Store accumulator content to D
10. Go to step 4
Address Label Mnemonic Comment
2000H Data Data Byte
Result of
2001H Result
factorial
Load data
2002H LXI H, 2000H from
memory
Load data to
2005H MOV B, M
B register
Set D register
2006H MVI D, 01H
with 1
pg. 17 By Prof.Panchal Ashok S. 9673610505 | 9763610505 12th 8085 Programming
Address Label Mnemonic Comment
Subroutine
2008H FACTORIAL CALL MULTIPLY call for
multiplication
200BH DCR B Decrement B
Call factorial
200CH JNZ FACTORIAL till B
becomes 0
Increment
200FH INX H
memory
Store result
2010H MOV M, D
in memory
2011H HLT Halt
Transfer
2100H MULTIPLY MOV E, B contents of B
to C
Clear
accumulator
2101H MVI A, 00H
to store
result
pg. 18 By Prof.Panchal Ashok S. 9673610505 | 9763610505 12th 8085 Programming
Address Label Mnemonic Comment
Add contents
2103H MULTIPLYLOOP ADD D
of D to A
2104H DCR E Decrement E
JNZ Repeated
2105H
MULTIPLYLOOP addition
Transfer
2108H MOV D, A contents of A
to D
Return from
2109H RET
subroutine
pg. 19 By Prof.Panchal Ashok S. 9673610505 | 9763610505 12th 8085 Programming