Vous êtes sur la page 1sur 19

Microprocessor-8086 Lab Manual

1. Programs involving data transfer instruction


1. Write an ALP to transfer a word data in different addressing modes.
.model small
.stack[100]
.data
num dw 4321h
.code
Mov ax,@data
Mov ds,ax
mov dx,2222h
Mov ax,1234h ;immediate addressing
Mov bx,ax ;register addressing
Mov ax,num ;direct addressing
Mov si,1000h
mov [si],bl
Mov al,[si] ;indirect addressing
mov [si+100h],dl
Mov bl,[si+100h] ;relative addressing
Mov bx,1000h
mov [si+bx],3333h
Mov ax,[si+bx] ;base index addressing
mov [si+bx+100h],4444h
Mov cx,[si+bx+100h] ;relative base index addressing
Mov ah,4ch
Int 21h
End

2. Write an ALP to transfer a byte data in different addressing modes.

.model small
.stack[100]
.data
num db 4321h
.code
Mov ax,@data
Mov ds,ax
mov dl,22h
Mov al,12h ;immediate addressing
Mov bl,al ;register addressing
Mov al,num ;direct addressing
Mov si,1000h
mov [si],bl
Mov al,[si] ;indirect addressing
mov [si+100h],dl
Mov bl,[si+100h] ;relative addressing
Mov bx,1000h
mov [si+bx],33h
Mov al,[si+bx] ;base index addressing
mov [si+bx+100h],44h
Mov cl,[si+bx+100h] ;relative base index addressing
Mov ah,4ch
Int 21h
End

3. Write an ALP to transfer a block of data byte from one memory location to another
without overlap.

.model small

.stack[100]

.data

n1 db 11h,12h,13h,14h,15h

n2 db 5 dup(0)

.code

mov ax,@data

mov ds,ax

mov cx,04h

lea si,n1

lea di,n2

loc: mov dl,[si]

mov [di],dl

inc si

inc di

dec cx

jnz loc

mov ah,4ch

int 21h

end
4. Write an ALP to transfer a block of data word from one memory location to another
without overlap.

.model small

.stack[100]

.data

n1 dw 1111h,1112h,1223h,1224h,1225h,3456h,5678h,4444h

n2 dw 8 dup(0)

.code

mov ax,@data

mov ds,ax

mov cx,08h

lea si,n1

lea di,n

loc: mov dx,[si]

mov [di],dx

inc si

inc si

inc di

inc di

dec cx

jnz loc

mov ah,4ch

int 21h

end
5. a. Write an ALP to transfer a block of data byte from one memory location to
another with overlap.

.model small

.stack[100]

.data

n2 db 3 dup(0)

n1 db 11h,12h,13h,14h,15h

.code

mov ax,@data

mov ds,ax

mov cx,05h

lea si,n1

lea di,n2

loc: mov dl,[si]

mov [di],dl

inc si

inc di

dec cx

jnz loc

mov ah,4ch

int 21h

end

b. Write an ALP to transfer a block of data byte from one memory location to another
with overlap

.model small

.stack[100]

.data

n1 db 11h,12h,13h,14h,15h
n2 db 16h,17h,18h,19h,20h

.code

mov ax,@data

mov ds,ax

mov cx,05h

lea si,n1

lea di,n2

loc: mov dl,[si+4]

mov [di],dl

dec si

dec di

dec cx

jnz loc

mov ah,4ch

int 21h

end

6 Write an ALP to transfer a block of data word from one memory location to another
with overlap.

.model small

.stack[100]

.data

n2 dw 5 dup(0)

n1 dw 1111h,1112h,1223h,1224h,1225h,3456h,5678h,4444h

.code

mov ax,@data

mov ds,ax

mov cx,08h
lea si,n1

lea di,n2

loc: mov dx,[si]

mov [di],dx

inc si

inc si

inc di

inc di

dec cx

jnz loc

mov ah,4ch

int 21h

end

7. Write an ALP to Interchange a block of data from one memory location to another
without using ‘XCHG’ instruction.

.model small

.stack 256

.data

n1 db 11h,12h,13h,14h,15h

n2 db 22h,33h,44h,55h,66h

.code

mov ax,@data

mov ds,ax

mov cx,05h

lea si,n1

lea di,n2

loc : mov al,[si]


mov bl,[di]

mov [di],al

mov [si],bl

inc si

inc di

dec cx

jnz loc

mov ah,4ch

int 21h

end

8. Write an ALP to Interchange a block of data from one memory location to another
by using ‘XCHG’ instruction.

.model small

.stack 256

.data

n1 db 11h,12h,13h,14h,15h

n2 db 22h,33h,44h,55h,66h

.code

mov ax,@data

mov ds,ax

mov cx,05h

lea si,n1

lea di,n2

loc : mov dl,[si]

xchg [di],dl

mov [si],dl

inc si

inc di
dec cx

jnz loc

mov ah,4ch

int 21h

end

9(*) Write an Alp for left shifting of data without overlap

.model small

.stack[100]

.data

n2 db 5 dup(0)

n1 db 11h,12h,13h,14h,15h

.code

mov ax,@data

mov ds,ax

mov cx,05h

lea si,n1

lea di,n2

loc: mov dl,[si]

mov [di],dl

inc si

inc di

dec cx

jnz loc

mov ah,4ch

int 21h

end
10(*) write an Alp for right shifting of data without overlap

.model small

.stack[100]

.data

src db 11h,12h,13h,14h,15h

.code

mov ax,@data

mov ds,ax

mov cx,05h

lea si,src

lea di,src+5

loc: mov dl,[si+4]

mov [di],dl

dec si

dec di

dec cx

jnz loc

mov ah,4ch

int 21h

end
2. Programs Involving Arithmetic operation
Addition and subtraction of multipression numbers.
1. Write an ALP to add two 8bit numbers

.model small
.stack [256]
.data
n1 db 12h,13h
result db(0)
carry db(0)
.code
mov ax,@data
mov ds,ax
mov al,n1
add al,n1+1
mov result,al
adc carry,00h
mov ah,4ch
int 21h

2. a) Write an ALP to add two 16bit numbers

.model small
.stack
.data
n1 dd 0aaaah
n2 dd 9999h
result dd(0)
carry db(0)
.code
mov ax,@data
mov ds,ax
mov ax,word ptr n1
mov bx,word ptr n2
clc
add ax,bx
mov word ptr result,ax
adc carry,00h
mov ah,4ch
int 21h
end
b)
.model small
.data
d1 dw 9999h
d2 dw 0aaaah
d3 db 3 dup(0)
.code
mov ax,@data ;Initialize the data segment
mov ds,ax
mov ax,00h ;Clear ax
lea si,d1 ;Load si with offset address of d1
lea di,d2 ;Load di with offset address of d2
lea bx,d3+3 ;Load bx with offset address of d3+3
mov cx,04h ;Load cx with with the count
mov dl,00h ;clear dl
clc ;clear carry
up:mov al,[si] ;Move the lower byte of Ist number to al
adc al,[di] ;Add with carry the second no.
mov [bx],al ;Store the result in memory pointed to by bx
inc si ;Increment si
inc di ;Increment di
dec bx ;decrement bx
dec cx ;Decrement cx
jnz up ;if cx is not equal to zero, repeat ;the loop
jnc down ;If no carry,jmp to label down
inc dl ;else increment carry counter
down:mov [bx],dl ;Move the carry to memory location
mov ah,4ch ;terminate the program
int 21h
end

3. a) Write an ALP to add two 32bit numbers

.model small
.data
d1 dd 99999999h
d2 dd 0aaaaaaaah
d3 db 11 dup(0)
.code
mov ax,@data ;Initialize the data segment
mov ds,ax
mov ax,00h ;Clear ax
lea si,d1 ;Load si with oFFset address of d1
lea di,d2 ;Load di with OFFset address of d2
lea bx,d3+5 ;Load bx with offset address of d3+5
mov cx,04h ;Load cx with with the count
mov dl,00h ;clear dl
clc ;clear carry
up:mov al,[si] ;Move the lower byte of Ist number to al
adc al,[di] ;Add with carry the second no.
mov [bx],al ;Store the result in memory pointed to by bx
inc si ;Increment si
inc di ;Increment di
dec bx ;decrement bx
dec cx ;Decrement cx
jnz up ;if cx is not equal to zero, repeat ;the loop
jnc down ;If no carry,jmp to label down
inc dl ;else increment carry counter
down:mov [bx],dl ;Move the carry to memory location
mov ah,4ch ;terminate the program
int 21h
end

b) Write an ALP to add two 32 bit numbers using word ptr

.model small
.stack
.data
n1 dd 0f2222222h
n2 dd 33333333h
result dd(0)
carry db(0)
.code
mov ax,@data
mov ds,ax
mov ax,word ptr n1
mov bx,word ptr n2
clc
add ax,bx
mov bx,word ptr n1+2
mov cx,word ptr n2+2
adc bx,cx
mov word ptr result+2,bx
mov word ptr result,ax
adc carry,00h
mov ah,4ch
int 21h
end

4. a) Write an ALP to add two 64bit numbers

.model small
.data
d1 dq 1234567812345678h
d2 dq 1234567812345678h
d3 db 09 dup(0)
.code
mov ax,@data ;Initialize the data segment
mov ds,ax
mov ax,00h ;Clear ax
lea si,d1 ;Load si with offset address of d1
lea di,d2 ;Load di with offset address of d2
lea bx,d3+8 ;Load bx with offset address of d3+5
mov cx,08h ;Load cx with with the count
mov dl,00h ;clear dl
clc ;clear carry
up:mov al,[si] ;Move the lower byte of Ist number to al
adc al,[di] ;Add with carry the second no.
mov [bx],al ;Store the result in memory pointed to by bx
inc si ;Increment si
inc di ;Increment di
dec bx ;decrement bx
dec cx ;Decrement cx
jnz up ;if cx is not equal to zero, repeat ;the loop
jnc down ;If no carry,jmp to label down
inc dl ;else increment carry counter
down:mov [bx],dl ;Move the carry to memory location
mov ah,4ch ;terminate the program
int 21h
end

b) Write an ALP to add two 64 bit numbers using word ptr

.model small
.stack
.data
n2 dq 0f222222222222222h
n1 dq 3333333333333333h
result dd(0)
carry db(0)
.code
mov ax,@data
mov ds,ax
mov ax,word ptr n1
mov bx,word ptr n2
clc
add ax,bx
mov word ptr result,ax
mov bx,word ptr n1+2
mov cx,word ptr n2+2
adc bx,cx
mov word ptr result+2,bx
mov ax,word ptr n1+4
mov bx,word ptr n2+4
adc ax,bx
mov word ptr result+4,ax
mov bx,word ptr n1+6
mov cx,word ptr n2+6
adc bx,cx
mov word ptr result+6,bx
adc carry,00h
mov ah,4ch
int 21h
end
5. (*) Write an ALP to add two 128bit numbers

.model small
.data
d1 dt 99999999999999999999h
d2 dt 0aaaaaaaaaaaaaaaaaaaah
d3 db 11 dup(0)
.code
mov ax,@data ;Initialize the data segment
mov ds,ax
mov ax,00h ;Clear ax
lea si,d1 ;Load si with offset address of d1
lea di,d2 ;Load di with offset address of d2
lea bx,d3+10 ;Load bx with offset address of d3+5
mov cx,0ah ;Load cx with with the count
mov dl,00h ;clear dl
clc ;clear carry
up:mov al,[si] ;Move the lower byte of Ist number to al
adc al,[di] ;Add with carry the second no.
mov [bx],al ;Store the result in memory pointed to by bx
inc si ;Increment si
inc di ;Increment di
dec bx ;decrement bx
dec cx ;Decrement cx
jnz up ;if cx is not equal to zero, repeat ;the loop
jnc down ;If no carry,jmp to label down
inc dl ;else increment carry counter
down:mov [bx],dl ;Move the carry to memory location
mov ah,4ch ;terminate the program
int 21h
end

6. Write an ALP to sub two 8bit numbers

.model small
.stack [256]
.data
n1 db 14h,13h
result db(0)
borrow db(0)
.code
mov ax,@data
mov ds,ax
mov al,n1
sub al,n1+1
mov result,al
sbb carry,00h
mov ah,4ch
int 21h
7. a ) Write an ALP to sub two 16bit numbers.

.model small
.stack
.data
n1 dd 0aaaah
n2 dd 9999h
result dd(0)
borrow db(0)
.code
mov ax,@data
mov ds,ax
mov ax,word ptr n1
mov bx,word ptr n2
clc
sub ax,bx
mov word ptr result,ax
sbb borrow,00h
mov ah,4ch
int 21h
end
b)

.model small
.data
d1 dw 9999h
d2 dw 0aaaah
d3 db 3 dup(0)
.code
mov ax,@data ;Initialize the data segment
mov ds,ax
mov ax,00h ;Clear ax
lea si,d1 ;Load si with offset address of d1
lea di,d2 ;Load di with offset address of d2
lea bx,d3+3 ;Load bx with offset address of d3+5
mov cx,04h ;Load cx with with the count
mov dl,00h ;clear dl
clc ;clear carry
up:mov al,[si] ;Move the lower byte of Ist number to al
sbb al,[di] ;subtract with borrow the second no.
mov [bx],al ;Store the result in memory pointed to by bx
inc si ;Increment si
inc di ;Increment di
dec bx ;decrement bx
dec cx ;Decrement cx
jnz up ;if cx is not equal to zero, repeat ;the loop
jnc down ;If no carry,jmp to label down
dec dl ;else decrement borrow counter
down:mov [bx],dl ;Move the carry to memory location
mov ah,4ch ;terminate the program
int 21h
end
8. a) Write an ALP to sub two 32bit numbers

.model small
.data
d1 dt 99999999h
d2 dt 0aaaaaaaah
d3 db 05 dup(0)
.code
mov ax,@data ;Initialize the data segment
mov ds,ax
mov ax,00h ;Clear ax
lea si,d1 ;Load si with offset address of d1
lea di,d2 ;Load di with offset address of d2
lea bx,d3+5 ;Load bx with offset address of d3+5
mov cx,04h ;Load cx with with the count
mov dl,00h ;clear dl
clc ;clear carry
up:mov al,[si] ;Move the lower byte of Ist number to al
sbb al,[di] ;sub with borrow the second no.
mov [bx],al ;Store the result in memory pointed to by bx
inc si ;Increment si
inc di ;Increment di
dec bx ;decrement bx
dec cx ;Decrement cx
jnz up ;if cx is not equal to zero, repeat ;the loop
jnc down ;If no carry,jmp to label down
dec dl ;else decrement borrow counter
down:mov [bx],dl ;Move the borrow to memory location
mov ah,4ch ;terminate the program
int 21h
end

b) Write an ALP to sub two 32bit numbers using word ptr

.model small
.stack
.data
n1 dd 0f2222222h
n2 dd 33333333h
result dd(0)
borrow db(0)
.code
mov ax,@data
mov ds,ax
mov ax,word ptr n1
mov bx,word ptr n2
clc
sub ax,bx
mov bx,word ptr n1+2
mov cx,word ptr n2+2
sbb bx,cx
mov word ptr result+2,bx
mov word ptr result,ax
adc borrow,00h
mov ah,4ch
int 21h
end

9. a) Write an ALP to sub two 64 bit numbers

.model small
.data
d1 dq 9999999999999999h
d2 dq 0aaaaaaaaaaaaaaaah
d3 db 9 dup(0)
.code
mov ax,@data ;Initialize the data segment
mov ds,ax
mov ax,00h ;Clear ax
lea si,d1 ;Load si with offset address of d1
lea di,d2 ;Load di with offset address of d2
lea bx,d3+8 ;Load bx with offset address of d3+5
mov cx,08h ;Load cx with with the count
mov dl,00h ;clear dl
clc ;clear carry
up:mov al,[si] ;Move the lower byte of Ist number to al
sbb al,[di] ;sub with borrow the second no.
mov [bx],al ;Store the result in memory pointed to by bx
inc si ;Increment si
inc di ;Increment di
dec bx ;decrement bx
dec cx ;Decrement cx
jnz up ;if cx is not equal to zero, repeat ;the loop
jnc down ;If no carry,jmp to label down
dec dl ;else decrement borrow counter
down:mov [bx],dl ;Move the borrow to memory location
mov ah,4ch ;terminate the program
int 21h
end

b) Write an ALP to sub two 64bit numbers using word ptr

.model small
.stack
.data
n2 dq 0f222222222222222h
n1 dq 3333333333333333h
result dd(0)
borrow db(0)
.code
mov ax,@data
mov ds,ax
mov ax,word ptr n1
mov bx,word ptr n2
clc
sub ax,bx
mov word ptr result,ax
mov bx,word ptr n1+2
mov cx,word ptr n2+2
sbb bx,cx
mov word ptr result+2,bx
mov ax,word ptr n1+4
mov bx,word ptr n2+4
sbb ax,bx
mov word ptr result+4,ax
mov bx,word ptr n1+6
mov cx,word ptr n2+6
sbb bx,cx
mov word ptr result+6,bx
sbb carry,00h
mov ah,4ch
int 21h
end

10(*) Write an ALP to sub two 128 bit numbers

.model small
.data
d1 dt 99999999999999999999h
d2 dt 0aaaaaaaaaaaaaaaaaaaah
d3 db 11 dup(0)
.code
mov ax,@data ;Initialize the data segment
mov ds,ax
mov ax,00h ;Clear ax
lea si,d1 ;Load si with offset address of d1
lea di,d2 ;Load di with offset address of d2
lea bx,d3+10 ;Load bx with offset address of d3+5
mov cx,0ah ;Load cx with with the count
mov dl,00h ;clear dl
clc ;clear carry
up:mov al,[si] ;Move the lower byte of Ist number to al
sbb al,[di] ;sub with borrow the second no.
mov [bx],al ;Store the result in memory pointed to by bx
inc si ;Increment si
inc di ;Increment di
dec bx ;decrement bx
dec cx ;Decrement cx
jnz up ;if cx is not equal to zero, repeat ;the loop
jnc down ;If no carry,jmp to label down
dec dl ;else decrement borrow counter
down:mov [bx],dl ;Move the borrow to memory location
mov ah,4ch ;terminate the program
int 21h
end
Multiplication and Division of signed and unsigned hexadecimal numbers
1. Write an ALP to multiply two 8bit unsigned numbers.

2. Write an ALP to multiply 8bit signed number and 8bit unsigned number.

3. Write an ALP to multiply two 8bit signed numbers .

4. Write an ALP to multiply two 16bit unsigned numbers

5. Write an ALP to multiply two 16bit signed numbers

6. Write an ALP to multiply 16bit unsigned number and 16bit signed number

7. Write an ALP to Divide two 8bit unsigned numbers

8. Write an ALP to Divide two 8bit signed numbers

9. Write an ALP to Divide 16bit signed number by 8bit unsigned number.

10. Write an ALP to divide 16bit signed number by 8bit signed number.

11. Write an ALP to divide 32bit number by 16bit number.

Vous aimerez peut-être aussi