At last! This head-breaking palindrome program is done…
; –ask string from user–
mov ah,0ah
lea dx,parameter
int 21h
mov ah,02
mov dl,0ah
int 21h
mov dl,0dh
int 21h
;–intialize–
mov cx, 0 ; or xor cx, cx –for making cx=0
lea si, namefield ; load address of namespace
mov cl, [actlen] ; cl refers to the length of the string
dec cl ; strings start at 0 and ends at [actlen]-1
lea di, namefield ; load address of namespace
add di, cx ; di now points to the last character of string
mov ah, 09 ; print string function
compare:
mov cl, [si] ; get character from si
mov ch, [di] ; get character from di
cmp cl, ch ; compare two characters
jne stop ; if not equal, not palindrome
inc si
dec di
cmp di, si ; check if si>di
jns compare
lea dx, pal
int 21h
jmp exit
stop:
lea dx, notpal
int 21h
exit:
int 20h
parameter label byte
maxlen db 0FF
actlen db ?
namefield db 0FF dup(’$')
pal db ‘This string is a palindrome$’
notpal db ‘This string is not a palindrome$’
can you make a palindrome program in C!!!…
Posted by jennylyn at February 15, 2009, 9:45 pmwuhu.. tnx! pcopy ng prog muh.. atlast my palindrome n rin aq.. aus.. pasado n q sa finals!! haha..
Posted by thea at March 14, 2009, 12:42 pmAll comments are moderated. Your comments will not appear here unless approved by the blog owner. Thank you.
works! =) congrats =)
Posted by yue at July 29, 2006, 6:38 am