Palindrome or reversing the string
.model small
print macro w
mov ah,09h
lea dx,w
int 21h
endm
copy macro q
lea dx,q
mov ah,0ah
int 21h
endm
.data
a db 20 dup("$")
b db 20 dup("$")
msg1 db 0ah,0dh,"Enter
string is $"
msg2 db 0ah,0dh,"Reverse
string $"
msg3 db
0ah,0dh,"Palindrome $"
msg4 db 0ah,0dh,"Not
palindrome $"
.code
.startup
print msg1
copy a
print msg2
lea si,a
lea di,b
inc si
mov dl,[si]
mov dh,00h
add si,dx
mov cx,dx
push cx
l1:
mov bh,[si]
mov[di],bh
inc di
dec si
loop l1
print b
lea di,b
lea si,a
inc si
inc si
pop cx
l2: mov bh,[si]
cmp bh,[di]
jne l3
inc si
inc di
loop l2
print msg3
jmp l4
l3: print msg4
l4: mov ah,4ch
int
21h
.exit
End
Output:






0 comments:
Post a Comment