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

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