8085 program to count total even numbers in series of 10 numbers

MicrocontrollerMicroprocessor8085

In this program we will see how to count number of even numbers in a block of elements.

Problem Statement

Write 8085 Assembly language program to count number of even numbers in a block of data, where the block size is 10D. The block is starting from location8000H.

Discussion

The Odd Even checking is very simple. we can determine one number is odd or even by checking only the LSb. When LSb is 1, the number is odd, otherwise it is even. In this program we are taking a number from memory and then ANDing01H with it. if the result is nonzero, then the number is odd, otherwise it is even.

Input

Address
Data
.
.
.
.
.
.
8000
DA
8001
53
8002
26
8003
41
8004
17
8005
AC
8006
78
8007
D8
8008
9C
8009
3F
.
.
.
.
.
.


Flow Diagram

Program

Address
HEX Codes
Labels
Mnemonics
Comments
F000
21, 00, 80


LXI H,8000H
Point to the starting byte
F003
0E, 0A


MVI C,0AH
Initialize count to 0AH
F005
06, 00


MVI B, 00H
Clear B register
F007
7E
LOOP
MOV A,M
Load the item from memory
F008
E6, 01


ANI 01H
AND A with01H
F00A
C2, 0E, F0


JNZ SKIP
If Z = 1, jump to skip
F00D
04


INR B
Increase B by1
F00E
23
SKIP
INX H
Point to next location
F00F
0D


DCR C
Decrease C by1
F010
C2, 07, F0


JNZ LOOP
if Z = 0, goto loop
F013
78


MOV A, B
Load the count to A
F014
32, 50, 80


STA 8050H
Store the result at 8050H
F017
76


HLT
Terminate the program


Output

Address
Data
.
.
.
.
.
.
8050
06
.
.
.
.
.
.
raja
Updated on 30-Jul-2019 22:30:24

Advertisements