0
(0)

[PRACTICAL] IMPLEMENT A PROGRAM TO COMPARE TWO NUMBERS

Are you looking for a step-by-step guide to Implement a program to compare two numbers? here are the steps to implement a program to compare two numbers.

Theory:

Comparison of two number is done by checking value CY and ZF flags.

 CYZF
< (R)10
= (R)01
> (R)00

After compare two value CY and ZF are set or reset according to value and depend on this two flag we can identify value is less than, greater than or equal. One number is stored in C050h and other number is 05h.

 If ((A) = (R) ) then

 stored in C051h

else if ((A) < (R) ) then

stored in C052h

else if ((A) > (R)) then

stored in C053h

Program:

LXI H C050h
MOV A,M
CPI 05h
JZ NEXT
JC THIRD
STA C053h
HLT
NEXT: JNC SECOND
HLT
SECOND: STA C051h
HLT
THIRD: STA C052h
HLT

Input:

C050: 06h

Output:

C053: 06h

For more practical related to 885 Programming please visit the 8085 Programming link

How useful was this post?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate this post.

As you found this post useful...

Share this post on social media!

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?