assume cs:code,ds:data,es:data
data segment
org 2000h
msg1 db "enter your string",0dh,0ah,"$"
msg2 db "It is palindrom",0dh,0ah,"$"
msg3 db "It is not palindrom",0dh,0ah,"$"
msg4 db "Do you wish to continue y/n",0dh,0ah,"$"
org 4000h
strg1 db 50h dup(0h)
org 6000h
strg2 db 50h dup(0h)
data ends
code segment
start:
mov ax,data
mov ds,ax
mov es,ax
lea si,strg1
lea di,strg2
mov bx,0h
lea dx,msg1
mov ah,09h
int 21h
next_char:
mov ah,01h
int 21h
cmp al,0dh
je rev_string
inc bx
stosb
jmp next_char
rev_string:
mov cx,bx
dec di
nxt_byte:
mov al,[di]
mov [si],al
inc si
dec di
loop nxt_byte
lea si,strg1
lea di,strg2
mov cx,bx
cld
rep cmpsb
je palin
lea dx,msg3
mov ah,09h
int 21h
jmp next
palin:
lea dx,msg2
mov ah,09h
int 21h
next:
lea dx,msg4
mov ah,09h
int 21h
mov ah,01h
int 21h
cmp al,'y'
je start
cmp al,'n'
je terminate
jmp next
terminate:
mov ah,4ch
int 21h
code ends
end start