8085 program to check whether the given number is even or odd


In this program we will see how to check whether a number is odd or even.

Problem Statement

Write 8085 Assembly language program to check whether a number is odd or even.

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

first input

Address
Data
.
.
.
.
.
.
8000
15
.
.
.
.
.
.

second input

Address
Data
.
.
.
.
.
.
8000
2C
.
.
.
.
.
.


Flow Diagram

Program

Address
HEX Codes
Label
Mnemonics
Comments
F000
3A, 00, 80


LDA 8000H
Load the number from memory
F003
E6, 01


ANI 01H
AND 01H with Acc content
F005
CA, 0D, F0


JZ EVEN
If Z = 0, it is Even
F008
3E, 01


MVI A, 01H
Load 01H to indicate it is Odd
F00A
C3, 0F, F0


JMP STORE
Jump to store
F00D
3E, FF
EVEN
MVI A, FFH
Load FFH to indicate it is Even
F00F
32, 50, 80
STORE
STA 8050H
Store the result into memory
F012
76


HLT
Terminate the program


Output

first input

Address
Data
.
.
.
.
.
.
8000
01
.
.
.
.
.
.

second input

Address
Data
.
.
.
.
.
.
8000
FF
.
.
.
.
.
.

Updated on: 30-Jul-2019

8K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements