Sunday, August 14

Determining If The String Input Is Palindrome Or Not Using Assembly Programming Language


.model small
.code
org 100h
jmp process
                parlist label byte
                maxlen db 30
                actlen db ?
                kbdata db 30 dup('')
                intro db 'Enter Word','$'
                p db 'PALINDROME','$'
                np db 'NOT PALINDROME','$'
process proc near
                call clr_scr
                mov dx,0000h
                call set_cur
                call printing
                mov dx,0305h
                call set_cur
                call input
                mov dx,0505h
                call set_cur
                mov si,00
                mov bl,actlen
                mov bh,00h
                sub bx,01h
                mov di,bx
                call processing
process endp
input:
                mov ah,0ah
                lea dx,parlist
                int  21h
                cmp actlen,00h
                je term
                ret
term:
                int 20h
processing:
                cmp si,bx
                je printing1
                mov dh,kbdata[si]
                mov dl,kbdata[di]
                inc si
                dec di
                cmp dh,dl
                je processing
                jne printing2
               
printing1:
                mov ah,09h
                lea dx,p
                int 21h
                ret
printing2:
                mov ah,09h
                lea dx,np
                int 21h
                ret
printing:
                mov ah,09h
                lea dx,intro
                int 21h
                ret
clr_scr:
                mov ax,0600h
                mov bh,07h
                mov cx,0000h
                mov dx,184fh
                int 10h
                ret
set_cur:
                mov ah,02h
                mov bh,00h
                int 10h
                ret

end process


/*Program Preview*/



No comments:

Post a Comment