Tuesday, September 21, 2010

MASM Programs: Pallindrome

.model small
print macro q
lea dx,q
mov ah,09h
int 21h
endm
copy macro p
lea dx,p
mov ah,0ah
int 21h
endm
.data
a db 20h dup("$")
b db 20h dup("$")
d db 0ah,0dh,("$")
e db "enter a string $"
f db "reverse fo the string is $"
g db" pallindrome$"
h db "not pallindrome$"
.code
.startup
print e
print d
copy a
print d
print f
print d
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 d
print g
jmp l4
l3:
print d
print h
l4:
.exit
end


0 comments:

Post a Comment

Twitter Delicious Facebook Digg Stumbleupon Favorites More

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | coupon codes