- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
8085 program to count number of elements which are less than 0A
In this section we will count elements which are lesser than 0AH using 8085.
problem Statement
There is an array of some elements. Write 8085 Assembly language program to count number of elements that are lesser than 0AH.
Discussion
The array is placed at location F051H onwards. The F050 is holding the size of the array. The logic is simple. At first we will take the array size into the B register. The C register will count number of elements less than 0AH. We will take numbers one by one from memory, then compare it with 0A. if the CY flag is set it indicates that the Accumulator is holding smaller value, so increase C by one, otherwise ignore it.
Input
Address | Data |
---|---|
F050 | FE |
F051 | 02 |
F052 | 07 |
F053 | A5 |
F054 | 48 |
F055 | 08 |
Flow Diagram
program
Address | HEX Codes | Labels | Mnemonics | Comments |
---|---|---|---|---|
8000 | 21, 50, F0 | | LXI H,F050 | Point the memory location F050 |
8003 | 46 | | MOV B,M | Load size of the array to B |
8004 | 0E, 00 | | MVI C,00H | Clear C register to count numbers |
8006 | 23 | LOOP | INX H | Point to the first element of array |
8007 | 7E | | MOV A,M | Load memory element to Acc |
8008 | FE, 0A | | CPI 0AH | Compare Acc and 0AH |
800A | D2, 0E, 80 | | JNC SKIP | If number is greater, skip it |
800D | 0C | | INR C | Increase C by 1 |
800E | 05 | SKIP | DCR B | decrease B by 1 |
800F | C2, 06, 80 | | JNZ LOOP | If array is not completed, jump to Loop |
8012 | 79 | | MOV A,C | Take the number from C to A |
8013 | 32, 50, 51 | | STA F150 | Store result at F150H |
8016 | 76 | | HLT | Terminate the program. |
Output
Address | Data |
---|---|
F150 | 03 |
- Related Articles
- Count sub-arrays which have elements less than or equal to X in C++
- Python – Elements with factors count less than K
- Program to find list of elements which are less than limit and XOR is maximum in Python
- Program to find number of elements in A are strictly less than at least k elements in B in Python
- 8085 program to count number of once in the given 8-bit number
- Program to find sum of two numbers which are less than the target in Python
- Python Program to remove elements that are less than K difference away in a list
- C++ Program to count number of operations needed to place elements whose index is smaller than value
- Program to count number of elements are placed at correct position in Python
- Java Program to display a prime number less than the given number
- 8085 program to count the number of ones in contents of register B
- Number of elements less than or equal to a given number in a given subarray in C++
- Count the number of words having sum of ASCII values less than and greater than k in C++
- Program to count index pairs for which array elements are same in Python
- Program to count maximum number of distinct pairs whose differences are larger than target in Python

Advertisements