Check for EVEN or ODD of 8-bit Number in 8085 Microprocessor

Check EVEN/ODD of an 8-bit Number: In this tutorial, we will learn how to check whether a given 8-bit number is EVEN or ODD in 8085 Microprocessor? By Shivakshi Dhiman Last updated : May 13, 2023

Check whether a given 8-bit number is EVEN or ODD in 8085 Microprocessor

Problem Statement

The given number is an EVEN number if its lower bit is 0 i.e. low otherwise number is ODD.

To check whether the number is odd or even, we perform AND operation with 01 by using ANI instruction. If the number is even then we will get 00 otherwise 01 in the accumulator. We use 11 to represent odd numbers and 22 to represent even numbers.

Algorithm

  1. Load the accumulator with the first data.
  2. Perform AND operation with 01 on first data using ANI Instruction.
  3. Check if zero flag is set then set the value of accumulator to 22 otherwise 11 to accumulator.
  4. Now load the result value in memory location.

Program

LDA     2050
ANI     01
JZ **
MVI     A 11
JMP ***
** MVI A 22
***STA 3050
HLT

Observation

INPUT:
2050:05
3050:11

OUTPUT:
3052:02
3053:00



Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.