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

8086 Assembly program

A simple and complete 8086 assembly program to add numbers, using macros.

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

number macro arg
mov ax,arg
mov cx,0000h
mov bx,000ah
conv: mov dx,0000h
div bx
add dx,30h
push dx
inc cx
cmp ax,0000h
jnz conv
mov ax,0200h
disp: pop dx
int 21h
loop disp
endm
data segment
cr equ 0dh
lf equ 0ah
msg1 db cr,lf,”Enter a number:$”
msg2 db cr,lf,”the sum is:$”
num1 dw 1
num2 dw 1
num3 dw 1
data ends
code segment
assume cs:code,ds:data
start: mov ax,data
mov ds,ax
message msg1
mov ax,0100h
int 21h
sub al,30h
cmp al,0ah
jnc store1
sub al,07h
store1: mov num1,ax
message msg1
mov ax,0100h
int 21h
sub al,30h
cmp al,0ah
jnc store2
sub al,07h
store2: mov num2,ax
mov ax,num1
add ax,num2
mov num3,ax
message msg2
number num3
pgend: mov ah,4ch
int 21h
code ends
end start