Theory:
Given no stored in memory location C040h and find number is even or odd. To check no is odd or even we just check last bit of number is LSB bit is 0 then number is even and if LSB bit is 1 then number is odd. To do this we just perform AND operation of accumulator with 01H. If number is even then 01 stored in C050h location and if odd then 01 stored in C051h location.
Program:
LXI H,C040H
MOV A,M
ANI 01h
JNZ odd
MVI a,01h
STA C050h
HLT
odd: STA C051;
HLT
Input:
C040: 45h
Output:
C051: 01h
0 Comments