Problem – Write an assembly language program in 8085 microprocessor to count number of elements which are less than 0A in series of 10 numbers.
Assumption – Series of 10 numbers is stored from starting memory location 2050. Value of count is stored at memory location 3050
- Initialize register H with 20 and register L with 4F so that indirect memory points to memory location 204F.
- Initialize register C with 00 and register D with 0A.
- Increment indirect memory by 01.
- Move the content of M in accumulator A.
- Compare the content of A with 0A by help of CPI instruction. This instruction will update flags of 8085.
- Check if carry flag is set, if true then increment content of C by 01.
- Decremented content of D by 01.
- Check if zero flag is reset, if true then jump to step 3.
- Move the content of C to A.
- Store the content of A to memory location 3050.
|2000||LXI H 204F||H <- 20, L <- 4F|
|2003||MVI C, 00||C <- 00|
|2005||MVI D, 0A||D <- 0A|
|2007||INX H||M <- M + 01|
|2008||MOV A, M||A <- M|
|2009||CPI 0A||A – 0A|
|200B||JNC 200F||Jump if CY = 0|
|200E||INR C||C <- C + 01|
|200F||DCR D||D <- D – 01|
|2010||JNZ 2007||Jump if ZF = 0|
|2013||MOV A, C||A <- C|
|2014||STA 3050||M <- A|
Explanation – Registers A, C, D, H, L are used for general purpose.
- LXI H 204F: assign 20 to register H and 4F to register L
- MVI C, 00: assign 00 to register C
- MVI D, 0A: assign 0A to register D
- INX H: increment indirect memory location by 01
- MOV A, M: moves the content of indirect memory location M to accumulator A
- CPI 0A: subtracts 0A from content of A and update the flags of 8085
- JNC 200F: jump to memory location 200F if CY = 0
- INR C: increment content of C by 01
- DCR D: decrement content of D by 01
- JNZ 2007: jump to memory location 2007 if ZF = 0
- MOV A, C: moves the content of C to A
- STA 3050: store the content of A in memory location 3050
- HLT: stops executing the program and halts any further execution
- 8085 program to count the number of ones in contents of register B
- 8085 program to count number of once in the given 8-bit number
- 8085 program to reverse 16 bit number
- 8085 program to check whether the given number is even or odd
- 8085 program to reverse 8 bit number
- 8085 program to convert an 8 bit number into Grey number
- 8085 program to convert an 8 bit BCD number into hexadecimal number
- 8085 program to determine if the number is prime or not
- 8085 program to check whether the given 16 bit number is palindrome or not
- 8085 program to find sum of digits of 8 bit number
- 8085 program to find square of a 8 bit number
- 8085 program to find nth power of a number
- 8085 program to convert a BCD number to binary
- 8085 program to find the factorial of a number
- 8085 program to find 1's and 2's complement of 8-bit number
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.