Tuesday, January 26, 2010

program on 8086 microprocessor

8086 programming

1. Program to display hello world

title Program to display hellow world

dosseg
.model small
.stack 100h

.data

string1 db "hellow world","$"

.code
main proc
mov ax,@data
mov ds,ax

mov dx,offset string1
mov ah,09h
int 21h
.exit
main endp
end main

2.Write a program to add two numbers which are in memory and store the sum at another varaible


dosseg
.model small
.stack 100h

.data

aa db 05h
bb db 08
cc db 00h

.code
main proc
mov ax,@data
mov ds,ax

mov al,aa
mov bl,bb
add al,bl
mov cc, al
.exit
main endp
end main


3.Write a program to transfer ten bytes of data from one array to another array


dosseg
.model small
.stack 100h

.data

aa db 01h,02h,03h,05h,07h
bb db 00h,00h,00h,00h,00h


.code
main proc
mov ax,@data
mov ds,ax

mov si,offset aa
mov di,offset bb
mov cx,0005h
aaa: mov al,[si]
mov [di],al
inc si
dec di
loop aaa

.exit
main endp
end main

4.Write a program to transfer ten words of data from one array to another array


dosseg
.model small
.stack 100h

.data

aa dw 0101h,0202h,0303h,0505h,0707h
bb dw 0000h,0000h,0000h,0000h,0000h


.code
main proc
mov ax,@data
mov ds,ax

mov si,offset aa
mov di,offset bb
mov cx,0005h
aaa: mov al,[si]
mov [di],al
inc si
inc di
loop aaa

.exit
main endp
end main

5.Write a program to add 10 bytes of data which are stored in memory and store the result in another memory location.

( suppose the sum donot exceeds ffh)
dosseg
.model small
.stack 100h

.data

aa db 01h,02h,03h,05h,07h
bb db 00h


.code
main proc
mov ax,@data
mov ds,ax

mov si,offset aa
mov cx,0005h
mov al,00h

aaa: add al,[si]
inc si
loop aaa
mov bb, al
.exit
main endp
end main

5.Write a program to add 10 bytes of data which are stored in memory and store the result in another memory location.

( suppose the sum exceeds ffh) ( program using ptr operator)
dosseg
.model small
.stack 100h

.data

aa db 01h,02h,03h,05h,07h
bb dw 0000h


.code
main proc
mov ax,@data
mov ds,ax

mov si,offset aa
mov cx,0005h
mov al,00h
mov bh,00h

aaa: add al,[si]
jnc down
inc bh
down:
inc si
loop aaa
mov byte ptr bb,al
mov byte ptr bb+1 ,bh

.exit
main endp
end main

7.Write a program to add 10 words of data which are stored in memory and store the result in another memory location.

( suppose the sum exceeds ffffh) ( program using ptr operator)
dosseg
.model small
.stack 100h

.data

aa dw ff001h,ff02h,d403h,e005h,f007h
bb dd 00000000h


.code
main proc
mov ax,@data
mov ds,ax

mov si,offset aa
mov cx,0005h
mov ax,0000h
mov bx,0000h

aaa: add ax,[si]
jnc down
inc bx
down:
inc si
inc si
loop aaa
mov word ptr bb,al
mov word ptr bb+2 ,bx

.exit
main endp
end main