A simple 8086 program to check if a string isĀ palindromeĀ or not, using macros.
message macro arg
lea dx,arg
mov ax,0900h
int 21h
endm
data segment
cr equ 0dh
lf equ 0ah
sent db 25 dup(‘$’)
msg1 db “Enter the sentenc:$”
msg2 db cr,lf,”Sentence is not a palindrome$”
msg3 db cr,lf,”Sentence is a palindrome$”
data ends
code segment
assume cs:code,ds:data
start: mov ax,data
mov ds,ax
message msg1
mov ax,0000h
lea si,sent
read: mov ax,0100h
int 21h
cmp al,0dh
je next
cmp al,7ah
jg read
cmp al,60h
jg ahead
cmp al,5ah
jg read
add al,20h
ahead: mov [si],al
inc si
inc cl
jmp read
next: dec si
lea di,sent
check: mov bl,[di]
cmp [si],bl;
jne notpali
inc di
dec si
cmp di,si
jge paliok
jmp check
notpali: message msg2
jmp pgend
paliok: message msg3
pgend: mov ah,4ch
int 21h
code ends
end start