Logo 
Search:

Assembly Language Forum

Ask Question   UnAnswered
Home » Forum » Assembly Language       RSS Feeds

check palindrome using stack

  Asked By: Fatima    Date: Dec 12    Category: Assembly Language    Views: 1710
  

It should have to check whether given string is palindrome or not but it didn't work. Here is my code. Your help will be greatly appreciated.
<code>
.MODEL SMALL
.STACK 100h
.DATA
str1 db 'Enter a string:$'
str2 db 50 dup('$')
str3 db 'Palindrome$'
str4 db 'Nt Palindrome$'
count dw ?
.CODE
MAIN PROC

mov ax,@data
mov ds,ax

mov cx,0

mov dx,offset str1
mov ah,09h ;masm pali.asm;
int 21h

inpt: mov ah,01h
int 21h

cmp al,13
JE below

mov [si],al
inc si
inc cx
PUSH ax
JMP inpt

below: mov count,cx
pal: dec cx
dec si
cmp cx,0
JNE pal

SHR count,1
palii: POP ax
cmp ax,[si]
JNE ntp
inc si
dec count
JNZ palii

mov dx,offset str3
mov ah,09h
int 21h
JMP exit

ntp: mov dx,offset str4
mov ah,09h
int 21h

exit: mov ah,4ch
int 21h

MAIN ENDP
END MAIN
</code>

Share: 

 

No Answers Found. Be the First, To Post Answer.

 
Didn't find what you were looking for? Find more on check palindrome using stack Or get search suggestion and latest updates.




Tagged: