8086 Assemly


A simple 8086 program to check if a string is palindrome or not, using macros.

message macro arg
lea dx,arg
mov ax,0900h
int 21h
endm

data segment
cr equ 0dh
lf equ 0ah
sent db 25 dup(‘$’)
msg1 db “Enter the sentenc:$”
msg2 db cr,lf,”Sentence is not a palindrome$”
msg3 db cr,lf,”Sentence is a palindrome$”
data ends

code segment
assume cs:code,ds:data
start: mov ax,data
mov ds,ax
message msg1
mov ax,0000h
lea si,sent
read: mov ax,0100h
int 21h
cmp al,0dh
je next
cmp al,7ah
jg read
cmp al,60h
jg ahead
cmp al,5ah
jg read
add al,20h
ahead: mov [si],al
inc si
inc cl
jmp read
next: dec si
lea di,sent
check: mov bl,[di]
cmp [si],bl;
jne notpali
inc di
dec si
cmp di,si
jge paliok
jmp check
notpali: message msg2
jmp pgend
paliok: message msg3
pgend: mov ah,4ch
int 21h
code ends
end start

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s