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

Write an ALP to transfer a block of data word from one memory location to another without overlap.model small .stack[100] .ax mov cx.14h.4444h .model small .5678h.1223h.04h lea si.15h n2 db 5 dup(0) .code mov ax. .1225h.4ch int 21h end 4.1112h.stack[100] .12h. Write an ALP to transfer a block of data byte from one memory location to another without overlap.[si] mov [di].n2 loc: mov dl.@data mov ds. .3456h.13h.data n1 db 11h.dl inc si inc di dec cx jnz loc mov ah.n1 lea di.3.data n1 dw 1111h.1224h.

12h.08h lea si.[si] mov [di].stack[100] .data n2 db 3 dup(0) n1 db 11h.ax mov cx.15h . Write an ALP to transfer a block of data byte from one memory location to another with overlap.13h.n2 dw 8 dup(0) .14h.n loc: mov dx. a.@data mov ds.code mov ax.model small .n1 lea di. .dx inc si inc si inc di inc di dec cx jnz loc mov ah.4ch int 21h end 5.

[si] mov [di].15h n2 db 16h..17h.18h.20h .14h.12h.05h lea si.stack[100] .19h.n1 lea di.code mov ax. Write an ALP to transfer a block of data byte from one memory location to another with overlap .4ch int 21h end b.@data mov ds.@data mov ds.n2 loc: mov dl.n2 .ax mov cx.dl inc si inc di dec cx jnz loc mov ah.ax mov cx.data n1 db 11h.05h lea si.13h.code mov ax.model small .n1 lea di.

.stack[100] .code mov ax.model small .4444h .loc: mov dl.[si+4] mov [di].1112h.3456h.4ch int 21h end 6 Write an ALP to transfer a block of data word from one memory location to another with overlap.ax mov cx.n2 loc: mov dx.1225h.5678h.1224h.1223h.@data mov ds.data n2 dw 5 dup(0) n1 dw 1111h.n1 lea di.dx inc si inc si inc di .dl dec si dec di dec cx jnz loc mov ah.08h lea si.[si] mov [di].

33h.05h lea si.stack 256 .inc di dec cx jnz loc mov ah.44h.[di] mov [di].55h.data n1 db 11h. .4ch int 21h end 7.bl inc si inc di dec cx jnz loc .15h n2 db 22h.n1 lea di.[si] mov bl.66h .14h.ax mov cx. Write an ALP to Interchange a block of data from one memory location to another without using ‘XCHG’ instruction.13h.al mov [si].model small .code mov ax.n2 loc : mov al.@data mov ds.12h.

15h n2 db 22h.14h.4ch int 21h end 9(*) Write an Alp for left shifting of data without overlap .data n1 db 11h.66h .ax mov cx.n2 loc : mov dl.model small .n1 lea di.mov ah.12h.dl inc si inc di dec cx jnz loc mov ah.33h.05h lea si.@data mov ds.[si] xchg [di].model small .44h.dl mov [si]. .4ch int 21h end 8.stack 256 .code mov ax.55h. Write an ALP to Interchange a block of data from one memory location to another by using ‘XCHG’ instruction.13h.

code .14h.n1 lea di.[si] mov [di].model small .data n2 db 5 dup(0) n1 db 11h.data src db 11h.14h..@data mov ds.stack[100] .05h lea si.12h.12h.15h .code mov ax.13h.15h .ax mov cx.13h.4ch int 21h end 10(*) write an Alp for right shifting of data without overlap .stack[100] .dl inc si inc di dec cx jnz loc mov ah.n2 loc: mov dl.

1.model small .05h lea si.src+5 loc: mov dl.4ch int 21h end 2.src lea di.mov ax. Write an ALP to add two 8bit numbers .@data mov ds.stack [256] .dl dec si dec di dec cx jnz loc mov ah. Programs operation Involving Arithmetic Addition and subtraction of multipression numbers.[si+4] mov [di].ax mov cx.

bx mov word ptr result.@data mov ds.code mov ax.Clear ax lea si.word ptr n1 mov bx.model small .Load si with offset address of d1 .n1+1 mov result.data d1 dw 9999h d2 dw 0aaaah d3 db 3 dup(0) .Initialize the data segment mov ds.13h result db(0) carry db(0) .ax mov ax.4ch int 21h 2.@data .d1 .stack .data n1 dd 0aaaah n2 dd 9999h result dd(0) carry db(0) .al adc carry.00h mov ah.4ch int 21h end b) .00h . a) Write an ALP to add two 16bit numbers .ax adc carry.ax mov ax..ax mov al.word ptr n2 clc add ax.00h mov ah.n1 add al.data n1 db 12h.code mov ax.code mov ax.@data mov ds.model small .

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

@data .Increment si inc di .the loop jnc down .[di] . mov [bx].word ptr n1 mov bx.if cx is not equal to zero. a) Write an ALP to add two 64bit numbers .Store the result in memory pointed to by bx inc si .word ptr n2 clc add ax.00h mov ah.Initialize the data segment mov ds.data d1 dq 1234567812345678h d2 dq 1234567812345678h d3 db 09 dup(0) .data n1 dd 0f2222222h n2 dd 33333333h result dd(0) carry db(0) . repeat .word ptr n1+2 mov cx.Increment di dec bx .ax mov ax.Clear ax lea si.cx mov word ptr result+2.Add with carry the second no.Decrement cx jnz up .clear carry up:mov al.Load cx with with the count mov dl.jmp to label down .model small .00h .code mov ax.Load di with offset address of d2 lea bx.08h .00h .Load bx with offset address of d3+5 mov cx.model small .al .d1 .code mov ax.decrement bx dec cx .4ch int 21h end 4.Move the lower byte of Ist number to al adc al.stack .clear dl clc .bx mov word ptr result.If no carry.ax mov ax.word ptr n2+2 adc bx.bx mov bx.[si] .b) Write an ALP to add two 32 bit numbers using word ptr .d2 .d3+8 .Load si with offset address of d1 lea di.ax adc carry.@data mov ds.

word ptr n2+4 adc ax.word ptr n1+2 mov cx.4ch .word ptr n1+6 mov cx.else increment carry counter down:mov [bx].stack .word ptr n2+2 adc bx.word ptr n1 mov bx.word ptr n1+4 mov bx.Clear ax .cx mov word ptr result+6.model small .ax mov bx.ax mov bx.00h .word ptr n2+6 adc bx.code mov ax.Move the carry to memory location mov ah.@data mov ds.Initialize the data segment mov ds.data d1 dt 99999999999999999999h d2 dt 0aaaaaaaaaaaaaaaaaaaah d3 db 11 dup(0) .bx adc carry.inc dl .ax mov ax.word ptr n2 clc add ax.bx mov word ptr result+4.ax mov ax.model small .bx mov ax.4ch int 21h end 5.00h mov ah.@data .dl .terminate the program int 21h end b) Write an ALP to add two 64 bit numbers using word ptr .data n2 dq 0f222222222222222h n1 dq 3333333333333333h result dd(0) carry db(0) .code mov ax.bx mov word ptr result. (*) Write an ALP to add two 128bit numbers .cx mov word ptr result+2.

[si] .d1 .13h result db(0) borrow db(0) .dl .If no carry.stack [256] .stack .data n1 dd 0aaaah n2 dd 9999h result dd(0) borrow db(0) . .@data mov ds.00h .Load cx with with the count mov dl.ax mov al.the loop jnc down .4ch int 21h 7.code mov ax.Increment di dec bx . a ) Write an ALP to sub two 16bit numbers.data n1 db 14h.code mov ax.Increment si inc di .00h mov ah.terminate the program int 21h end 6.model small .clear dl clc .Store the result in memory pointed to by bx inc si .d2 .n1 sub al.decrement bx dec cx . repeat . Write an ALP to sub two 8bit numbers .Move the lower byte of Ist number to al adc al.d3+10 .@data . mov [bx].al .jmp to label down inc dl .Add with carry the second no.if cx is not equal to zero.n1+1 mov result.Load di with offset address of d2 lea bx.model small .else increment carry counter down:mov [bx].lea si.al sbb carry.0ah .4ch .Load si with offset address of d1 lea di.Move the carry to memory location mov ah.Decrement cx jnz up .Load bx with offset address of d3+5 mov cx.[di] .clear carry up:mov al.

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

bx mov bx.ax adc borrow.Store the result in memory pointed to by bx inc si .Load bx with offset address of d3+5 mov cx.stack .the loop jnc down .dl .word ptr n2+2 sbb bx.else decrement borrow counter down:mov [bx].word ptr n1 mov bx.If no carry.model small .if cx is not equal to zero.4ch int 21h end 9.jmp to label down dec dl .clear carry up:mov al.model small .code mov ax.bx mov word ptr result.00h .terminate the program int 21h end b) Write an ALP to sub two 32bit numbers using word ptr .Decrement cx jnz up .word ptr n2 clc sub ax. a) Write an ALP to sub two 64 bit numbers .lea si.word ptr n1+2 mov cx.Move the borrow to memory location mov ah.Load di with offset address of d2 lea bx. repeat .d2 .00h mov ah.Load cx with with the count mov dl.4ch .clear dl clc .sub with borrow the second no.d1 . mov [bx].[si] .Increment si inc di .cx mov word ptr result+2.[di] .al .Increment di dec bx .Load si with offset address of d1 lea di.d3+5 .decrement bx dec cx .data n1 dd 0f2222222h n2 dd 33333333h result dd(0) borrow db(0) .Move the lower byte of Ist number to al sbb al.data d1 dq 9999999999999999h .@data mov ds.ax mov ax.04h .

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

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

5. Write an ALP to multiply two 16bit signed numbers 6. 10. Write an ALP to Divide two 8bit signed numbers 9. Write an ALP to Divide two 8bit unsigned numbers 8.Write an ALP to divide 16bit signed number by 8bit signed number. Write an ALP to Divide 16bit signed number by 8bit unsigned number. Write an ALP to multiply 16bit unsigned number and 16bit signed number 7. . 11. Write an ALP to divide 32bit number by 16bit number.

Sign up to vote on this title
UsefulNot useful

Master Your Semester with Scribd & The New York Times

Special offer for students: Only $4.99/month.

Master Your Semester with a Special Offer from Scribd & The New York Times

Cancel anytime.