Google

Aug 30, 2008

check wether given 16 bit number is palindrome or not

Palindrome program taking 16 bits.

taking C7H,EBH as given data i have done the program
which is equivalant to 1101011111101011

ORG 2000H
LXI H,2100H ;DATAS ARE STORED AT LOCATIONS 2100H,21001H
MOV A,M
MVI C,07H

LOOP: RRC
CALL SBR ;SBR IS SUBROUTINE
DCR C
JNZ LOOP

ANI 01H
ADD D
INX H
CMP M
LXI H,2400H ;1 IS STORED AT MEM-LOC 2400H IF PALIIN ELSE 0
JZ PALIN
MVI M,00H
JMP FIN

PALIN: MVI M,01H
FIN: HLT

SBR: MOV B,A
MOV A,D
JNC BYPAS ;IF CARRY IS NOT 1 IS NOT AADED
ADI 01H
BYPAS: RLC
MOV D,A
MOV A,B
RET

ORG 2100H
DB 00C7H,00EBH ;DATA BYTE

END

here EBH is reversed and compared with C7H, if they are equal then plain else not palin


You might be also interested in:

:: Temperature Control system using 8086
:: Traffic light control system using 8086
:: Assembly Language Program to serve NMI
:: Interfacing Stepper Motor to 8086 using 8255

No comments: