In this section we will count elements which are lesser than 0AH using 8085.
There is an array of some elements. Write 8085 Assembly language program to count number of elements that are lesser than 0AH.
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.
|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.|