Program to find out the number of even and odd numbers from a given series of 16 bit hexadecimal numbers.

The simplest logic to decide whether a binary number is even or odd is to check the least significant bit of the number. If the bit is zero, the number is even, else its odd. Check the LSB by rotating the number through carry flag and increment even or odd number counter.

ASSUME CS:CODE, DS:DATA

DATA SEGMENT

LIST DW 2357H,0a579H,0c2322H,0c91eH,0c0000H,0957H

COUNT EQU 006h

DATA ENDS

CODE SEGMENT

START: XOR BX,BX

XOR DX,DX

MOV AX,DATA

MOV DS,AX

MOV CL,COUNT

MOV SI, OFFSET LIST

AGAIN: MOV AX,[SI]

RPR AX,01

JC ODD

INC BX

JMP NEXT

ODD: INC DX

NEXT: ADD SI,02

DEC CL

JNZ AGAIN

MOV AH,4CH

INC 21H

CODE ENDS

END START

You might be also interested in:

:: Data transfer instructions of 8086 microprocessor

:: 8085 Microprocessor simulator for linux

::Interfacing pic microcontroller with LCD

:: Serial Port interfacing with atmega

Subscribe to:
Post Comments (Atom)

## 1 comment:

What Is rpr?

Post a Comment