8086 MICROPROCESSORS LAB EXPERIMRNTS.
Note: To test 8086 asm programs download Masm from:
https://www.facebook.com/groups/163904047131828/
https://www.facebook.com/groups/163904047131828/
Ø Steps to test and run 8086 asm programs.
Ø Open cmd and and select the screen size as
shown.
1. Download masm and copy the “MASM” folder in c:\
2. Open cmd and maximize it.
3. Change the directory to cd c:\masm
4. Or else c:\
5. Cd masm
6. Type edit and type your program and save it
with filename.asm
7. Or else type program in notepad save it with
.asm extension and copy in “c:\masm”
8. Note:while typing the program u may not get full
screen in windows 7.
9. Now exit from editor window.
Follow following commands:
Compile :
masm filename;
Linking
: link filename;
Debug
: debug filename.exe;
-p : proceed
-t :
trace
Edit : edit filename.asm
Check memory location : -d ds:1000
For linking two programs follow following commands.
Main program name : pgm1
Procedure program name : pgm2
Then
Masm pgm1;
Masm pgm2;
Link pgm1 pgm2;
To get output press
Pgm1;
8086 lab Experiments.
Expt no 1: alp to display a message on console.
data segment
m1 db 0ah,0dh,"vishal$"
data ends
prg segment
assume cs:prg , ds:data
start: mov ax,data
mov ds,ax
lea dx,m1
mov ah,09h
int 21h
mov ah,4ch
int 21h
prg ends
end start
output:
Expt no 2:alp to display two messages on console.
data segment
m1 db 0ah,0dh,"vishal$"
m2 db 0ah,0dh,"2ji11ec061$"
data ends
prg segment
assume cs:prg , ds:data
start: mov ax,data
mov ds,ax
lea dx,m1
mov ah,09h
int 21h
lea dx,m2
mov ah,09h
int 21h
mov ah,4ch
int 21h
prg ends
end start
output:
Expt no 3:alp to read character from keyboard and display on console.
data segment
m1 db 0ah,0dh,"enter character: $"
m2 db 0ah,0dh," entered character is: $"
data ends
prg segment
assume cs:prg , ds:data
start: mov ax,data
mov ds,ax
lea dx,m1
mov ah,09h
int 21h
mov ah,01h
int 21h
mov bl,al
lea dx,m2
mov ah,09h
int 21h
mov dl,bl
mov ah,02h
int 21h
mov ah,4ch
int 21h
prg ends
end start
output:
·
Procedure to read a 8 bit hex no from keyboard and to display a 8
bit hex no on console.
data segment
data ends
prg segment
assume
cs:prg,ds:data
public
inp,dsp
start : mov
ax,data
mov ds,ax
inp proc near
push ax
push cx
push dx
pushf
mov ah,01h
int 21h
cmp al,41h
jc dn1
sub al,07h
dn1:sub al,30h
mov cl,04h
ror al,cl
mov bl,al
mov ah,01h
int 21h
cmp al,41h
jc dn2
sub al,07h
dn2:sub al,30h
add bl,al
popf
pop dx
pop cx
pop ax
ret
inp endp
dsp proc near
push ax
push bx
push cx
push dx
pushf
mov dl,bl
and dl,0f0h
mov cl,04
ror dl,cl
cmp dl,0ah
jc dn3
add dl,07h
dn3:add dl,30h
mov ah,02h
int 21h
mov dl,bl
and dl,0fh
cmp dl,0ah
jc dn4
add dl,07h
dn4: add dl,30h
mov ah,02h
int 21h
popf
pop dx
pop cx
pop bx
pop ax
ret
dsp endp
mov ah,4ch
int 21h
prg ends
end start
Expt no 1a : data transfer in various
addressing modes.
data segment
n1 db 22h
n2 dw 1133h
data ends
prg segment
assume cs:prg,ds:data
start: mov ax,data
mov ds,ax
mov al,55h
mov si,2500h
mov bx,si
mov ah,n1
mov cx,n2
mov [si],al
mov dh,[si]
mov dx,[bx-20h]
mov cl,[bx+si]
mov ch,[bx+si+2000h]
mov ah,4ch
int 21h
prg ends
end start
output:
Expt no 1b : block of data transfer without
overlap.
data segment
org 1000h
scrlist db
01h,02h,03h,04h,05h,06h,07h,08h,09h,0ah
org 2000h
dstlist db 10 dup(00)
data ends
prg segment
assume cs:prg,ds:data
start: mov ax,data
mov ds,ax
mov si,1000h
mov di,2000h
mov cx,000ah
up: mov al,[si]
mov
[di],al
inc
si
inc
di
loop up
mov
ah,4ch
int
21h
prg
ends
end
start
output:
Expt no 1c : block of data transfer with
overlap.
data segment
org 1000h
scrlist db 01h,02h,03h,04h,05h,06h,07h,08h,09h,0ah
data ends
prg segment
assume cs:prg,ds:data
start: mov ax,data
mov ds,ax
mov si,1009h
mov di,100eh
mov cx,000ah
up: mov al,[si]
mov
[di],al
dec
si
dec
di
loop up
mov
ah,4ch
int
21h
prg
ends
end
start
output :
Expt no 1d : exchange of block of data in two
memory locations.
data segment
org 1000h
scrlist db
01h,02h,03h,04h,05h,06h,07h,08h,09h,0ah
org 2000h
dstlist db
11h,12h,13h,14h,15h,16h,17h,18h,19h,2ah
data ends
prg segment
assume cs:prg,ds:data
start: mov ax,data
mov ds,ax
mov si,1000h
mov di,2000h
mov cx,000ah
up: mov al,[si]
xchg al,[di]
mov
[si],al
inc
si
inc
di
loop up
mov
ah,4ch
int
21h
prg
ends
end
start
output :
Expt no 2a: Multiprecise addition of two
32-bit no.
data segment
n1 dd 44443333h
n2 dd 22221111h
org 1000h
result dd ?
data ends
prg segment
assume cs:prg,ds:data
start:mov ax,data
mov ds,ax
mov ax,word ptr n1
add ax,word ptr n2
mov word ptr result,ax
mov ax,word ptr n1+2
adc ax,word ptr n2+2
mov word ptr result+2,ax
mov ah,4ch
int 21h
prg ends
end start
output:
Expt no 2b: Multiprecise substraction of two
32 bit no.
data segment
n1 dd 44443333h
n2 dd 22222222h
org 1000h
result dd ?
data ends
prg segment
assume cs:prg,ds:data
start:mov ax,data
mov ds,ax
mov ax,word ptr n1
sub ax,word ptr n2
mov word ptr result,ax
mov ax,word ptr n1+2
sbb ax,word ptr n2+2
mov word ptr result+2,ax
mov ah,4ch
int 21h
prg ends
end start
output:
Expt no 3a: addition of two 16 bit bcd no.
data segment
m1 db 0ah,0dh,"enter first number :
$"
m2 db 0ah,0dh,"enter second number:
$"
m3 db 0ah,0dh,"result is : $"
data ends
print macro m
push ax
push dx
lea dx,m
mov ah,09h
int 21h
pop dx
pop ax
endm
prg segment
extrn inp:far,dsp:far
assume cs:prg,ds:data
start : mov ax,data
mov ds,ax
print m1
call inp
mov ch,bl
call inp
mov cl,bl
print m2
call inp
mov bh,bl
call inp
mov al,cl
add al,bl
daa
mov cl,al
mov al,ch
adc al,bh
daa
mov ch,al
print m3
call dsp
mov bl,ch
call dsp
mov bl,cl
call dsp
mov ah,4ch
int 21h
prg ends
end start
output:
Expt no 3b: substraction of two 16 bit bcd
no.
data segment
m1 db 0ah,0dh,"enter first number :
$"
m2 db 0ah,0dh,"enter second number:
$"
m3 db 0ah,0dh,"result is : $"
data ends
print macro m
push ax
push dx
lea dx,m
mov ah,09h
int 21h
pop dx
pop ax
endm
prg segment
extrn inp:far,dsp:far
assume cs:prg,ds:data
start : mov ax,data
mov ds,ax
print m1
call inp
mov ch,bl
call inp
mov cl,bl
print m2
call inp
mov bh,bl
call inp
mov al,cl
sub al,bl
das
mov cl,al
mov al,ch
sbb al,bh
das
mov ch,al
print m3
call dsp
mov bl,ch
call dsp
mov bl,cl
call dsp
mov ah,4ch
int 21h
prg ends
end start
output:
Expt no 3c: multiplication of two 16 bit hex
no.
data segment
m1 db 0ah,0dh,"enter first number :
$"
m2 db 0ah,0dh,"enter second number:
$"
m3 db 0ah,0dh,"result is : $"
data ends
print macro m
push ax
push dx
lea dx,m
mov ah,09h
int 21h
pop dx
pop ax
endm
prg segment
extrn inp:far,dsp:far
assume cs:prg,ds:data
start : mov ax,data
mov ds,ax
print m1
call inp
mov ch,bl
call inp
mov cl,bl
print m2
call inp
mov bh,bl
call inp
mov dx,0000h
mov ax,cx
mul bx
print m3
mov bl,dh
call dsp
mov bl,dl
call dsp
mov bl,ah
call dsp
mov bl,al
call dsp
mov ah,4ch
int 21h
prg ends
end start
output:
Expt no 3d: division of two 16 bit hex no.
data segment
m1 db 0ah,0dh,"enter first number :
$"
m2 db 0ah,0dh,"enter second number:
$"
m3 db 0ah,0dh,"quotient is : $"
m4 db 0ah,0dh,"remender is:$"
data ends
print macro m
push ax
push dx
lea dx,m
mov ah,09h
int 21h
pop dx
pop ax
endm
prg segment
extrn inp:far,dsp:far
assume cs:prg,ds:data
start : mov ax,data
mov ds,ax
print m1
call inp
mov ch,bl
call inp
mov cl,bl
print m2
call inp
mov bh,bl
call inp
mov dx,0000h
mov ax,cx
div bx
print m4
mov bl,dh
call dsp
mov bl,dl
call dsp
print m3
mov bl,ah
call dsp
mov bl,al
call dsp
mov ah,4ch
int 21h
prg ends
end start
Expt no 4a: square of 8 bit no.
data segment
m1 db 0ah,0dh,"enter number : $"
m2 db 0ah,0dh,"square is : $"
data ends
print macro m
push ax
push dx
lea dx,m
mov ah,09h
int 21h
pop dx
pop ax
endm
prg segment
assume cs:prg,ds:data
extrn inp:far,dsp:far
start:
mov ax,data
mov ds,ax
print m1
call inp
mov al,bl
mul al
print m2
mov bl,ah
call dsp
mov bl,al
call dsp
mov ah,4ch
int 21h
prg ends
end start
output:
Expt no 4b: cube of a 8 bit no.
data segment
m1 db 0ah,0dh,"enter number : $"
m2 db 0ah,0dh,"cube is : $"
data ends
print macro m
push ax
push dx
lea dx,m
mov ah,09h
int 21h
pop dx
pop ax
endm
prg segment
assume cs:prg,ds:data
extrn inp:far,dsp:far
start:
mov ax,data
mov ds,ax
print m1
call inp
mov al,bl
mov cl,bl
mov dx,0000h
mul al
mul cl
print m2
mov bl,dh
call dsp
mov bl,dl
call dsp
mov bl,ah
call dsp
mov bl,al
call dsp
mov ah,4ch
int 21h
prg ends
end start
output:
Expt no 4c: 8 bit hex calculator.
data segment
m1 db 0ah,0dh,"enter first digit
:$"
m2 db 0ah,0dh,"enter second digit
:$"
m3 db 0ah,0dh,"enter 01 for add , 02 for
substract 03 for mul , 04 for division : $"
m4 db 0ah,0dh,"enter your choice:$"
m5 db 0ah,0dh,"the results is :$"
m6 db 0ah,0dh,"invalid choice !!!!!!!!
$"
data ends.
print macro m
push ax
push dx
lea dx,m
mov ah,09h
int 21h
pop dx
pop ax
endm
prg segment
assume cs:prg,ds:data
extrn inp:far,dsp:far
start: mov ax,data
mov ds,ax
print m1
call inp
mov cl,bl
print m2
call inp
mov ch,bl
print m3
print m4
call inp
cmp bl,01h
je dn1
cmp bl,02h
je dn2
cmp bl,03h
je dn3
cmp bl,04h
je dn4
print m6
jmp last
dn1:add cl,ch
mov bl,cl
print m5
call dsp
jmp last
dn2:sub cl,ch
mov bl,cl
print m5
call dsp
jmp last
dn3:mov al,cl
mov ah,00h
mul ch
mov bl,ah
print m5
call dsp
mov bl,al
call dsp
jmp last
dn4:mov al,cl
mov ah,00h
div ch
mov bl,ah
print m5
call dsp
mov bl,al
call dsp
last:mov ah,4ch
int 21h
prg ends
end start
output:
Expt no 5a: gcd of two 8 bit no.
data segment
m1 db 0ah,0dh,"enter first digit:$"
m2 db 0ah,0dh,"enter second digit
:$"
m3 db 0ah,0dh,"GCD is : $"
data ends
print macro m
push ax
push dx
lea dx,m
mov ah,09h
int 21h
pop dx
pop ax
endm
prg segment
assume cs:prg,ds:data
extrn inp:far,dsp:far
start: mov ax,data
mov ds,ax
print m1
call inp
mov al,bl
print m2
call inp
up1:
cmp al,bl
je dn1
cmp al,bl
jc dn2
sub al,bl
jmp up1
dn2:
sub bl,al
jmp up1
dn1:print m3
mov
bl,al
call
dsp
mov
ah,4ch
prg
ends
end
start
output:
Expt no 5b: lcm of two 8 bit no.
data segment
m1 db 0ah,0dh,"enter first digit:$"
m2 db 0ah,0dh,"enter second digit
:$"
m3 db 0ah,0dh,"LCM is : $"
data ends
print macro m
push ax
push dx
lea dx,m
mov ah,09h
int 21h
pop dx
pop ax
endm
prg segment
assume cs:prg,ds:data
extrn inp:far,dsp:far
start: mov ax,data
mov ds,ax
print m1
call inp
mov al,bl
mov ch,bl
print m2
call inp
mov cl,bl
up1:cmp al,bl
je dn1
jc dn2
sub al,bl
jmp up1
dn2:sub bl,al
jmp up1
dn1:mov al,ch
mul cl
div bl
print m3
mov bl,al
call dsp
mov ah,4ch
int 21h
prg ends
end start
output:
Expt no 5c: factorial of a no.
data segment
m1 db 0ah,0dh,"Enter the no $"
m2 db 0ah,0dh,"factorial of no is
$"
data ends
print macro m
push ax
push dx
lea dx,m
mov ah,09h
int 21h
pop dx
pop ax
endm
prg segment
extrn inp:far,dsp:far
assume cs:prg,ds:data
start:mov ax,data
mov ds,ax
print m1
call inp
mov cl,bl
mov ch,00h
mov ax,0001h
up:mul cx
loop up
mov cx,ax
print m2
mov bl,ch
call dsp
mov bl,cl
call dsp
mov ah,4ch
int 21h
prg ends
end start
output:
Expt no 6a: bcd to hex conversion.
data segment
m1 db 0ah,0dh,"enter bcd no:$"
m2 db 0ah,0dh,"hex eq bcd no:$"
data ends
print macro m
push dx
push ax
lea dx,m
mov ah,09h
int 21h
pop ax
pop dx
endm
prg segment
extrn inp:far,dsp:far
assume cs:prg,ds:data
start:mov ax,data
mov ds,ax
print m1
call inp
mov al,bl
and al,0f0h
mov cl,04h
ror al,cl
mov cl,0ah
mul cl
and bl,0fh
add al,bl
print m2
mov bl,al
call dsp
mov ah,4ch
int 21h
prg ends
end start
output:
Expt no 6b: hex to bcd conversion.
data segment
m1 db 0ah,0dh,"enter hex number:$"
m2 db 0ah,0dh,"bcd equ of hex number
is:$"
data ends
print macro m
push dx
push ax
lea dx,m
mov ah,09h
int 21h
pop ax
pop dx
endm
prg segment
assume cs:prg,ds:data
extrn inp:far,dsp:far
start:mov ax,data
mov ds,ax
print m1
call inp
mov al,bl
mov ah,00h
mov bl,64h
div bl
print m2
mov bl,al
call dsp
mov al,ah
mov bl,0ah
mov ah,00h
div bl
mov cl,04h
ror al,cl
add al,ah
mov bl,al
call dsp
mov ah,4ch
int 21h
prg ends
end start
output:
Expt no 6c : hex to ascii conversion using
aam istn.
data segment
m1 db 0ah,0dh,"enter the hex number:
$"
m2 db 0ah,0dh,"ascii equivalent of hex
is: $"
data ends
print macro m
push ax
push dx
lea dx,m
mov ah,09h
int 21h
pop dx
pop ax
endm
prg segment
extrn inp:far,dsp:far
assume cs:prg,ds:data
start:
mov ax,data
mov ds,ax
print m1
call inp
mov al,bl
mov ah,00h
aam
add ax,3030h
print m2
mov bl,ah
call dsp
mov bl,al
call dsp
mov ah,4ch
int 21h
prg ends
end start
output:
Expt no 7a: alp to count no of 0’s and 1’s in
a 8 bit no.
data segment
m1 db 0ah,0dh,"enter the number:$"
m2 db 0ah,0dh,"number of ones is:$"
m3 db 0ah,0dh,"number of zeros
is:$"
data ends
print macro m
push ax
push dx
lea dx,m
mov ah,09h
int 21h
pop dx
pop ax
endm
prg segment
assume cs:prg,ds:data
extrn inp:far,dsp:near
start:mov ax,data
mov ds,ax
print m1
call inp
mov cl,08h
mov ch,00h
mov ah,00h
mov al,00h
up:rol bl,01h
jc dn3
inc al
loop up
jmp last
dn3:inc ah
loop up
last:print m2
mov bl,ah
call dsp
print m3
mov bl,al
call dsp
mov ah,4ch
int 21h
prg ends
end start
output:
Expt no 7b: alp to check for 2 out of 5 code.
data segment
m1 db 0ah,0dh,"enter the no:$"
m2 db 0ah,0dh,"the number is two out of
five:$"
m3 db 0ah,0dh,"the number is not two out
of five:$"
data ends
print macro m
push dx
push ax
lea dx,m
mov ah,09h
int 21h
pop ax
pop dx
endm
prg segment
assume cs:prg,ds:data
extrn inp:far,dsp:far
start :mov ax,data
mov ds,ax
print m1
call inp
mov al,bl
and al,0e0h
jnz dn1
mov ah,00h
mov cx,00005h
up1:ror bl,01h
jnc dn2
inc ah
dn2:loop up1
cmp ah,02h
jne dn1
print m2
jmp last
dn1:print m3
last: mov ah,4ch
int 21h
prg ends
end start
output:
Expt no 7c: alp to check whether a given 16
bit no is nibble wise palindrome
Or not.
data segment
m1 db 0ah,0dh,"enter the 16 bit no:
$"
m2 db 0ah,0dh,"the no is nibble wise
palindrom $"
m3 db 0ah,0dh,"the no is not nibblewise
palindrom $"
data ends
print macro m
push ax
push dx
lea dx,m
mov ah,09h
int 21h
pop dx
pop ax
endm
prg segment
extrn inp:far,dsp:far
assume cs:prg,ds:data
start:mov ax,data
mov ds,ax
print m1
call inp
mov bh,bl
call inp
mov cl,04h
ror bl,cl
cmp bl,bh
jne dn1
print m2
jmp last
dn1:print m3
last:mov ah,4ch
int 21h
prg ends
end start
output:
Expt no 7d: alp to check whether a given 16
bit no is bitwise palindrome
Or not.
data segment
m1 db 0ah,0dh,"enter the 16 bit no:
$"
m2 db 0ah,0dh,"the no is bitwise
palindrom $"
m3 db 0ah,0dh,"the no is not bitwise
palindrom $"
data ends
print macro m
push ax
push dx
lea dx,m
mov ah,09h
int 21h
pop dx
pop ax
endm
prg segment
extrn inp:far,dsp:far
assume cs:prg,ds:data
start:mov ax,data
mov ds,ax
print m1
call inp
mov ah,bl
call inp
mov al,bl
mov bx,ax
mov cx,0010h
up:rol bx,1
rcr ax,1
loop up
xor ax,bx
jnz npal
print m2
jmp last
npal:print m3
last:mov ah,4ch
int 21h
prg ends
end start
output:
Expt no 8a: alp to find smallest no.
data segment
m1 db 0ah,0dh,"Enter the value on N:
$"
m2 db 0ah,0dh,"enter the no one by
one:$"
m3 db 0ah,0dh,"smallest no is: $"
m4 db 0ah,0dh,"$"
list db 100 dup(00)
data ends
print macro m
push ax
push dx
lea dx,m
mov ah,09h
int 21h
pop dx
pop ax
endm
prg segment
extrn inp:far,dsp:far
assume cs:prg,ds:data
start:mov ax,data
mov ds,ax
print m1
call inp
mov cl,bl
mov dl,bl
print m2
mov ch,00h
lea si,list
up:print m4
call inp
mov [si],bl
inc si
loop up
lea si,list
dec dl
mov cl,dl
mov al,[si]
up1:inc si
cmp al,[si]
jc dn
mov al,[si]
dn:loop up1
print m3
mov bl,al
call dsp
mov ah,4ch
int 21h
prg ends
end start
output:
Expt no 8b: alp to find largest no.
data segment
m1 db 0ah,0dh,"Enter the value on N:
$"
m2 db 0ah,0dh,"enter the no one by
one:$"
m3 db 0ah,0dh,"largest no is: $"
m4 db 0ah,0dh,"$"
list db 100 dup(00)
data ends
print macro m
push ax
push dx
lea dx,m
mov ah,09h
int 21h
pop dx
pop ax
endm
prg segment
extrn inp:far,dsp:far
assume cs:prg,ds:data
start:mov ax,data
mov ds,ax
print m1
call inp
mov cl,bl
mov dl,bl
print m2
mov ch,00h
lea si,list
up:print m4
call inp
mov [si],bl
inc si
loop up
lea si,list
dec dl
mov cl,dl
mov al,[si]
up1:inc si
cmp al,[si]
jnc dn
mov al,[si]
dn:loop up1
print m3
mov bl,al
call dsp
mov ah,4ch
int 21h
prg ends
end start
output:
Expt no 8c: alp to find average of n no.
data segment
m1 db 0ah,0dh,"enter the value of
n:$"
m2 db 0ah,0dh,"enter the nos 1 by
1:$"
m3 db 0ah,0dh,"the average is $"
m4 db 0ah,0dh,"$"
list db 100 dup (00)
data ends
print macro m
push ax
push dx
lea dx,m
mov ah,09h
int 21h
pop dx
pop ax
endm
prg segment
assume cs:prg,ds:data
extrn inp:far,dsp:far
start:mov ax,data
mov ds,ax
print m1
call inp
mov cl,bl
mov dl,bl
mov ch,00h
lea si,list
print m2
up:print m4
call
inp
mov
[si],bl
inc
si
loop
up
mov
cl,dl
mov
ax,00h
lea
si,list
up1:mov bl,[si]
mov
bh,00h
add
ax,bx
inc
si
loop up1
div
dl
print m3
mov
bl,al
call dsp
mov
ah,4ch
int
21h
prg
ends
end
start
output:
Expt no 9a: alp to sort no in ascending
order.
data segment
m1 db 0ah,0dh,"Enter the value of N
$"
m2 db 0ah,0dh,"Enter the no 1 by 1
$"
m3 db 0ah,0dh,"The ascending order is
$"
m4 db 0ah,0dh,"$"
list db 100 dup(00)
data ends
print macro m
push ax
push dx
lea dx,m
mov ah,09h
int 21h
pop dx
pop ax
endm
prg segment
extrn inp:far,dsp:far
assume cs:prg,ds:data
start:mov ax,data
mov ds,ax
print m1
call inp
mov cl,bl
mov dl,bl
mov ch,00h
mov dh,bl
lea si,list
print m2
up:print m4
call inp
mov [si],bl
inc si
loop up
dec dh
up2:lea si,list
mov cl,dh
up1:mov al,[si]
mov bl,[si+01]
cmp al,bl
jc dn
xchg al,bl
mov [si],al
mov [si+01],bl
dn:inc si
loop up1
dec dh
jnz up2
print m3
lea si,list
mov cl,dl
up3:print m4
mov bl,[si]
call dsp
inc si
loop up3
mov ah,4ch
int 21h
prg ends
end start
output:
Expt no 9b: alp to sort no in descending
order.
data segment
m1 db 0ah,0dh,"Enter the value of N
$"
m2 db 0ah,0dh,"Enter the no 1 by 1
$"
m3 db 0ah,0dh,"The descending order is
$"
m4 db 0ah,0dh,"$"
list db 100 dup(00)
data ends
print macro m
push ax
push dx
lea dx,m
mov ah,09h
int 21h
pop dx
pop ax
endm
prg segment
extrn inp:far,dsp:far
assume cs:prg,ds:data
start:mov ax,data
mov ds,ax
print m1
call inp
mov cl,bl
mov dl,bl
mov ch,00h
mov dh,bl
lea si,list
print m2
up:print m4
call inp
mov [si],bl
inc si
loop up
dec dh
up2:lea si,list
mov cl,dh
up1:mov al,[si]
mov bl,[si+01]
cmp al,bl
jnc dn
xchg al,bl
mov [si],al
mov [si+01],bl
dn:inc si
loop up1
dec dh
jnz up2
print m3
lea si,list
mov cl,dl
up3:print m4
mov bl,[si]
call dsp
inc si
loop up3
mov ah,4ch
int 21h
prg ends
end start
output:
Expt no 10a: alp to separate positive and
negative no.
data segment
m1 db 0ah,0dh,"enter the value of
n$"
m2 db 0ah,0dh,"enter the no one by one
$"
m3 db 0ah,0dh,"the +ve no list $"
m4 db 0ah,0dh,"the -ve no list $"
m5 db 0ah,0dh,"$"
list db 100 dup(00)
plist db 100 dup(00)
nlist db 100 dup(00)
data ends
print macro m
push ax
push dx
lea dx,m
mov ah,09h
int 21h
pop dx
pop ax
endm
prg segment
assume cs:prg, ds:data
extrn inp:far,dsp:far
start: mov ax,data
mov ds,ax
print m1
call inp
mov cl,bl
mov bh,cl
print m2
lea si,list
mov ch,00h
up1:print m5
call inp
mov [si],bl
inc si
loop up1
lea si,list
lea di,plist
mov dh,00h
mov cl,bh
up2:mov al,[si]
rol al,01h
jc up3
mov al,[si]
mov [di],al
inc di
inc dh
up3:inc si
loop up2
lea si,list
lea di,nlist
mov dl,00h
mov cl,bh
up4:
mov al,[si]
rol al,01h
jnc up5
mov al,[si]
mov [di],al
inc di
inc dl
up5:
inc si
loop up4
print m3
lea si,plist
mov cl,dh
up6:print m5
mov bl,[si]
call dsp
inc si
loop up6
print m4
mov cl,dl
lea si,nlist
up7:print m5
mov bl,[si]
call dsp
inc si
loop up7
mov ah,4ch
int 21h
prg ends
end start
output:
Expt no 10b: alp to separate even and odd no.
data segment
m1 db 0ah,0dh,"enter the value of n:
$"
m2 db 0ah,0dh,"enter the no one by one:
$"
m3 db 0ah,0dh,"the even no list :$"
m4 db 0ah,0dh,"the odd no list:$"
m5 db 0ah,0dh,"$"
list db 100 dup(00)
plist db 100 dup(00)
nlist db 100 dup(00)
data ends
print macro m
push ax
push dx
lea dx,m
mov ah,09h
int 21h
pop dx
pop ax
endm
prg segment
assume cs:prg, ds:data
extrn inp:far,dsp:far
start: mov ax,data
mov ds,ax
print m1
call inp
mov cl,bl
mov bh,cl
print m2
lea si,list
mov ch,00h
up1:print m5
call inp
mov [si],bl
inc si
loop up1
lea si,list
lea di,plist
mov dh,00h
mov cl,bh
up2:mov al,[si]
ror al,01h
jc up3
mov al,[si]
mov [di],al
inc di
inc dh
up3:inc si
loop up2
lea si,list
lea di,nlist
mov dl,00h
mov cl,bh
up4:
mov al,[si]
ror al,01h
jnc up5
mov al,[si]
mov [di],al
inc di
inc dl
up5:
inc si
loop up4
print m3
lea si,plist
mov cl,dh
up6:print m5
mov bl,[si]
call dsp
inc si
loop up6
print m4
mov cl,dl
lea si,nlist
up7:print m5
mov bl,[si]
call dsp
inc si
loop up7
mov ah,4ch
int 21h
prg ends
end start
output:
Expt no 11a: alp to search a key in a string.
data
segment
m1 db
0ah,0dh,"enter the string:$"
m2 db
0ah,0dh,"enter the key to be searched:$"
m3 db
0ah,0dh,"the key is present:$"
m4 db
0ah,0dh,"the key is not present:$"
str
db 100 dup(00)
data
ends
print
macro m
push
ax
push
dx
lea
dx,m
mov
ah,09h
int
21h
pop
dx
pop
ax
endm
prg
segment
assume cs:prg,ds:data
start:mov ax,data
mov ds,ax
print m1
mov cx,0000h
lea si,str
up:mov ah,01h
int 21h
cmp al,0Dh
je dn
mov [si],al
inc si
inc cx
jmp up
dn:print m2
mov ah,01h
int 21h
lea si,str
up1:cmp al,[si]
je dn1
inc si
loop up1
print m4
jmp last
dn1:print m3
last:
mov ah,4ch
int 21h
prg ends
end start
output:
Expt no 11b:alp to concantinate two strings.
data
segment
m1 db
0ah,0dh,"enter the first string:$"
m2 db
0ah,0dh,"enter the second string:$"
m3 db
0ah,0dh,"concantinated string is:$"
str1
db 100 dup(00)
str2
db 100 dup(00)
data
ends
print
macro m
push
ax
push
dx
lea
dx,m
mov
ah,09h
int
21h
pop
dx
pop
ax
endm
prg
segment
assume cs:prg,ds:data
start:mov ax,data
mov ds,ax
print m1
mov cx,0000h
lea si,str1
up:mov ah,01h
int 21h
cmp al,0Dh
je dn
mov [si],al
inc si
inc cx
jmp up
dn:mov bx,cx
mov cx,0000h
print m2
lea si,str2
up1:mov ah,01h
int 21h
cmp al,0dh
je dn1
mov [si],al
inc si
inc cx
jmp up1
dn1:lea si,str1
add si,bx
lea di,str2
up2:mov al,[di]
mov [si],al
inc si
inc di
loop up2
mov byte ptr[si],'$'
print m3
print str1
mov ah,4ch
int 21h
prg ends
end start
output:
Expt no 11c: alp to reverse a string and
check whether it is palindrome
or not.
data segment
m1 db 0ah,0dh,"Enter the string: $"
m2 db 0ah,0dh,"The reversed string is:
$"
m3 db 0ah,0dh,"the string is palindrome:
$"
m4 db 0ah,0dh,"The string is not a
palindrome: $"
str1 db 100 dup(00)
str2 db 100 dup(00)
data ends
print macro m
push ax
push dx
lea dx,m
mov ah,09h
int 21h
pop dx
pop ax
endm
prg segment
assume cs:prg,ds:data
start:mov ax,data
mov ds,ax
print m1
lea si,str1
mov cx,0000h
up:mov ah,01h
int 21h
cmp al,0dh
je
dn
mov [si],al
inc si
inc cx
jmp up
dn:mov bx,cx
lea si,str1
lea di,str2
add si,bx
dec si
up1:mov al,[si]
mov [di],al
inc di
dec si
loop up1
print m2
lea di,str2
mov cx,bx
up3: mov dl,[di]
mov ah,02h
int 21h
inc di
loop up3
lea si,str1
lea di,str2
mov cx,bx
up2:mov al,[si]
cmp al,[di]
jne dn2
inc si
inc di
loop up2
print m3
jmp last
dn2:print m4
last
:mov ah,4ch
int 21h
prg ends
end start
output:
Expt no 11d: alp to change the case of string.
data
segment
m1 db
0ah,0dh,"enter the string:$"
m2 db
0ah,0dh,"the result:$"
str
db 100 dup(00)
data
ends
print
macro m
push
ax
push
dx
lea
dx,m
mov
ah,09h
int
21h
pop
dx
pop
ax
endm
prg
segment
assume cs:prg,ds:data
start:mov ax,data
mov ds,ax
print m1
mov cx,0000h
lea si,str
up:mov ah,01h
int 21h
cmp al,0Dh
je dn
mov [si],al
inc si
inc cx
jmp up
dn:lea si,str
up1:mov al,[si]
cmp al,'A'
jc d2
cmp al,'Z'
jnc d1
add al,20h
mov [si],al
jmp d2
d1:cmp al,'a'
jc d2
cmp al,'z'
jnc d2
sub al,20h
mov [si],al
d2:inc si
loop up1
mov byte ptr[si],'$'
print m2
print str
mov ah,4ch
int 21h
prg ends
end start
output:
Expt no 12a: alp to display system date on console.
data segment
m1 db 0ah,0dh,"the system date is :$"
data ends
print macro m
push ax
push dx
lea dx,m
mov ah,09h
int 21h
pop dx
pop ax
endm
prg segment
extrn inp:far,dsp:far
assume cs:prg,ds:data
start:mov ax,data
mov ds,ax
mov ah,2ah
int 21h
print m1
mov bh,dl
mov bl,al
call dsp
mov dl,':'
mov ah,02h
int 21h
mov bl,bh
call dsp
mov dl,':'
mov ah,02h
int 21h
mov bl,dh
call dsp
mov ah,02h
int 21h
mov bl,ch
call dsp
mov bl,cl
call dsp
mov ah,4ch
int 21h
prg ends
end start
output:
Expt no 12b: alp to display system time on console.
data segment
m1 db 0ah,0dh,"the system time is: $"
data ends
print macro m
push ax
push dx
lea dx,m
mov ah,09h
int 21h
pop dx
pop ax
endm
prg segment
extrn inp:far,dsp:far
assume cs:prg,ds:data
start:mov ax,data
mov ds,ax
mov ah,2ch
int 21h
print m1
mov bl,ch
call dsp
mov dl,':'
mov ah,02h
int 21h
mov bl,cl
call dsp
mov dl,':'
mov ah,02h
int 21h
mov bl,dh
call dsp
mov ah,4ch
int 21h
prg ends
end start
output:
data segment
m1 db 0ah,0dh,"the system date is :$"
data ends
print macro m
push ax
push dx
lea dx,m
mov ah,09h
int 21h
pop dx
pop ax
endm
prg segment
extrn inp:far,dsp:far
assume cs:prg,ds:data
start:mov ax,data
mov ds,ax
mov ah,2ah
int 21h
print m1
mov bh,dl
mov bl,al
call dsp
mov dl,':'
mov ah,02h
int 21h
mov bl,bh
call dsp
mov dl,':'
mov ah,02h
int 21h
mov bl,dh
call dsp
mov ah,02h
int 21h
mov bl,ch
call dsp
mov bl,cl
call dsp
mov ah,4ch
int 21h
prg ends
end start
output:
Expt no 12b: alp to display system time on console.
data segment
m1 db 0ah,0dh,"the system time is: $"
data ends
print macro m
push ax
push dx
lea dx,m
mov ah,09h
int 21h
pop dx
pop ax
endm
prg segment
extrn inp:far,dsp:far
assume cs:prg,ds:data
start:mov ax,data
mov ds,ax
mov ah,2ch
int 21h
print m1
mov bl,ch
call dsp
mov dl,':'
mov ah,02h
int 21h
mov bl,cl
call dsp
mov dl,':'
mov ah,02h
int 21h
mov bl,dh
call dsp
mov ah,4ch
int 21h
prg ends
end start
output:
8086 Microprocessor Interfacing.
Steps for interfacing:
·
Go to
start>als>alsplxpc107>sample VBapplications.
· Note the port address.
· Save the program with .asm extension and exit from editor window
· Compile: masm filename;
· Link : link filename;
· Allowio port_address filename.exe
· Eg: allowio 0x0c880 fiename.exe
· Note the port address.
· Save the program with .asm extension and exit from editor window
· Compile: masm filename;
· Link : link filename;
· Allowio port_address filename.exe
· Eg: allowio 0x0c880 fiename.exe
8086 Interfacing programs.
Expt no 1:Interfacing logic controller.
Expt no 1a:alp to implement ring counter.
data segment
ba equ 0c880h
pa equ ba+00h
pb equ ba+01h
pc equ ba+02h
cwr equ ba+03h
data ends
prg segment
assume cs:prg,ds:data
start:mov ax,data
mov ds,ax
up: mov al,8ah
mov dx,cwr
out dx,al
mov cx,0008h
mov al,80h
up1: mov dx,pa
out dx,al
call delay
ror al,01
loop up1
mov ah,0bh
int 21h
or al,al
jz up
delay proc near
push bx
push cx
push ax
mov bx,0f00fh
up2:mov cx,0f00fh
here:loop here
up3:mov ax,00ffh
hre:loop hre
dec bx
jnz up2
pop ax
pop cx
pop bx
ret
delay endp
mov ah,4ch
int 21h
prg ends
end start
Expt no 1b: alp to implement bcd counter.
data segment
ba equ 0c880h
pa equ ba+00h
pb equ ba+01h
pc equ ba+02h
cwr equ ba+03h
data ends
prg segment
assume cs:prg,ds:data
start:mov ax,data
mov ds,ax
up: mov al,8ah
mov dx,cwr
mov cx,0100
out dx,al
mov al,00h
up1:mov dx,pa
out dx,al
call delay
add al,01h
daa
loop up1
mov ah,0bh
int 21h
or al,al
jz up
delay proc near
push bx
push cx
push ax
mov bx,0f00fh
up2:mov cx,0f00fh
here:loop here
up3:mov ax,00ffh
hre:loop hre
dec bx
jnz up2
pop ax
pop cx
pop bx
ret
delay endp
mov ah,4ch
int 21h
prg ends
end start
Expt no 1c:alp to check parity.
data segment
baseaddr equ 0c880h
porta equ baseaddr+00h
portb equ baseaddr+01h
portc equ baseaddr+02h
cwr equ baseaddr+03h
data ends
prg segment
assume cs:prg,ds:data
start: mov ax,data
mov ds,ax
up:mov al,8ah
mov dx,cwr
out dx,al
mov dx,portb
in al,dx
add al,00h
jp epb
mov al,00h
mov bx,porta
out dx,al
call delay
jmp exit
epb:mov al,0ffh
mov dx,porta
out dx,al
call delay
delay proc near
push dx
push cx
mov dx,0fffh
uu1:mov cx,0ffffh
here:loop here
dec dx
jnz uu1
pop cx
pop dx
ret
delay endp
exit:mov ah, 0dh
int 21h
or al,al
jz up
mov ah,4ch
int 21h
prg ends
end start
Expt no 2:Interfacing stepper motor
data segment
ba equ 0c880h
pa equ ba+00h
pb equ ba+01h
pc equ ba+02h
cwr equ ba+03h
data ends
prg segment
assume cs:prg,ds:data
start:mov ax,data
mov ds,ax
mov al,80h
mov dx,cwr
out dx,al
again:mov cx,0064h
mov dx,portc
mov al,0eeh
up:out dx,al
call delay
rol al,01
loop up
mov cx,00c8h
up1:out dx,al
call delay
ror al,01h
loop up1
mov ah,0bh
int 21h
or al,al
jz again
delay proc near
push ax
push bx
push cx
mov bh,0ffh
up3:mov cx,0ffffh
here:loop here
up4:mov ax,0ffffh
there:loop there
dec bh
jnz up3
jnz up4
pop cx
pop bx
pop ax
ret
delay endp
prg ends
end start
Expt no 3:Interfacing seven segment display.
data segment
ba equ 0c880h
pa equ ba+00h
pb equ ba+01h
pc equ ba+02h
cwr equ ba+03h
list db 3fh,06h,5bh,4fh,66h,6dh
data ends
prg segment
assume cs:prg,ds:data
start:mov ax,data
mov ds,ax
mov al,80h
mov dx,cwr
out dx,al
again:mov cx,0006h
mov bl,00h
lea si,list
up:mov al,bl
mov dx,pc
out dx,al
mov al,[si]
mov dx,pa
out dx,al
call delay
inc si
inc bl
loop up
mov ah,0bh
int 21h
or al,al
jz again
mov ah,4ch
int 21h
delay proc near
push bx
push cx
mov bx,0fffh
vi:
mov cx,0fffh
here:loop here
dec bx
jnz vi
pop cx
pop bx
ret
delay endp
prg ends
end start
*********************************THE END***************************************
Special thanks to….
Special thanks to….
Somali
bhosale , Indrayani kamat , Hrishikesh kamat.
********************************************************************************
********************************************************************************
No comments:
Post a Comment