For a program I'm making the user needs to enter a string and then it will be checked to see if it is a palindrome. So far I've managed to reverse the ordering of the string entered so that I have the original string and the reverse version of it.
The problem is that I don't know how to compare these two strings.
Please if you can help me I would appreciate it.
CR equ 13
LF equ 10
JMP START
prompt db CR,LF,'Please enter a word to be checked: $'
outmsg db CR,LF,'The reverse word is: $'
instring db 12,?,' $'
outstring db '????????????$'
correct db CR,LF,'The word that you have entered is a palindrome$'
incorrect db CR,LF,'The word that you have entered is not a palindrome$'
firstchar dw ?
START:
LEA DX,prompt
MOV AH,9
INT 21h
LEA DX,instring
MOV AH,0ah
INT 21h
LEA SI,instring
MOV BL,byte ptr[SI + 1]
INC BL
MOV BH,0
ADD SI,BX
LEA firstchar,instring+2
LEA DI,outstring
MOVECHAR:
MOV BH,byte ptr[SI]
MOV byte ptr[DI],BH
CMP SI,firstchar
JE DONE
DEC SI
INC DI
JMP MOVECHAR
DONE:
INC DI
MOV byte ptr[DI],'$'
LEA DX, outmsg
MOV AH,9
INT 21h
LEA DX,outstring
MOV AH,9
INT 21h
FINISH:
MOV AH,4ch
INT 21h