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


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

Problem Statement

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

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 ANDing 01H 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 with 01H
F00A
CA, 0E, F0
 
JZ SKIP
If Z = 0, jump to skip
F00D
04
 
INR B
Increase B by 1
F00E
23
SKIP
INX H
Point to next location
F00F
0D
 
DCR C
Decrease C by 1
F010
C2, 07, F0
 
JNZ LOOP
if Z = 0, go to 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
04

.

.

.

.

.

.

 

 

 

 

 

Updated on: 30-Jul-2019

1K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements