You are on page 1of 100

8086 Lab Manual 1

IV SEM CSE
LAB MANUAL
MICROPROCESSOR
LAB (8086)
Sub Code: 06CSL48
Mr. J B.Sasanur Mr. Basavaraj G.Kumbar
Dept. of CSE REC,Hulkoti.
8086 Lab Manual 2
Contents
MASM Commands
Sample Programs
Lab Programs
Instrut!on Set
Interrupts
Inter"a!ng #ev!es
V!va $uest!ons and Ans%ers
Dept. of CSE REC,Hulkoti.
8086 Lab Manual 3
MASM C&MMA'#S(
C ()*d "oldername
C()"oldername*ed!t "!lename.asm
After this command executed in command prompt an editor window will open.
Program should be typed in this window and saved. The program structure is given
below.
Struture o" Program(
.model t!n+)small)med!um)large
.Sta, -some number*
.data
. In!t!al!/e data
. %0!0 !s used !n program.
.ode
. Program log! goes 0ere.
.
end
1o run t0e program2 t0e "ollo%!ng steps 0ave to be "ollo%ed(
C()"oldername*masm "!lename.asm
After this command is executed in command prompt if there are no errors in
program regarding to syntax the assembler will generates an object module as discuss
above.
C()"oldername*l!n, "!lename.obj
After verifying the program for correct syntax and the generated object files
should be linked together. For this the above link command should be executed and it will
give an EE file if the model directive is small as discuss above.
C()"oldername*debug "!lename.e3e
After generating EE file by the assembler it!s the time to check the output. For
this the above command is used and the execution of the program can be done in different
ways. "t is as shown below#
44 g . omplete e3eut!on o" program !n s!ngle step.
Dept. of CSE REC,Hulkoti.
8086 Lab Manual 4
44 t . Step%!se e3eut!on.
44d ds( start!ng address or end!ng address . 1o see data !n memor+ loat!ons
44p . 5sed to e3eute !nterrupt or proedure dur!ng step%!se e3eut!on o"
program
44 6 . 1o 6u!t t0e e3eut!on.
Dept. of CSE REC,Hulkoti.
8086 Lab Manual 5
'ote(
$evelop and execute the following programs using an %&%' Assembly (anguage.
All the programs to be executed using an assembler like )A*)+ TA*) etc.
Program should have suitable comments.
The board layout and the circuit diagram of the interface are to be provided to the
student during the examination.
SAMPLE P7&G7AMS
,. Program to move data between the registers
-. Program to move immediate data
.. Program to add two numbers
/. Program to multiply two ,'0bit numbers
1. Program to divide .-0bit unsigned number by ,'0bit number
'. Program to illustrate the use of AAA instruction
LAB P7&G7AMS
1. a8 *earch a key element in a list of 2n! ,'0bit numbers using the 3inary search
algorithm.
b8 4ead the status of eight input bits from the (ogic 5ontroller "nterface and
display 2FF! if it is even parity bits otherwise display &&. Also display number of
,!s in the input data.
2. a8 6rite A(P macros#
!. To read a character from the keyboard in the module 7,8 7in a different file8
!!. To display a character in module7-8 7from different file8
!!!. 9se the above two modules to read a string of characters from the keyboard
terminated by the carriage return and print the string on the display in the next
line.
b8 Perform the following functions using the (ogic 5ontroller "nterface.
!. 35$ up0down 5ounter !!. 4ing 5ounter
3. a8 *ort a given set of 2n! numbers in ascending and descending orders using the
3ubble *ort algorithm.
b8 4ead the status of two %0bit inputs 7 : ;8 from the (ogic 5ontroller "nterface
and display <;.
4. a8 4ead an alphanumeric character and display its e=uivalent A*5"" code at the
center of the screen.
b8 $isplay messages F"4E and >E(P alternately with flickering effects on a ?0
segment display interface for a suitable period of time.
Dept. of CSE REC,Hulkoti.
8086 Lab Manual 6
Ensure a flashing rate that makes it easy to read both the messages 7Examiner
does not specify these delay values nor it is necessary for the student to compute
these values8.
5. a8 4everse a given string and check whether it is a palindrome or not.
b8 Assume any suitable message of ,- characters length and display it in the
rolling fashion on a ?0segment display interface for a suitable period of time.
Ensure a flashing rate that makes it easy to read both the messages. 7Examiner
does not specify these delay values nor it is necessary for the student to compute
these values8.
6. a8 4ead two strings+ store them in locations *T4, and *T4-. 5heck whether they
are e=ual or not and display appropriated messages. Also display the length of the
stored strings.
b8 5onvert a ,'0bit binary value 7assumed to be an unsigned integer8 to 35$ and
display it from left to right and right to left for specified number of times on a ?0
segment display interface.
. a8 4ead your name from the keyboard and display it at a specified location on the
screen in front of the message 6hat is your name@ ;ou must clear the entire
screen before display.
b8 $rive a *tepper )otor interface to rotate the motor in clockwise direction by A
steps 7A is specified by the examiner8. "ntroduce suitable delay between
successive steps. 7Any arbitrary value for the delay may be assumed by the
student8.
8. a8 5ompute the factorial of a positive integer 2n! using recursive procedure.
b8 $rive a stepper motor interface to rotate the motor in anticlockwise direction
by A steps 7A is specified by the examiner8. "ntroduce suitable delay between
successive steps 7 Any arbitrary value for he delay may be assumed by the
student8.
!. a8 5ompute n5r using recursive procedure. Assume that 2n! and 2r! are non0
negative integers.
b8 $rive a stepper motor interface to rotate the motor by A steps left direction and
A steps right direction 7A is specified by the examiner8. "ntroduce suitable delay
between successive steps. 7Any arbitrary value for the delay may be assumed by
the student8.
10. a8 Find out whether a given sub0string is present or not in a main string of
characters.
Dept. of CSE REC,Hulkoti.
8086 Lab Manual
b8 *can a % x . keypad for key closure and to store the code of the key pressed in
a memory location or display on screen. Also display row and column numbers of
the key pressed.
11. a8 Benerate the first 2n! Fibonacci numbers.
b8 *can a % x . keypad for key closure and simulate A$$ and *93T4A5T
operations as in a calculator.
12. a8 4ead the current time from the system and display it in the standard format on
the screen.
b8 Benerate the *ine 6ave using $A5 interface 7The output of the $A5 is to be
displayed on the 54C8.
13. a8 Program to simulate a $ecimal 9p0counter to display &&0DD.
b8 Benerate a >alf 4ectified *ine wave form using the $A5 interface. 7The
output of the $A5 is to be displayed on the 54C8.
14. a8 4ead a pair of input co0ordinates in 35$ and move the cursor to the specified
location on the screen.
b8 Benerate a Fully 4ectified *ine waveform using the $A5 interface. 7The
output of the $A5 is to be displayed on the 54C8.
15. a8 Program to create a file 7input file8 and to delete an existing file.
b8 $rive an elevator interface in the following way#
!. "nitially the elevator should be in the ground floor+ with all re=uests in CFF
state.
!!. 6hen a re=uest is made from a floor+ the elevator should move to that floor+
wait there for a couples of seconds+ and then come down to ground floor and stop.
"f some re=uests occur during going up or coming down they should be ignored.
Aote# "n the examination each student picks one =uestion from a lot of all ,1 =uestions
Dept. of CSE REC,Hulkoti.
8086 Lab Manual 8
SAMPLE P7&G7AMS
9. ALP 1& M&VE #A1A BE1:EE' 1;E 7EGIS1E7S.
.model t!n+
.data
num, db 1&h
num- dw ,-./h
.ode
mov ax+Edata
mov ds+ax F$ATA *EB)EAT "A"T"A("GAT"CA
mov al+num,
mov ah+al
mov bh+ah
mov bl+al F)CHE* 3;TE (EABT> CF $ATA F4C) 4EB.A( TC 4EB.3(
mov cx+num-
mov dx+cx
mov si+ax
mov di+si F)CHE* 6C4$ (EAB>T CF $ATA F4C) 4EB.5 TC 4EB.$
int . FTE4)"AATE* T>E P4CB4A) EE59T"CA
align ,' F$ATA *EB)EAT *TA4T* F4C) PABE 3C9A$A4;
end
Run1" #$%5050, &$%5050, C$%1234, D$%1234, S'%1234, D'%1234
Dept. of CSE REC,Hulkoti.
8086 Lab Manual !
<. ALP 1& M&VE IMME#IA1E #A1A
.model t!n+
.ode
mov al+,&h
mov ah+,&
mov cl+1&h
mov ch+1& F)CHE* "))E$"ATE HA(9E TC % 3"T 4EB"*TE4
mov bx+,-./h
mov dx+,-./ F)CHE* "))E$"ATE HA(9E TC ,' 3"T 4EB"*TE4
mov si+/&&&h
mov di+-&&&h
int . FTE4)"AATE T>E P4CB4A) EE59T"CA
end
Run1" #$%1010, &$%1234, C$%5050, D$%1234, S'%4000, D'%2000
Dept. of CSE REC,Hulkoti.
8086 Lab Manual 10
=. ALP 1& A## 1:& '5MBE7S
.model small
.data
num, db &1h
num- db &'h
num. dw ,-./h
num/ dw &&&-h
sum db @
sum- dw @
.ode
mov ax+Edata
mov ds+ax F"A"T"A("GE* $ATA *EB)EAT
mov al+num,
mov bl+num-
add al+bl FA$$ T>E - 3;TE*
mov sum+al F*TC4E* T>E 4E*9(T "A )E)C4;
mov cx+num.
add cx+num/ FA$$ T>E - 6C4$*
mov sum-+cx F*TC4E* T>E 4E*9(T "A )E)C4;

int . FTE4)"AATE T>E P4CB4A) EE59T"CA
align ,' F$* *TA4T* F4C) PABE 3C9A$A4;
end
Run1" #$%((0&, C$%1236
Dept. of CSE REC,Hulkoti.
8086 Lab Manual 11
>. ALP 1& M5L1IPL? 1:& 9@ABI1 '5MBE7S
.model small
.data
num, dw ,-./h
num- dw &ffffh
res dw 1 dup7&8
.ode
mov ax+Edata
mov ds+ax F"A"T"A("GAT"CA CF $ATA *EB)EAT
mov ax+num,
mov dx+num-
mul dx F)9(T"P("E* - ,'03"T A9)3E4*
mov res+ax
mov resI-+dx F*TC4E* T>E "A )E)C4;
int . FTE4)"AATE T>E P4CB4A) EE59T"CA
align ,' F$* *TA4T* F4C) PABE 3C9A$A4;
end
Dept. of CSE REC,Hulkoti.
8086 Lab Manual 12
B. ALP 1& #IVI#E =<ABI1 5'SIG'E# '5MBE7 B? 9@ABI1 '5MBE7
.model small
.data
dvd dd ,-./1'?%h
dvr dw &ffffh
=uot dw @
remd dw @
.ode
mov ax+Edata
mov ds+ax F"A"T"A("GAT"CA CF $ATA *EB)EAT
mov si+offset dvd
mov ax+word ptrJsiK
mov dx+word ptrJsiI-K
mov cx+dvr
div cx
mov =uot+ax
mov remd+dx
int . FTE4)"AATE* T>E P4CB4A) EE59T"CA
align ,' F$* *TA4T* F4C) PABE 3C9A$A4;
end
Dept. of CSE REC,Hulkoti.
8086 Lab Manual 13
@. ALP 1& !llustrate t0e use o" AAA !nstrut!on
.model small
.data
read macro F*tart of a macro
mov ah+&,h Fread a single key stroke
int -,h
endm Fend of macro
.ode
mov ax+Edata
mov ds+ax F"A"T"A("GAT"CA CF $ATA *EB)EAT
read F5A(( )A54C 4EA$
mov bl+al F*TC4E T>E 4EA$ LE; "A 3( 4EB"*TE4
read
mov cl+al
add al+bl FA$$ A( 6"T> 3( AA$ *TC4E* T>E 4E*9(T "A A(.
mov dl+al
mov ah+&
aaa FA$M9*T T>E A( HA(9E TC 9APA5LE$ 35$
mov si+ax
int . FTE4)"AATE* T>E P4CB4A) EE59T"CA
end
Dept. of CSE REC,Hulkoti.
8086 Lab Manual 14
LAB P7&G7AMS
9. a Program to sear0 a ,e+ element !n a l!st o" n numbers us!ng t0e B!nar+ sear0
Algor!t0m.
.model small
.Sta, 9CC
.data
array db 1+ ,-+ -.+ /1+ '&+ '?+ D'+ ,&&
len e=u N0array
key db ,&&
msg, db OfoundNO
msg- db Onot foundNO
.ode
mov ax+ Edata
mov ds+ ax
mov si+ &&h
mov di+ len0,
mov cl+ key
aga!n( mov bx+ si
add bx+ di
shr bx+ ,
cmp cl+ arrayJbxK
je found
ja down
mov di+ bx
dec di
jmp up
do%n( mov si+ bx
inc si
up( cmp si+ di
jle again
lea dx+ msg-
jmp display
"ound( lea dx+ msg,
d!spla+( mov ah+ &Dh
int -,h
int .
end
Dept. of CSE REC,Hulkoti.
8086 Lab Manual 15
Conlus!on(
This program performs a search for a key element in an array. "f the search
element is found it will display a message 2found!. As the search element 7key in
program8 is not present in the given array it will display a message 2not found!.
Dept. of CSE REC,Hulkoti.
8086 Lab Manual 16
9. b. 7ead t0e status o" e!g0t !nput b!ts "rom t0e Log! Controller Inter"ae and
d!spla+ DD !" !t !s even par!t+ b!ts ot0er%!se d!spla+ CC. Also d!spla+ number o" 9Es !n
t0e !nput data.
.model small
.data
pa e=u &d%&&h
pb e=u &d%&,h
pc e=u &d%&-h
ctrl e=u &d%&.h
.ode
start( mov ax+ Edata
mov ds+ ax

mov dx+ ctrl
mov al+ %-h
out dx+ al
mov dx+ pb
in al+ dx
mov bl+ &&h
mov cx+ &%
up( rcl al+,
jnc down
inc bl
do%n( loop up
test bl+&,h
jnP oddp
mov al+&ffh
jmp next
oddp( mov al+&&h
ne3t( mov dx+pa
out dx+al
call delay
mov al+ bl
mov dx+ pa
out dx+ al
int .
dela+ pro
mov ax+&ffffh
up<( mov dx+/fffh
up9( dec dx
Dept. of CSE REC,Hulkoti.
8086 Lab Manual 1
jnP up, .
dec ax
)n* up2
ret
dela+ endp
end start
Conlus!on(
The program reads port 3 of %-511A which is an input port. "f input
contains an odd number of ,!s 7that is the number of (E$!s at logic ,8 then first display
&& at port A+ which is an output port+ indicating input is odd parity and after some delay
display the number of ,!s present in input at port A.
*imilarly display FF on port A if input data contains even number of ,!s and after some
delay display the number of ,!s present in input data read form port 3.
Dept. of CSE REC,Hulkoti.
8086 Lab Manual 18
<. a. :r!te ALP maros(
! 1o read a 0arater "rom t0e ,e+board !n t0e module F98 F!n a d!""erent "!le8.
!! 1o d!spla+ a 0arater !n moduleF<8 F"rom d!""erent "!le8
!!! 5se t0e above t%o modules to read a str!ng o" 0araters "rom t0e ,e+board
term!nated b+ t0e arr!age return and pr!nt t0e str!ng on t0e d!spla+ !n t0e
ne3t l!ne.
.model small
.data
*tring db .& dup 7@8
.ode
!nlude c#QmasmQread.mac
!nlude c#QmasmQwrite.mac
start( mov ax+ Edata
mov ds+ ax
mov si+ &&h
aga!n( read
cmp al+ &dh
je down
mov stringJsiK+ al
inc si
jmp again
do%n( mov cx+ si
mov si+ &&h
write &dh
write &ah
ba,( write stringJsiK
inc si
loop back
int .
end start
read.ma
read maro
mov ah+ &,h
int -,h
endm
%r!te.ma
%r!te maro x
mov dl+ x
mov ah+ &-h
int -,h
Dept. of CSE REC,Hulkoti.
8086 Lab Manual 1!
endm
Conlus!on(
This program reads a string message till enter key is pressed 7user has to enter
the string8. As soon as enter key pressed the read string will displayed on the screen.
Dept. of CSE REC,Hulkoti.
8086 Lab Manual 20
<. b. Per"orm t0e "ollo%!ng "unt!ons us!ng t0e Log! Controller Inter"ae
! BC# upAdo%n Counter
!! 7!ng Counter
BC# upAdo%n ounter
.model small
.data
pa e=u &d%&&h
pb e=u &d%&,h
pc e=u &d%&-h
ctrl e=u &d%&.h
.ode
start( mov ax+Edata
mov ds+ax
mov al+%-h
mov dx+ctrl
out dx+al
mov cl+&&h
up( call delay
mov ah+&'h
mov dl+&ffh
int -,h
cmp al+ R=R
je exit
mov dx+ pb
in al+ dx
cmp al+ &&
je downc
F 9P 5C9ATE4
mov al+ cl
mov dx+ pa
out dx+ al
add al+&,h
daa
mov cl+ al
cmp cl+DDh
jbe up
mov cl+&&
jmp up
F $C6A 5C9ATE4
Dept. of CSE REC,Hulkoti.
8086 Lab Manual 21
do%n( mov al+cl
mov dx+pa
out dx+al
cmp cl+&&h
je down
mov al+cl
sub al+&,
das
mov cl+al
jmp down,
do%n( mov cl+DDh
do%n9( jmp up
e3!t( int .
dela+ pro
mov ax+ &ffffh
up<( mov bx+ /fffh
up9( dec bx
jnP up,
dec ax
jnP up-
ret
dela+ endp
end start
Conlus!on(
The program performs the up0down counter based on the input data given
on logic controller read through port 3. "f the input is Pero then it performs down counter
starting from DD down to && and if other than Pero is the input then it perform up counter
starting from && down to DD. And the counting will continue until a key 2=! is pressed in
the key board+ so after displaying the count on logic controller every time it checks
whether a key 2=! is pressed or not.
6hile observing the output of down counter or up counter if the input changes then from
that point the counting will also changes. *uppose if the input is Pero then it perform
down counting from DD to && after some time when the output is 1& then if we change the
input other than Pero then from that point it will start up counting that is form 1&+ 1,+ 1-.
and so on.
Dept. of CSE REC,Hulkoti.
8086 Lab Manual 22
7!ng ounter
.model small
.data
pa e=u &d%&&h
pb e=u &d%&,h
pc e=u &d%&-h
ctrl e=u &d%&.h
.ode
start( mov ax+Edata
mov ds+ax
mov al+%-h
mov dx+ctrl
out dx+al
mov cl+&-h
up( call delay
mov al+cl
mov dx+pa
out dx+al
rol cl+&,
mov ah+&'h
mov dl+&ffh
int -,h
cmp al+R=R
je exit
jmp up
e3!t( int .
dela+ pro
mov ax+&ffffh
up<( mov bx+&ffffh
up9( dec bx
jnP up,
dec ax
jnP up-
ret
dela+ endp
end start
Conlus!on(
This program performs ring counter. *tarting value is provided in 5(
register. "t displays the starting value on output port and rotates the value to left by one.
After rotating each bit by , position it waits for some delay to observe the rolling.
Dept. of CSE REC,Hulkoti.
8086 Lab Manual 23
C C C C C C 9 C
C C C C C 9 C C
C C C C 9 C C C
C C C 9 C C C C
C C 9 C C C C C
(
.
(
(
(
(
Dept. of CSE REC,Hulkoti.
8086 Lab Manual 24
=. a. Sort a g!ven set o" n numbers !n asend!ng and desend!ng orders us!ng t0e
Bubble Sort Algor!t0m.
.model small
.data
arr, db 1h+ %Dh+ .h+ 1'h+ ,h
len, e=u N0arr,
arr- db -Dh+ ,-h+ /1h+ %Dh+ ./h
len- e=u N0arr-
.ode
start( mov ax+ Edata
mov ds+ ax
F Ascending *ort
mov ch+ len,0, Fno of itterations
agn9( mov cl+ ch Fno of comparisions
mov si+ offset arr,
rept9( mov al+ JsiK
inc si
cmp al+ JsiK
jbe next,
xchg al+ JsiK
mov Jsi0,K+ al
ne3t9( dec cl
jnP rept,
dec ch
jnP agn,
F $escending *ort
mov ch+ len-0, Fno of itterations
agn<( mov cl+ ch Fno of comparisions
mov si+ offset arr-
rept<( mov al+ JsiK
inc si
cmp al+ JsiK
jae next-
xchg al+ JsiK
mov Jsi0,K+ al
ne3t<( dec cl
jnP rept-
dec ch
jnP agn-
int .
end start
Dept. of CSE REC,Hulkoti.
8086 Lab Manual 25
Conlus!on(
This program performs an ascending order and descending order sort on given
array. "t will store the result in data segment. 6e have to observe the data segment
memory location for our given array.
Dept. of CSE REC,Hulkoti.
8086 Lab Manual 26
=. b. 7ead t0e status o" t%o GAb!t !nputs FH I ?8 "rom t0e Log!al Controller
Inter"ae and d!spla+ HJ?.
.model small
.data
pa e=u &d%&&h
pb e=u &d%&,h
pc e=u &d%&-h
ctrl e=u &d%&.h
db @
; db @
G dw @
str, db ,.+,&+Oread NO
str- db ,.+,&+Oread ;NO
str. db ,.+,&+Sdisplay result NT+,.+,&
.ode
start( mov ax+Edata
mov ds+ax
mov al+%-h
mov dx+ctrl
out dx+al
up( mov ah+&Dh
mov dx+offset str,
int -,h
mov ah+&,
int -,h
mov dx+pb
in al+dx
mov x+al
mov ah+&Dh
mov dx+offset str-
int -,h
mov ah+&,
int -,h
mov dx+pb
in al+dx
mov y+al
mov ah+x
mul ah
Dept. of CSE REC,Hulkoti.
8086 Lab Manual 2
mov P+ax
mov ah+&Dh
mov dx+offset str.
int -,h
mov dx+pa
mov ax+P
mov al+ah
out dx+al
call delay
mov dx+pa
mov ax+P
out dx+al
mov ah+&,
int -,h
cmp al+OyO
je up
int .
dela+ pro
mov ax+&FFFF>
up<( mov bx+ &FFFF>
up9( dec bx
jnP up,
dec ax
jnP up-
ret
dela+ endp
end start

Conlus!on(
The program performs the multiplication between two bytes and gives the
result. A message appears on the screen as enter t0e "!rst number. First byte it reads
from the port 3 of logic controller 7user as to provide8 and waits for enter key to be
pressed and once enter key is pressed it will display a message on screen as enter t0e
seond number and once again it reads the data from port 3 7user as to provide one more
data from the same port8 and waits for enter key to be pressed. 4esult will be displayed
on the port A of the logic controller.
Dept. of CSE REC,Hulkoti.
8086 Lab Manual 28
>. a. 7ead an alp0anumer! 0arater and d!spla+s !ts e6u!valent ASCII ode at t0e
enter o" t0e sreen.
.model small
.data
alpha db @
ascii db @+ @+ ONO
.ode
start( mov ax+ Edata
mov ds+ ax
F 4EA$ A 5>A4A5TE4 F4C) LE; 3CA4$
mov ah+ &,h
int -,h
mov alpha+ al
mov cl+ &/
shr al+ cl
cmp al+ &Dh
jbe add.&
add al+ &?h
add=C( add al+ .&h
mov ascii+ al
mov al+ alpha
and al+ &fh
cmp al+ &Dh
jbe add.&h
add al+ &?h
add=C0( add al+ .&h
mov asciiI,+ al

F 5(EA4 T>E *54EEA
mov cx+ .&h<D&
mov dl+ R R
mov ah+ &-
ba,( int -,h
loop back
F *ET T>E 594*C94 PC*"T"CA TC $E*"4E$ (C5AT"CA.
mov ah+ &-h
mov bh+ &&
mov dl+ .& Fcolumn no.
mov dh+ ,1 Frow no.
int ,&h
Dept. of CSE REC,Hulkoti.
8086 Lab Manual 2!
mov dx+ offset ascii
mov ah+ &Dh
int -,h
F P4E** EATE4 LE;
mov ah+ &,h
int -,h
int .
end start
Conlus!on(
This program reads the character from key board by using the $C* function &,>
and find its A*5"" e=uivalent number. After that it clears the entire screen and places the
cursor to the specified location using 3"C* function &->. After+ it will display the A*5""
value where cursor is placed. "n order to observe the output on the screen the program is
not been terminated until enter key is pressed.
Dept. of CSE REC,Hulkoti.
8086 Lab Manual 30
>. b. #!spla+ messages DI7E and ;ELP alternatel+ %!t0 "l!,er!ng e""ets on a KA
Segment d!spla+ !nter"ae "or a su!table per!od o" t!me. Ensure a "las0!ng rate t0at
ma,es !t eas+ to read bot0 t0e messages.
.model small
.sta, 9CC
.data
pa e=u &d%&&h
pb e=u &d%&,h
pc e=u &d%&-h
ctrl e=u &d%&.h
str, db %eh+ &fDh+ %%h+ %'h
str- db %Dh+ %'h+ &c?h+ %ch
.ode
start( mov ax+ Edata
mov ds+ ax
mov al+ %&h
mov dx+ ctrl
out dx+ al
aga!n( mov bx+ offset str,
call display
call delay
mov bx+ offset str-
call display
call delay
mov ah+ &'h
mov dl+ &ffh
int -,h
cmp al+ R=R
jne again
int .
d!spla+ pro
mov si+ &.h
up9( mov cl+ &%h
mov ah+ JbxIsiK
up( mov dx+ pb
rol ah+ ,
mov al+ ah
out dx+ al
call clock
Dept. of CSE REC,Hulkoti.
8086 Lab Manual 31
dec cl
jnP up
dec si
cmp si+ 0,
jne up,
ret
d!spla+ endp
lo, pro
mov dx+ pc
mov al+ &,h
out dx+ al
mov al+ &
out dx+ al
mov dx+ pb
ret
lo, endp
dela+ pro
push cx
push bx
mov cx+ &ffffh
d<( mov bx+ %fffh
d9( dec bx
jnP d,
loop d-
pop bx
pop cx
ret
dela+ endp
end start
Conlus!on(
This program displays SF"4ET and S>E(PT on seven segment display interface
recursively one after the other with some delay till key 2=! is pressed on key board. "t!s
not going to read any data from interface device. The data which has to be displayed is
provided in the program itself.
Dept. of CSE REC,Hulkoti.
8086 Lab Manual 32
B. a. 7everse a g!ven str!ng and 0e, %0et0er !t !s a pal!ndrome or not.
.model small
.data
str, db OalamO
slen e=u 7N0str,8
str- db /& dup7&8
msg, db OPalindromeNO
msg- db OAot PalindromeNO
.ode
start( mov ax+Edata
mov ds+ax
mov es+ax
mov cx+slen
mov si+offset str,
add si+slen 0 ,
mov di+offset str-
up( mov al+JsiK
mov JdiK+al
dec si
inc di
loop up
mov si+offset str,
mov di+offset str-
mov cx+slen
cld
repe cmpsb
jne down
mov dx+offset msg,
jmp down,
do%n( mov dx+offset msg-
do%n9( mov ah+&Dh
int -,h
int .
end start
Conlus!on(
This program reverse the string provided in data segment by keeping the
original string as it is and compares both the strings. "t will check each and every
character. "f all the characters are same then the given string is said to be as palindrome
and it will display a message Spal!ndromeT on screen otherwise the given string is not
palindrome and it will display a message Snot pal!ndromeT on screen.
Dept. of CSE REC,Hulkoti.
8086 Lab Manual 33
B. b. Assume an+ su!table message o" 9< 0araters lengt0 and d!spla+ !t !n t0e
roll!ng "as0!on on a KASegment d!spla+ Inter"ae "or a su!table per!od o" t!me.
Ensure a "las0!ng rate t0at ma,es !t eas+ to read t0e message.
.model small
.sta, 9CC
.data
pa e=u &d%&&h
pb e=u &d%&,h
pc e=u &d%&-h
ctrl e=u &d%&.h
str, db &c&h+&fDh+&a/h+&b&h+DDh+D-h+%.h+&f%h+%&h+D%h+&c&h+&fDh
.ode
start( mov dx+ Edata
mov ds+ dx
mov al+ %&h
mov dx+ ctrl
out dx+ al
aga!n( mov bx+ offset str,
call display
call delay
mov ah+ &'h
mov dl+ &ffh
int -,h
cmp al+ R=R
jnP again
int .
d!spla+ pro
mov si+ &bh
up9( call delay
mov cl+ &%h
mov ah+ JbxIsiK
up( mov dx+ pb
rol ah+ ,
mov al+ ah
out dx+ al
call clock
dec cl
jnP up
Dept. of CSE REC,Hulkoti.
8086 Lab Manual 34
dec si
cmp si+ 0,
jne up,
ret
d!spla+ endp
lo, pro
mov dx+ pc
mov al+ &,h
out dx+ al
mov al+ &
out dx+ al
mov dx+ pb
ret
lo, endp
dela+ pro
push cx
push bx
mov cx+ &ffffh
d<( mov bx+ %fffh
d9( dec bx
jnP d,
loop d-
pop bx
pop cx
ret
dela+ endp
end start
Conlus!on(
This program displays a message of ,- characters in rolling fashion on
seven segment display. The message is stored in data segment. "t will continue of rolling
the message until 2=! is pressed in keyboard. 3ut it will check for a key press event only
after displaying the complete string. Till then it will just keep on displaying the
characters.
Dept. of CSE REC,Hulkoti.
8086 Lab Manual 35
@. a. 7ead t%o str!ngs. store t0em !n loat!ons S179 and S17<. C0e, %0et0er t0e+
are e6ual or not and d!spla+ appropr!ated messages. Also d!spla+ t0e lengt0 o" t0e
stored str!ngs.
.model small
.data
str, db .& dup7&8
str- db .& dup7&8
len, dw , dup7&8
len- dw , dup7&8
msg, db ,.+,&+ OEnter the ,st string # NO
msg- db ,.+,&+ OEnter the -nd string # NO
msg. db ,.+,&+ O*tring are not e=ual NO
msg/ db ,.+,&+ O*trings are e=ual NO
msg1 db ,.+,&+ OThe length of the first string is # O
slen, db @+ @
msg' db ,.+,&+OThe length of the second string is # O
slen- db @+ @+,.+,&+RNR
.ode
read maro
mov ah+ &,
int -,h
endm
d!sp maro x
mov dx+ offset x
mov ah+ &D
int -,h
endm
start( mov ax+Edata
mov ds+ax
mov es+ax
F 4EA$ F"4*T *T4"AB
disp msg,
mov si+&h
up9( read
cmp al+&dh
je down,
mov str,JsiK+al
inc si
jmp up,
do%n9( mov len,+si

F 4EA$ *E5CA$ *T4"AB
Dept. of CSE REC,Hulkoti.
8086 Lab Manual 36
disp msg-
mov si+&h
up<( read
cmp al+&dh
je down-
mov str-JsiK+al
inc si
jmp up-
do%n<( mov len-+si
F 5>E5L 6>ET>E4 *T4"AB* A4E EU9A( C4 ACT.
mov cx+len,
cmp cx+len-
jne note=
mov si+offset str,
mov di+offset str-
cld
repe cmpsb
jne note=
disp msg/
jmp next
note6( disp msg.
ne3t( mov al+byte ptr len,
aam
add ax+ .&.&h
mov slen,+ ah
mov slen,I,+ al

mov al+byte ptr len-
aam
add ax+ .&.&h
mov slen-+ ah
mov slen-I,+ al
disp msg1
int .
end start
Conlus!on(
This program reads two strings from user and compares both the strings. First it
checks the length of the strings and if lengths are e=ual then it will checks each and every
character. "f all the characters are same then the given strings are said to be e=ual and it
will display a message Sstrings are e=ualT along with length of both the strings on screen.
Dept. of CSE REC,Hulkoti.
8086 Lab Manual 3
@. b. Convert a 9@Ab!t b!nar+ valueFassumed to be an uns!gned !nteger8 to BC# and
d!spla+ !t "orm le"t to r!g0t and r!g0t to le"t "or spe!"!ed number o" t!mes on a KA
Segment d!spla+ Inter"ae.
.model small
.data
pa e=u &d%&&h
pb e=u &d%&,h
pc e=u &d%&-h
ctrl e=u &d%&.h
bin dw &&&Dh
bcd db / dup7&8
count db &-
disptbl db &c&h+ &fDh+ &a/h+ &b&h+ DDh+ D-h+ %-h+ &f%h+ %&h+ D%h
.ode
start( mov ax+ Edata
mov ds+ ax
mov al+ %&h
mov dx+ ctrl
out dx+ al
mov bx+ ,&
mov cx+ &/
mov ax+ bin
ba,( mov dx+ &
div bx
push dx
loop back
lea si+ bcd
mov cx+ &/

ba,9( pop dx
mov JsiK+ dl
inc si
loop back,

mov bx+ offset disptbl
d!sp( call display,
call delay
call display
call delay
dec count
jnP disp
int .
d!spla+ pro
Dept. of CSE REC,Hulkoti.
8086 Lab Manual 38
mov si+ &&
n3t0ar(mov al+ bcdJsiK
xlat
mov ah+ %
n3tseg( mov dx+ pb
rol al+ &,
out dx+ al
mov ch+ al
call clock
mov al+ch
dec ah
jnP nxtseg
inc si
cmp si+/
jne nxtchar
ret
d!spla+ endp
d!spla+9 pro
mov si+ &.
n3t0ar9( mov al+ bcdJsiK
xlat
mov ah+ %
n3tseg9( mov dx+ pb
rol al+ &,
out dx+ al
mov ch+ al
call clock
mov al+ch
dec ah
jnP nxtseg,
dec si
cmp si+0,
jne nxtchar,
ret
d!spla+9 endp
lo, pro
mov dx+ pc
mov al+ &,h
out dx+ al
mov al+ &
Dept. of CSE REC,Hulkoti.
8086 Lab Manual 3!
out dx+ al
mov dx+ pb
ret
lo, endp
dela+ pro
push cx
push bx
mov cx+ &ffffh
d<( mov bx+ %fffh
d9( dec bx
jnP d,
loop d-
pop bx
pop cx
ret
dela+ endp
end start
Conlus!on(
This program converts a ,'0bit number provided in data segment into
35$. Then it will displays the 35$ number on seven segment display interface form left
to right and right to left for specified number of times.
Dept. of CSE REC,Hulkoti.
8086 Lab Manual 40
K. a. 7ead +our name "rom t0e ,e+board and d!spla+s !t at a spe!"!ed loat!on on
t0e sreen !n "ront o" t0e message L:0at !s +our nameMN +ou must lear t0e ent!re
sreen be"ore d!spla+.
.model small
.data
msg, db OEnter the name NO
x db ,&
y db -&
msg- db O6hat is your name @ O
str db .& dup7&8
.ode
d!sp maro P
mov dx+ offset P
mov ah+ &D
int -,h
endm
start( mov ax+Edata
mov ds+ax
FFC4 4EA$"AB T>E *T4"AB
disp msg,
mov si+&h
up( mov ah+ &,
int -,h
cmp al+&dh
je down
mov strJsiK+al
inc si
jmp up
do%n( mov strJsiK+RNR
F FC4 5(EA4"AB T>E *54EEA
mov cx+ -Dh<1&h
mov dl+ R R
mov ah+ &-
ba,( int -,h
loop back
mov dl+ x
mov dh+ y
mov bh+ &&h
mov ah+ &-
int ,&h
disp msg-
mov ah+&,
int -,h
int .
end start
Dept. of CSE REC,Hulkoti.
8086 Lab Manual 41
Conlus!on(
This program will reads a string and displays the same string on the screen at the
desired position after clearing the screen.
Dept. of CSE REC,Hulkoti.
8086 Lab Manual 42
K. b. #r!ve a Stepper Motor Inter"ae to rotate t0e motor !n lo,%!se d!ret!on b+ '
steps F' !s spe!"!ed b+ t0e e3am!ner8. Introdue su!table dela+ bet%een suess!ve
steps.
.model small
.data
pa e=u &d%&&h
pb e=u &d%&,h
pc e=u &d%&-h
ctrl e=u &d%&.h
nstep db -
.ode
start( mov ax+ Edata
mov ds+ ax
mov al+ %&h
mov dx+ ctrl
out dx+ al
mov bh+ nstep
mov al+ %%h
aga!n9( call step
ror al+ ,
dec bh
jnP again,
int .
step pro
mov dx+ pa
out dx+ al
mov cx+ &ffffh
d<( mov di+ %fffh
d9( dec di
jnP d,
loop d-
ret
step endp
end start
Conlus!on(
This program drives a stepper motor interface to rotate by % steps in clockwise
direction. After each rotation a delay is introduced to observe the rotation. After
completing the rotations the execution will get stopped.
Dept. of CSE REC,Hulkoti.
8086 Lab Manual 43
G. a. Compute t0e "ator!al o" a pos!t!ve !nteger OnE us!ng reurs!ve proedure.
.model small
.sta, ,&&h
.data
n, dw .
nfact dw @
.ode
start( mov ax+ Edata
mov ds+ ax
mov ax+ &,
mov dx+ &&
mov cx+ n,
F 5A(( T>E P4C5E$94E FA5TA
call factn
mov nfact+ax
mov nfactI-+ dx
int .
"atn proc
cmp cx+&&
je exit
cmp cx+ &,
je exit
push cx
dec cx
call factn

pop cx
mul cx
e3!t( ret
"atn endp
end start
Conlus!on(
This program computes the factorial of a given number and stores the result in A
and $ registers.
Dept. of CSE REC,Hulkoti.
8086 Lab Manual 44
G. b. #r!ve a Stepper Motor Inter"ae to rotate t0e motor !n ant!Alo,%!se d!ret!on
b+ ' steps F' !s spe!"!ed b+ t0e e3am!ner8. Introdue su!table dela+ bet%een
suess!ve steps.
.model small
.data
pa e=u &d%&&h
pb e=u &d%&,h
pc e=u &d%&-h
ctrl e=u &d%&.h
nstep db -
.ode
start( mov ax+ Edata
mov ds+ ax
mov al+ %&h
mov dx+ ctrl
out dx+ al
mov bh+ nstep
mov al+ %%h
aga!n9( call step
rol al+ ,
dec bh
jnP again,
int .
step pro
mov dx+ pa
out dx+ al
mov cx+ &bfffh
d<( mov di+ %fffh
d9( dec di
jnP d,
loop d-
ret
step endp
end start
Conlus!on(
This program drives a stepper motor interface to rotate by % steps in anti0
clockwise direction. After each rotation a delay is introduced to observe the rotation.
After completing the rotations the execution will get stopped.
Dept. of CSE REC,Hulkoti.
8086 Lab Manual 45
P. a. Compute nCr us!ng reurs!ve proedure. Assume t0at OnE and OrE are nonA
negat!ve !ntegers.
.model small
.sta, -&
.data
n db &%h
r db &1h
ncr db @
.ode
start( mov ax+Edata
mov ds+ax
mov ncr+&&h
mov al+n
mov bl+r
call encer
int .
ener pro
para9( cmp al+bl
je para%
para<( cmp bl+&&h
je para%
para=( cmp bl+&,h
je para,&
para>( dec al
cmp bl+al
je paraD
paraB( push ax
push bx
call encer
para@( pop bx
pop ax
dec bl
push ax
push bx
call encer
paraK( pop bx
pop ax
ret
paraG( inc ncr
ret
paraP( inc ncr
para9C( add ncr+al
ret
ener endp
end start
Dept. of CSE REC,Hulkoti.
8086 Lab Manual 46
Conlus!on(
This program performs n5r using recursive procedure. Cutput is stored in data
segment. To observe the output in data segment we have to search for our given OnE and
OrE values as program is written to store the result after the given data in data segment.
Dept. of CSE REC,Hulkoti.
8086 Lab Manual 4
P. b. #r!ve a Stepper Motor Inter"ae to rotate t0e motor b+ ' steps le"t d!ret!on
and ' steps r!g0t d!ret!on F' !s spe!"!ed b+ t0e e3am!ner8. Introdue su!table dela+
bet%een suess!ve steps.
.model small
.data
pa e=u &d%&&h
pb e=u &d%&,h
pc e=u &d%&-h
ctrl e=u &d%&.h
nstep db -
.ode
start( mov ax+ Edata
mov ds+ ax
mov al+ %&h
mov dx+ ctrl
out dx+ al
mov bh+ nstep
mov al+ %%h
aga!n9( call step
ror al+ ,
dec bh
jnP again,
mov bh+ nstep
mov al+ %%h
aga!n<( call step
rol al+ ,
dec bh
jnP again-
int .
step pro
mov dx+ pa
out dx+ al
mov cx+ %fffh
d<( mov di+ %fffh
d9( dec di
jnP d,
loop d-
Dept. of CSE REC,Hulkoti.
8086 Lab Manual 48
ret
step endp
end start
Conlus!on(
This program drives a stepper motor interface to rotate by % steps left direction
and % steps right direction. After each rotation a delay is introduced to observe the
rotation. After completing the rotations the execution will get stopped.
Dept. of CSE REC,Hulkoti.
8086 Lab Manual 4!
9C. a. D!nd out %0et0er a g!ven subAstr!ng !s present or not !n a ma!n str!ng o"
0araters.
.model small
.data
str, db RLA4AATALAR
len, e=u 7N0str,8
str- db RALAR
len- e=u 7N0str-8
msgf db R*ubstring found in main string at position# R
posn db @+RNR
msgnf db R*ubstring not foundNR
ascii db R&,-./1'?%DA35$EFR+!N!
.ode
start( mov ax+Edata
mov ds+ax
mov es+ax
mov bx+len,
sub bx+len-
inc bx
lea si+str,
lea di+str-
aga!n( push si
push di
mov cx+len-
repe cmpsb
pop di
pop si
je fnd
inc si
dec bx
jnP again
lea dx+msgnf
jmp display
"nd( lea dx+msgf
sub si+offset str,
sub si+ len-0,
lea bx+ascii
mov ax+si
xlat
mov posn+al
d!spla+( mov ah+&Dh
int -,h
int .
Dept. of CSE REC,Hulkoti.
8086 Lab Manual 50
end start
Conlus!on(
This program checks a sub0string is present or not in main string. 3oth sub0string
and main string are provided in data segment of program. "f substring is found in main
string it will display a message Ssubstring foundT. "f not it will display a message as
Ssubstring not foundT.
Dept. of CSE REC,Hulkoti.
8086 Lab Manual 51
9C. b. San a G3= ,e+pad "or ,e+ losure and to store t0e ode o" t0e ,e+ pressed !n a
memor+ loat!on and d!spla+ on sreen. Also d!spla+ ro% and olumn numbers o"
t0e ,e+ pressed.
.model small
.sta, ,&&
.data
pa e=u &d%&&h
pb e=u &d%&,h
pc e=u &d%&-h
ctrl e=u &d%&.h
A*5""5C$E db O&,-./1'?%D.I0<VWackX)4mnO
str db ,.+,&+Opress any key on the matrix keyboardNO
str, db ,.+,&+OPress y to repeat and any key to exit NO
msg db ,.+ ,&+Othe code of the key pressed is #O
key db @
msg, db ,.+,&+Othe row is O
row db @
msg- db ,.+,&+Othe column is O
col db @+,.+,&+!N!
.ode
d!sp maro x
mov dx+ offset x
mov ah+ &D
int -,h
endm
start( mov ax+Edata
mov ds+ax
mov al+D&h
mov dx+ctrl
out dx+al
aga!n9( disp str
mov si+&h
aga!n( call scan
mov al+bh F 4ow number
add al+.,h
mov row+al
mov al+ah F 5olumn number
add al+.,h
mov col+al
cmp si+&&
je again
Dept. of CSE REC,Hulkoti.
8086 Lab Manual 52
mov cl+&.
rol bh+cl
mov cl+bh
mov al+ah
lea bx+A*5""5C$E
add bl+cl
xlat
mov key+al
disp msg
disp str,
mov ah+ &,
int -,h
cmp al+RyR
je again,
int .
san pro
mov cx+&.
mov bh+&
mov al+%&h
n3tro%( rol al+,
mov bl+al
mov dx+pc
out dx+al
mov dx+pa
in al+dx
cmp al+&
jne keyid
mov al+bl
inc bh
loop nxtrow
ret
,e+!d( mov si+,
mov cx+%
mov ah+&
agn( ror al+,
jc skip
inc ah
loop agn
s,!p( ret
san endp
end start
Dept. of CSE REC,Hulkoti.
8086 Lab Manual 53
Conlus!on(
This program reads the data from the %<. key interface board. "t will display its
value on the screen. "t will also display the row number and column number of the key
pressed.
Dept. of CSE REC,Hulkoti.
8086 Lab Manual 54
99. a. Generate t0e "!rst OnE D!bona! numbers.
.model small
.sta, -&
.data
fib db ,1 dup7@8
n dw &Dh
.ode
start( mov ax+Edata
mov ds+ax
mov cx+n
lea si+fib
mov byte ptr JsiK+&&h
inc si
dec cx
mov byte ptr JsiK+&,
dec cx

a9( mov al+Jsi0,K
add al+JsiK
inc si
mov JsiK+al
loop a,
int .
end start
Conlus!on(
This program generates a Fibonacci series for the given number. Cutput will be
observed in data segment. Fibonacci series of first D numbers is &&+ &,+ &,+ &-+ &.+ &1+ &%+
&$+ ,1.
Dept. of CSE REC,Hulkoti.
8086 Lab Manual 55
99. b. San an G3= ,e+pad "or ,e+ losure and s!mulate A## and S5B17AC1
operat!ons as !n a alulator.
.model small
.data
pa e=u &d%&&h
pb e=u &d%&,h
pc e=u &d%&-h
ctrl e=u &d%&.h
asciicode db O&,-./1'?%D.I0<VWA5LX)4mnO
msg, db ,.+,&+Oenter the ,st operand NO
msg- db ,.+,&+Oenter the operator NO
msg. db ,.+,&+Oenter the -nd operand NO
msg/ db ,.+,&+Othe invalid operator NO
msg1 db ,.+,&+Othe result of O
op, db @+@
op- db @+O is O
res db @+@+@+RNR
.ode
d!sp maro x
mov dx+ offset x
mov ah+ &D
int -,h
endm
start( mov ax+Edata
mov ds+ax
mov dx+ctrl
mov al+ D&h
out dx+al
up( disp msg,
lea di+op,
call kb
disp msg-
lea di+op,I,
call kb
disp msg.
lea di+op-
call kb
mov al+op,I,
cmp al+RIR
je add,
Dept. of CSE REC,Hulkoti.
8086 Lab Manual 56
cmp al+R0R
je sub,
disp msg/
jmp up
add9( mov al+op,
add al+op-
sub al+'&h
mov res+RIR
aam
add ax+ .&.&h
mov resI,+ ah
mov resI-+ al
jmp exit
sub9( mov al+op,
mov bl+op-
cmp al+bl
jnc next
mov res+R0R
xchg al+bl
jmp next,
ne3t( mov res+RIR
ne3t9( sub al+bl
aam
add ax+ .&.&h
mov resI,+ ah
mov resI-+ al
e3!t( disp msg1
int .
,b pro
mov si+&&h
aga!n9( call delay
call scan
cmp si+&&h
je again,
mov cl+&.
rol bh+cl
mov cl+bh
mov al+ah
lea bx+asciicode
add bl+cl
xlat
mov JdiK+al
Dept. of CSE REC,Hulkoti.
8086 Lab Manual 5
ret
,b endp
san pro
mov cx+&.
mov bh+&
mov al+%&h
nro%( rol al+,
mov bl+al
mov dx+pc
out dx+al
mov dx+pa
in al+dx
cmp al+&&h
jne keyid
mov al+bl
inc bh
loop nrow
ret
,e+!d ( mov si+,
mov ah+&
mov cx+%
agn( rcr al+,
jc skip
inc ah
loop agn
s,!p( ret
san endp
dela+ pro
mov bx+&bfffh
net9( mov cx+&fff&h
net( loop net
dec bx
jnP net,
ret
dela+ endp
end start
Conlus!on(
This program reads the data from the %<. key interface board. "t will display its
value on the screen. "t is used as a calculator to do the addition and subtraction
operations.
Dept. of CSE REC,Hulkoti.
8086 Lab Manual 58
9<. a. 7ead t0e urrent t!me "rom t0e s+stem and d!spla+ !t !n t0e standard "ormat
on t0e sreen.
.model small
.data
msg db OThe time is# O
hrs db @+@+R # R
mins db @+@+R 7hh#mm8 R+,&+,.+RNR
.ode
start( mov ax+Edata
mov ds+ax
F $C* F9A5T"CA 4EA$* T>E *;*TE) T")E.
mov ah+-ch
int -,h
mov al+ch
aam
add ax+ .&.&h
mov hrs+ ah
mov hrsI,+ al
mov al+cl
aam
add ax+ .&.&h
mov mins+ ah
mov minsI,+al
lea dx+msg
mov ah+&Dh
int -,h
int .
end start
Conlus!on(
This program displays the present system time. Cur program displays only the
hours and minutes in the format >>#)). 3ut by using the same DOS function we can
also display the seconds and milliseconds.
Dept. of CSE REC,Hulkoti.
8086 Lab Manual 5!
9<. b. Generate a S!ne :ave us!ng t0e #AC !nter"ae.
.model small
.data
pa e=u &c/&&h
pb e=u &c/&,h
pc e=u &c/&-h
ctrl e=u &c/&.h
table db ,-%+,.-+,.?+,/,+,/'+,1&+,1/+,1D+,'.+,'?+,?,+,?'+,%&+,%/+,%%
db ,D-+,D'+,DD+-&.+-&'+-,&+-,.+-,?+--&+--.+--'+--D+-.,+-./+-.'
db -.D+-/,+-/.+-/1+-/?+-/%+-1&+-1,+-1-+-1.+-1/+-11
db -11+-1/+-1.+-1-+-1,+-1&+-/%+-/?+-/1+-/.+-/,+-.D+-.'+-./+-.,
db --D+--'+--.+--&+-,?+-,.+-,&+-&'+-&.+,DD+,D'+,D-+,%%+,%/+,%&
db ,?'+,?,+,'?+,'.+,1D+,1/+,1&+,/'+,/,+,.?+,.-+,-%
db ,-.+,,D+,,/+,,&+,&1+,&,+D?+D.+%%+%/+%&+?'+?-+'%+'/+'&+1'+1-+/D
db /1+/-+.D+.'+..+.&+-?+-/+--+,D+,?+,1+,,+D+?+'+1+/+.+-+,+&
db &+,+-+.+/+1+'+?+D+,,+,1+,?+,D+--+-/+-?+.&+..+.'+.D+/-+/1+/D+1-+1'
db '&+'/+'%+?-+?'+%&+%/+%%+D.+D?+,&,+,&1+,,&+,,/+,,D+,-.
.ode
start( mov ax+Edata
mov ds+ax
mov al+%&h
mov dx+ctrl
out dx+al
aga!n( mov bx+&1h
up( mov cx+,'/
mov si+&&h
mov dx+pa
aga!n9( mov al+tableJsiK
out dx+al
inc si
loop again,
dec bx
cmp bx+&&
jne up
mov ah+&'h
mov dl+&ffh
int -,h
jP again
int .
end start
Dept. of CSE REC,Hulkoti.
8086 Lab Manual 60
Conlus!on(
This program generates a sine wave of having amplitude of 1H. Cutput will be
seen in 54C. "t will be continues wave. "t stops execution as soon as any key is pressed
from the key board.
Dept. of CSE REC,Hulkoti.
8086 Lab Manual 61
9=. a. Program to s!mulate a #e!mal 5pACounter to d!spla+ CC Q PP.
.model small
.data
string db Othe count is O
nors db @+@+RNR
.ode
start( mov ax+Edata
mov ds+ax
mov ah+&.h
mov bh+&&h
int ,&h
up( mov cl+&&h
up9( mov al+cl
aam
add ax+ .&.&h
mov nors+ ah
mov norsI,+ al
push dx
mov ah+&-h
mov bh+&&h
int ,&h
mov dx+offset string
mov ah+&Dh
int -,h
inc cl
call delay
mov ah+&'h
mov dl+&ffh
int -,h
cmp al+R=R
je exit
pop dx
cmp cl+,&&
je up
jmp up,
e3!t( int .
dela+ pro
mov ax+&ffffh
d9( mov dx+&fffh
d<( dec dx
cmp dx+&&h
jne d-
dec ax
jne d,
ret
dela+ endp
Dept. of CSE REC,Hulkoti.
8086 Lab Manual 62
end start
Conlus!on(
5ount from && to DD will given by this program. 5ount will continue until a key
is pressed in key board.
Dept. of CSE REC,Hulkoti.
8086 Lab Manual 63
9=. b. Generate a ;al" 7et!"!ed S!ne :ave "orm us!ng t0e #AC !nter"ae.
.model small
.data
pa e=u &c/&&h
pb e=u &c/&,h
pc e=u &c/&-h
ctrl e=u &c/&.h
table db ,-%+,.-+,.?+,/,+,/'+,1&+,1/+,1D+,'.+,'?+,?,+,?'+,%&+,%/+,%%
db ,D-+,D'+,DD+-&.+-&'+-,&+-,.+-,?+--&+--.+--'+--D+-.,+-./+-.'
db -.D+-/,+-/.+-/1+-/?+-/%+-1&+-1,+-1-+-1.+-1/+-11+-1/+-1.+-1-
db -1,+-1&+-/%+-/?+-/1+-/.+-/,+-.D+-.'+-./+-.,+--D+--'+--.+--&
db -,?+-,.+-,&+-&'+-&.+,DD+,D'+,D-+,%%+,%/+,%&+,?'+,?,+,'?+,'.
db ,1D+,1/+,1&+,/'+,/,+,.?+,.-+,-%
.ode
start( mov ax+Edata
mov ds+ax
mov al+%&h
mov dx+ctrl
out dx+al
aga!n=( mov bx+&1h
up( mov cx+%.
mov si+&&
aga!n>( mov dx+pa
mov al+tableJsiK
out dx+al
inc si
loop again/
mov cx+%.
mov al+,-%
ne3t( out dx+al
loop next
dec bx
cmp bx+&&h
jnP up
mov ah+&'h
mov dl+&ffh
int -,h
jP again.
int .
end start
Dept. of CSE REC,Hulkoti.
8086 Lab Manual 64
Conlus!on( This program generates a half 0 rectified sine wave of 1H amplitude. Cutput
will be seen in 54C. "t stops execution as soon as any key is pressed from the key board.
Dept. of CSE REC,Hulkoti.
8086 Lab Manual 65
9>. a. 7ead a pa!r o" !nput oAord!nates !n BC# and moves t0e ursor to t0e
spe!"!ed loat!on on t0e sreen.
.model small
.data
x db @
y db @
msg, db ,.+ ,&+ OEnter the y co ordinate 7&& 0 ,D8NO
msg- db ,.+ ,&+ OEnter the x co ordinate 7&& 0 1&8NO
.ode
read maro
mov ah+ &,h
int -,h
endm
start( mov ax+Edata
mov ds+ax

mov dx+offset msg,
mov ah+&Dh
int -,h
read
mov cl+ &/h
shl al+ cl
mov bl+al

read
and al+&fh
or al+bl
mov y+al
mov dx+offset msg-
mov ah+&Dh
int -,h
read
mov cl+&/h
shl al+cl
mov bl+al

read
and al+&fh
or al+bl
mov x+al

Dept. of CSE REC,Hulkoti.
8086 Lab Manual 66
F5(EA4 *54EEA
mov ah+&-h
mov cx+ ,Dh<1&h
mov dl+ R R
ba,( int -,h
loop back
mov ah+&-h
mov bh+&&h
mov dh+y
mov dl+x
int ,&h
read
int .
end start
Conlus!on(
This program reads and ; coordinates from key board and takes the cursor to
the specified location after clearing the screen and it will remains at the same position
until a key pressed.
Dept. of CSE REC,Hulkoti.
8086 Lab Manual 6
9>. b. Generate a Dull+ 7et!"!ed S!ne :ave "orm us!ng t0e #AC !nter"ae.
.model small
.data
pa e=u &c/&&h
pb e=u &c/&,h
pc e=u &c/&-h
ctrl e=u &c/&.h
table db ,-%+,.-+,.?+,/,+,/'+,1&+,1/+,1D+,'.+,'?+,?,+,?'+,%&+,%/+,%%
db ,D-+,D'+,DD+-&.+-&'+-,&+-,.+-,?+--&+--.+-,?+--&+--.+--'+--D
db -.,+-./+-.'+-.D+-/,+-/.+-/1+-/?+-/%+-1&+-1,+-1-+-1.+-1/+-11
db -1/+-1.+-1-+-1,+-1&+-/%+-/?+-/1+-/.+-/,+-.D+-.'+-./+-.,+--D
db --'+--.+--&+-,?+-,.+-,&+-&'+-&.+,DD+,D'+,D-+,%%+,%/+,%&+,?'
db ,?,+,'?+,'.+,1D+,1/+,%&+,/'+,/,+,.?+,.-+,-%
count dw %.
.ode
start( mov ax+Edata
mov ds+ax
mov al+%&h
mov dx+ctrl
out dx+al
agn ( mov bx+&1
ba,9( mov cx+count
mov si+&&h
ba,( mov al+tableJsiK
mov dx+pa
out dx+al
inc si
loop back
dec bx
cmp bx+&&
jnP back,
mov ah+&'h
mov dl+&ffh
int -,h
jP agn
int .
end start
Conlus!on(
This program generates a fully rectified sine wave of 1H amplitude. Cutput will
be seen in 54C. "t stops execution as soon as key is pressed from the key board.
Dept. of CSE REC,Hulkoti.
8086 Lab Manual 68
9B. a. Program to reate a "!le F!nput "!le8 and to delete an e3!st!ng "!le.
.model small
.data
string db OEnter the file name for the file to be createdO+,.+,&+RNR
msg, db ,.+,&+OThe file cannot be createdO+,.+,&+RNR
msg- db ,.+,&+OFile created successfullyO+,.+,&+RNR
str, db /& dup7&8
string, db OEnter the file name to be deletedO+,.+,&+RNR
msg. db ,.+,&+OThe file cannot be deletedO+,.+,&+RNR
msg/ db ,.+,&+OFile deleted successfullyO+,.+,&+RNR
str- db /& dup7&8
.ode
d!sp maro x
lea dx+ x
mov ah+ &Dh
int -,h
endm
start( mov ax+Edata
mov ds+ax
disp string
mov bx+&&h
up( mov ah+&,h
int -,h
cmp al+&dh
je exit
mov str,JbxK+al
inc bx
jmp up
e3!t( mov str,JbxK+RNR
mov ah+.ch
mov cx+&&-&h
mov dx+offset str,
int -,h
jc down
disp msg-
jmp down,
do%n( disp msg,
do%n9( disp string,
mov bx+&&h
up9( mov ah+&,h
Dept. of CSE REC,Hulkoti.
8086 Lab Manual 6!
int -,h
cmp al+&dh
je exit,
mov str-JbxK+al
inc bx
jmp up,
e3!t9( mov str-JbxK+RNR
mov ah+/,h
mov dx+offset str-
int -,h
jc down-
disp msg/
jmp down.
do%n<( disp msg.
do%n=( int .
end start
Conlus!on(
This program creates a file in current root directory. "f creation of file success it
will display a message Sfile created successfullyT. After that it will delete the file from
the current directory. "f deletion of file is success then it will display a message Sfile
deleted successfullyT.
Dept. of CSE REC,Hulkoti.
8086 Lab Manual 0
9B. b. #r!ve an Elevator Inter"ae !n t0e "ollo%!ng %a+ to move an elevator "rom
ground to top "loor and top to ground.
.model small
.data
pa e=u &d%&&h
pb e=u &d%&,h
pc e=u &d%&-h
ctrl e=u &d%&.h
tf db &
cf db &
.ode
mov ax+ Edata
mov ds+ ax
mov al+ %-h
mov dx+ ctrl
out dx+ al
F"nitially display lift in ground floor
mov cf+ &h
mov al+ cf
or al+ &f&h
mov dx+ pa
out dx+ al
F5heck for the re=uested floor
start( call chk
cmp al+R=R
jP exit
cmp al+ &feh
je gfr
cmp al+ &fdh
je ffr
cmp al+ &fbh
je sfr
cmp al+ &f?h
je tfr
jmp start
e3!t( int .
FBround floor
g"r( mov tf+&
call floor
ne3t( mov al+ &e&h
mov dx+ pa
out dx+ al
jmp start
Dept. of CSE REC,Hulkoti.
8086 Lab Manual 1
FFirst floor
""r( mov tf+ ,
call floor
ne3t9( mov al+ &d.h
mov dx+ pa
out dx+ al
jmp start
F*econd floor
s"r( mov tf+-
call floor
ne3t<( mov al+ &b'h
mov dx+ pa
out dx+ al
jmp start
FThird floor
t"r( mov tf+.
call floor
ne3t=( mov al+ ?Dh
mov dx+ pa
out dx+ al
jmp start
Fprocedure to check the target floor
0, pro
mov ah+ &'h Fcheck for R=R to exit
mov dl+ &ffh
int -,h
cmp al+ R=R
jnP next/
ret
ne3t>( mov dx+ pb Fcheck the status of target floor
in al+dx
or al+ &f&h
cmp al+&ffh
jP chk
mov tf+ al
ret
0, endp
Fprocedure to move lift up and down
"loor pro
mov al+ .
mul tf
mov cl+al Ftarget floor lift position
Dept. of CSE REC,Hulkoti.
8086 Lab Manual 2
mov al+ &.
mul cf
mov ch+ al Fcurrent floor lift position
cmp cl+ch
je ext,
ja up
ba,( call updown
dec ch Fto move lift down
cmp cl+ch
jle back
jmp ext
up( call updown
inc ch Fto move lift up
cmp cl+ch
jge up
e3t( mov cl+ tf
mov cf+ cl
e3t9( ret
"loor endp
updo%n pro
mov al+ch
or al+ &f&h
mov dx+ pa
out dx+ al
call delay
ret
updo%n endp
dela+ pro
push bx
push cx
mov cx+&fffh
b<( mov bx+ &ffffh
b9( dec bx
jnP b,
loop b-
pop cx
pop bx
ret
dela+ endp
end
Conlus!on(
This program does the operation of lift.
Dept. of CSE REC,Hulkoti.
8086 Lab Manual 3
Instrut!on Set(
"nstructions Cperands $escription
M&V
7EG2 memor+
memor+2 7EG
7EG2 7EG
memor+2 !mmed!ate
7EG2 !mmed!ate
S7EG2 memor+
memor+2 S7EG
7EG2 S7EG
S7EG2 7EG
Cop+ operand< to operand9.
The )CH instruction cannot#
*et the value of the 5* and "P registers.
5opy value of one segment register to another segment
register 7should copy to general register first8.
5opy immediate value to segment register 7should copy to
general register first8.
Algor!t0m( operand9 R operand<
Ex#
Mov AH2BH .Cop+ ontents o" BH to AH
Mov s!2CC0 .load S! %!t0 CC0
M5L 7EG
Memor+
5ns!gned mult!pl+.
)ultiply the contents of 4EBV)emory with contents of A( register.
Algor!t0m(
6hen operand is a b+te#
A X A( < operand.
6hen operand is a %ord#
7$# A8 X A < operand.
CMP
7EG2 memor+
memor+2 7EG
7EG2 7EG
memor+2 !mmed!ate
7EG2 !mmed!ate
Compare.
Algor!t0m( operand1 - operand2
4esult is not stored anywhere+ flags are set 7CF+ *F+ GF+ AF+ PF+ 5F8
according to result.
JMP Label
5nond!t!onal Jump.
Transfers control to another part of the program. 4+b,te a--.e// may
be entered in this form# ,-./h# 1'?%h+ first value is a segment
second value is an offset.
Algor!t0m( always jump
JA Label
Jump I" Above.
*hort Mump if first operand is Above second operand 7as set by 5)P
instruction8. 9nsigned.
Algor!t0m( if 75F X &8 and 7GF X &8 then jump
JAE Label
Jump I" Above &r E6ual
*hort Mump if first operand is Above or E=ual to second operand 7as
set by 5)P instruction8. 9nsigned.
Algor!t0m(
Dept. of CSE REC,Hulkoti.
8086 Lab Manual 4
if 5F X & then jump
JB Label
Jump I" Belo%.
*hort Mump if first operand is 3elow second operand 7as set by 5)P
instruction8. 9nsigned.
Algor!t0m(
if 5F X , then jump
JBE Label
Jump I" Belo% &r E6ual
*hort Mump if first operand is 3elow second operand 7as set by 5)P
instruction8. 9nsigned.
Algor!t0m#
if 5F X , then jump
JC Label
Jump I" Carr+
*hort Mump if 5arry flag is set to ,.
Algor!t0m(
if 5F X , then jump
JE Label
Jump I" E6ual.
*hort Mump if first operand is E=ual to second operand 7as set by
5)P instruction8. *ignedV9nsigned.
Algor!t0m(
if GF X , then jump
JG Label
Jump I" Greater
*hort Mump if first operand is Breater then second operand 7as set by
5)P instruction8. *igned.
Algor!t0m(
if 7GF X &8 and 7*F X CF8 then jump
JGE Label
Jump I" Greater &r E6ual.
*hort Mump if first operand is Breater or E=ual to second operand 7as
set by 5)P instruction8. *igned.
Algor!t0m(
if *F X CF then jump
Dept. of CSE REC,Hulkoti.
8086 Lab Manual 5
JL Label
Jump I" Less t0an.
*hort Mump if first operand is (ess then second operand 7as set by
5)P instruction8. *igned.
Algor!t0m(
if *F YZ CF then jump
JLE Label
Jump I" Less &r E6ual.
*hort Mump if first operand is (ess or E=ual to second operand 7as
set by 5)P instruction8. *igned.
Algor!t0m(
if *F YZ CF or GF X , then jump
J'S Label
Jump I" 'on Sero.
*hort Mump if Aot Gero 7not e=ual8. *et by 5)P+ *93+ A$$+ TE*T+
AA$+ C4+ C4 instructions.
Algor!t0m(
if GF X & then jump
JS Label
Jump I" Sero.
*hort Mump if Gero 7e=ual8. *et by 5)P+ *93+ A$$+ TE*T+ AA$+
C4+ C4 instructions.
Algor!t0m(
if GF X , then jump
LEA 7EG2 memor+
Load E""et!ve Address.
Algor!t0m(
4EB X address of memory 7offset8
L&&P Label
#erease CH2 jump to label !" CH not /ero.
Algor!t0m(
5 X 5 0 ,
if 5 YZ & then
o jump
else
o no jump+ continue
A##
7EG2 memor+
memor+2 7EG
7EG2 7EG
memor+2 !mmed!ate
7EG2 !mmed!ate
Add.
Algor!t0m(
operand, X operand, I operand-
Dept. of CSE REC,Hulkoti.
8086 Lab Manual 6
A'#
7EG2 memor+
memor+2 7EG
7EG2 7EG
memor+2 !mmed!ate
7EG2 !mmed!ate
(ogical AA$ between all bits of two operands. 4esult is stored in
operand,.
These rules apply#
9 A'# 9 R 9. 9 A'# C R C
C A'# 9 R C. C A'# C R C
&7 7EG2 memor+
memor+2 7EG
7EG2 7EG
memor+2 !mmed!ate
7EG2 !mmed!ate
(ogical C4 between all bits of two operands. 4esult is stored in first
operand.
These rules apply#
9 &7 9 R 9. 9 &7 C R 9
C &7 9 R 9. C &7 C R C
S5B
7EG2 memor+
memor+2 7EG
7EG2 7EG
memor+2 !mmed!ate
7EG2 !mmed!ate
Subtrat.
Algor!t0m(
operand, X operand, 0 operand-
#AA 'o &perands
#e!mal adjust A"ter Add!t!on.
5orrects the result of addition of two packed 35$ values.
Algor!t0m(
if low nibble of A( Z D or AF X , then#
A( X A( I '
AF X ,
if A( Z DFh or 5F X , then#
A( X A( I '&h
5F X ,
#AS 'o &perands
#e!mal adjust A"ter Subtrat!on.
5orrects the result of subtraction of two packed 35$ values.
Algor!t0m(
if low nibble of A( Z D or AF X , then#
A( X A( 0 '
AF X ,
if A( Z DFh or 5F X , then#
A( X A( 0 '&h
5F X ,
Dept. of CSE REC,Hulkoti.
8086 Lab Manual
I'C 7EG
memor+
Inrement.
Algor!t0m( operand X operand I ,
#EC 7EG
Memor+
#erement.
Algor!t0m( operand X operand [ ,
#IV
7EG
Memor+
5ns!gned d!v!de.
Algor!t0m(
when operand is a b+te#
A( X A V operand
A> X remainder 7modulus8
when operand is a %ord#
A X 7$ A8 V operand
$ X remainder 7modulus8
S;L
memor+2 !mmed!ate
7EG2 !mmed!ate
memor+2 CL
7EG2 CL
S0!"t Le"t.
*hift operand, (eft. The number of shifts is set by operand-.
Algor!t0m(
*hift all bits left+ the bit that goes off is set to 5F.
Gero bit is inserted to the right0most position.
S;7
memor+2 !mmed!ate
7EG2 !mmed!ate
memor+2 CL
7EG2 CL
S0!"t 7!g0t.
*hift operand, 4ight. The number of shifts is set by operand-.
Algor!t0m(
*hift all bits right+ the bit that goes off is set to 5F.
Gero bit is inserted to the left0most position.
7&L
memor+2 !mmed!ate
7EG2 !mmed!ate
memor+2 CL
7EG2 CL
7otate Le"t.
4otate operand, left. The number of rotates is set by operand-.
Algor!t0m(
*hift all bits left+ the bit that goes off is set to 5F and the
same bit is inserted to the right0most position.
7&7
memor+2 !mmed!ate
7EG2 !mmed!ate
memor+2 CL
7EG2 CL
7otate 7!g0t.
4otate operand, right. The number of rotates is set by operand-.
Algor!t0m(
*hift all bits right+ the bit that goes off is set to 5F and the
same bit is inserted to the left0most position.
Dept. of CSE REC,Hulkoti.
8086 Lab Manual 8
RCL
memory, immediate
REG, immediate
memory, CL
REG, CL
4otate operand, left through 5arry Flag. The number of rotates is
set by operand-.
Algor!t0m(
*hift all bits left+ the bit that goes off is set to 5F and
previous value of 5F is inserted to the right0most position.
E3ample(
*T5 F set carry 75FX,8.
)CH A(+ ,5h F A( X &&&,,,&&b
45( A(+ , F A( X &&,,,&&,b+ 5FX&.
4ET
5 C
r r
CFX& if first operand keeps original sign.
CALL
proedure name
label
Transfers control to procedure+ return address is 7"P8 pushed to stack.
7E1
'o operands
&r even !mmed!ate
date
4eturn from near procedure.
Algor!t0m(
Pop from stack#
o "P
if immediate operand is present# *P X *P I operand
I'
AL2 !m.b+te
AL2 #H
AH2 !m.b+te
AH2 #H
"nput from port into AL or AH.
*econd operand is a port number. "f re=uired to access port number
over -11 0 #H register should be used.
&51
AL2 !m.b+te
AL2 #H
AH2 #H
Cutput from AL or AH to port.
First operand is a port number. "f re=uired to access port number
over -11 0 #H register should be used.
P&P
7EG
S7EG
memor+
Bet ,' bit value from the stack.
Algorithm# Cperand X ** # J*PK7top of stack8
*P X *p I -.
P5S;
7EG
S7EG
memor+
*tore ,' bit value in the stack.
Algor!t0m(
*P X *P 0 -
**#J*PK 7top of the stack8 X operand
H&7
7EG2 memor+
memor+2 7EG
7EG2 7EG
memor+2 !mmed!ate
(ogical C4 7Exclusive C48 between all bits of two operands.
4esult is stored in first operand.
These rules apply#
Dept. of CSE REC,Hulkoti.
8086 Lab Manual !
7EG2 !mmed!ate 9 H&7 9 R C. 9 H&7 C R 9
C H&7 9 R 9. C H&7 C R C
HC;G
REG, memory
memory, REG
REG, REG
Exchange values of two operands.
Algor!t0m( operand, Y 0 Z operand-
HLA1 'o &perands
Translate byte from table.
5opy value of memory byte at $*#J3 I unsigned A(K to A(
register.
Algor!t0m( A( X $*#J3 I unsigned A(K
AAA 'o &perands
ASCII Adjust a"ter Add!t!on.
5orrects result in A> and A( after addition when working with
35$ values.
Algor!t0m(
if low nibble of A( Z D or AF X , then#
A( X A( I '
A> X A> I ,
AF X ,
5F X ,
else
AF X &
5F X &
in both cases#
clear the high nibble of A(.
Example#
)CH A+ ,1 F A> X &&+ A( X &Fh
AAA F A> X &,+ A( X &1
AAS 'o &perands
ASCII Adjust a"ter Subtrat!on.
5orrects result in A> and A( after subtraction when working with
35$ values.
Algor!t0m(
if low nibble of A( Z D or AF X , then#
A( X A( 0 '
A> X A> 0 ,
AF X ,
5F X ,
else
AF X &
5F X &
Dept. of CSE REC,Hulkoti.
8086 Lab Manual 80
in both cases#
clear the high nibble of A(.
Example#
)CH A+ &-FFh F A> X &-+ A( X &FFh
AA* F A> X &,+ A( X &D
AAM 'o &perands
ASCII Adjust a"ter Mult!pl!at!on.
5orrects the result of multiplication of two 35$ values.
Algor!t0m(
A> X A( V ,&
A( X remainder
Example#
)CH A(+ ,1 F A( X &Fh
AA) F A> X &,+ A( X &1
Interrupt I'1 <90(
"AT -,h calls $C* functions.
Dunt!on C90 - 7ead 0arater "rom standard !nput+ result is stored in A(. "f there is
no character in the keyboard buffer+ the function waits until any key is pressed.
"nvoked by# A; X &,h
4eturns# AL X character entered.
Dept. of CSE REC,Hulkoti.
8086 Lab Manual 81
E3ample(
)ov A>+ &,h
"AT -,h
Dunt!on C<0 A :r!te a 0arater to standard output.
"nvoked by# #L X character to write.
A; X&-h
After execution A( X $(.
E3ample(
)ov A>+ &-h
)ov $(+ !a! F 5haracter to be displayed on screen must be stored in $( reg.
"AT -,h
Dunt!on C@0 [ #!ret onsole "or !nput)output. "f $( X &FF> on entry+ then this
function reads the console. "f $( X A*5"" character+ then this function displays the A*5""
character on the console video screen.
"nvoked by# Parameters for CVP# #L X &\-11
Parameters for "VP# #L X -11.
4eturns# for CVP# AL X #L.
For "VP# SD set if no character available : AL X &
SD clear if character available : AL X character.
E3ample(
)ov A>+ &'h
)ov $(+ &ffh
"AT -,h
Dunt!on CP0 - :r!te a str!ng to standard output at #S( #H.
*tring must be terminated by RTR. The string can be of any length and may contain control
characters such as carriage return 7&$>8 and line feed 7&A>8.
"nvoked by# #S X string to write.
A; X &Dh
E3ample(
)ov A>+ &Dh
)ov $+offset str FAddress of the string to be displayed
"AT -,h
Dunt!on <C0 A Get s+stem t!me.
"nvoked by# A; X-5h
4eturn# C; X hour. CL X minute. #; X second. #L X ,V,&& seconds.
Dept. of CSE REC,Hulkoti.
8086 Lab Manual 82
E3ample(
)ov A>+ -ch
"AT -,h
Dunt!on =C0 - Create or trunate "!le.
"nvoked by# CH X file attributes#
mov cx+ & F normal 0 no attributes.
mov cx+ , F read0only.
mov cx+ - F hidden.
mov cx+ / F system
mov cx+ ? F hidden+ system and read0only]
mov cx+ ,' F archive
mov cx+ &3> F Holume label
mov cx+ ,&> F *ubdirectory
#S( #H 0Z filename. F A; X.5h
4eturns#
CD clear if successful+ AH X file handle.
CD set on error AH X error code.
E3ample(
)ov A>+ .ch
)ov 5+ &,
)ov $+ offset Filename
"AT -,h
Dunt!on >90 0 #elete "!le 7unlink8.
"nvoked by# #S( #H 0Z A*5"G filename 7no wildcards+ but see notes8.
A;X/,h
4eturn#
CD clear if successful+ AH destroyed.
CD set on error AH X error code.
E3ample(
)ov A>+ /,h
)ov $+ offset Filename
"AT -,h
Dunt!on >C0 Q 1erm!nate a proess.
"nvoked by# A; X /ch
4eturn# returns control to the operating system.
Dept. of CSE REC,Hulkoti.
8086 Lab Manual 83
E3ample(
)ov A>+ /5h
"AT -,h
Interrupt I'1 9C0(
"AT ,&h calls the 3"C* functions. This interrupt often called the video services
interrupt as it directly controls the video display in a system.
Dunt!on C<0 0 Set ursor pos!t!on.
"nvoked by" #; X rowF #L X columnF B; X page number 7&...?8F A;X&-h.
E3ample(
)CH A>+ &-h
)CH 3>+ &&
)CH $>+ &'
)CH $(+ ,&
"AT ,&h
Dunt!on C=0 Q Get ursor pos!t!on.
"nvoked by# B; X page number. 7"n general &8
A; X &.h
4eturn# #; X row numberF #L X column numberF C; X cursor start lineF
CL X cursor bottom line.
E3ample(
)ov 3>+ &
)ov A>+ &.h
"AT ,&h
Dunt!on C@0 Q Sroll up %!ndo%
"nvoked by# AL X number of lines by which to scroll. 7&&h X clear the entire screen.8
B; X attribute used to write blank lines at bottom of window.
C;2 CL X row+ column of windowRs upper left corner.
#;2 #L X row+ column of windowRs lower right corner.
C!ru!t d!agrams o" !nter"a!ng dev!es
9. Log! Controller Inter"ae
(ogic controllers find extensive application in industries for the programming of
processes. The nature of control would range from a simple CAVCFF type of control ro
complex systems implementing sophisticated control algorithms while accepting multiple
inputs and actuating multiple outputs. A controller would typically+ accept a number of
Dept. of CSE REC,Hulkoti.
8086 Lab Manual 84
inputs from transducers like sensorsVlimit switches+ key inputs etc.. perform a se=uence of
logical and arithmetic opertaions on them and use the result to maitain the process within
specified safe operating conditions while providing information on the status of the
process at any instant of time.The logic controller interface consits essentially of two %
bit ports+ an input and an output port. The inputs and outputs are connected to the user
systems. The logic state fo each input and output is indicated by (E$s and all signals are
TT( compatible. The input signals are connected to port 3 of %-511A while output lines
are driven from port A.
*ome of the cpabilities of theis interface are#
a. Programmable 5ounter b. *e=uential 5ounter c. 5ombinational 5ontroller.
Dept. of CSE REC,Hulkoti.
8086 Lab Manual 85
<. Seven Segment #!spla+
Dept. of CSE REC,Hulkoti.
8086 Lab Manual 86
The hardware uses four shift register "5s ?/,'/. ?/,'/ is an %0bit serial in0parallel out
shift register with asynchronous reset and two input pins. "t re=uires % clock cycles at
S5(LT pin to shift the serial data from input to % parallel outputs. After % shifts+ the first
serial bit will be in output U>+ and only now the data at output is valid. To cascade more
?/,'/ shift register "5 need to connect the last output U> to the input of second shift
register.
The output is connected to the cathode of the (E$s in the ? segment display and thus
common anode displays are used. The anode is connected to IHcc. The last output of the
first sift register is connected to input of the -nd shift register and the last output o f -
nd
shift register to input of .
rd
and so on. Thus the shift register are serial in parallel out and
they are connected to displays+ in such a way that output &A is connected to display
segment 2a! and &3 to 2b! and so on up to &>F through ..& ohm resistors.
The shifting of data bit takes place for each clock cycle. ?/&/ "5 used provides isolation
and the interface board gets 1H through port bit.
Pin , is used as data pin and pin - is used as other input to Hcc. The clock signal is
generated at a port bit which will be connected to the clock of the shift register.
P3& is used for data bitF and P5& for clock through which a falling edge has to be sent.
The microprocessor stores the display information in a 4A). Each time a display has to
be updated the microprocessor fetches all bytes one by one from 4A) and outputs
corresponding display codes serially that is bit by bit to display. >exadecimal code is
stores in the 4A). The code conversion from hexa to ? segment is done just before the
display is updated.
The ? segment display is used as a numerical indicator on many types of test e=uipment.
"t is an assembly of light emitting diodes which can be powered individually. There are
two important types of ?0segment (E$ display.
"n a ommon at0ode display+ the cathodes of all the (E$s are joined together and the
individual segments are illuminated by >"B> voltages.
"n a ommon anode display+ the anodes of all the (E$s are joined together and the
individual segments are illuminated by connecting to a (C6 voltage.
#!spla+ ode
*ince the outputs of shift registers are connected to cathode sides of displays+ low input
must be given to segments for making them glow and high inputs for making them blank.
Each display has % segments 7a+ b+ c+ d+ e+ f+ g+ h8 as shown. For displaying any character
the corresponding segment must be given low inputs.
Dept. of CSE REC,Hulkoti.
8086 Lab Manual 8
The one shown above is a common anode display since all anodes are joined together and
go to the positive supply. The cathodes are connected individually to Pero volts. 4esistors
must be placed in series with each diode to limit the current through each diode to a safe
value. The d.p represents a decimal point.
The following table shows how to form characters# R&R means that pin is connected to
ground. R,R means that pin is connected to Hcc.
d.p g f e d c b a >ex. value
& , , & & & & & & 5&
, , , , , , & & , FD
- , & , & & , & & A/
. , & , , & & & & 3&
/ , & & , , & & , DD
1 , & & , & & , & D-
' , & & & & & , & %-
Dept. of CSE REC,Hulkoti.
8086 Lab Manual 88
? , , , , , & & & F%
% , & & & & & & & %&
D , & & , , & & & D%
F , & & & , , , & %e
" , , , , , & & , FD
4 , & & & , & & & %%
E , & & & & , , & %'
=. Stepper Motor(
A stepper motor is a widely used device that translates electrical pulses into mechanical
movement. "n applications such as disk drives+ dot matrix printers+ and robotics+ the
stepper motor is used for Position control.
Every stepper motor has a permanent magnet rotor 7also called the shaft.8 surrounded by
a stator. The most common stepper motors have four common stator windings that are
pairs with a center0taped common. This type of stepper motor is commonly referred to as
a four0phase stepper motor.
A *tepper motor is stepped from one position to the next by changing the currents
through the fields in the motor. 5ommon step siPes for stepper motors range from &.D
degrees to .& degrees.
%-511A is used to provide the drive signals that are used to rotate the armature of the
motor in either the right0hand or left0hand direction.
Dept. of CSE REC,Hulkoti.
8086 Lab Manual 8!
The power circuit for one winding of the stepper motor is as shown in figure above. "t is
connected to the port A 7PA&8 of %-511A. *imilar circuits are connected to the remaining
lower bits of port A 7PA,+ PA-+ PA.8. Cne winding is energiPed at a time. The coils are
turned CAVCFF one at a time successively.
Dept. of CSE REC,Hulkoti.
8086 Lab Manual !0
The stepper motor showing full0step operation is shown below.
7A8 /10degrees. 738 ,.10degrees 758 --10degrees 7$8 .,10degrees.
Dept. of CSE REC,Hulkoti.
8086 Lab Manual !1
/. Matr!3 Ke+board #!spla+(
The rows are connected to an output port and the columns are connected to an input port.
"f no key has been pressed+ reading the input port will yields &s for all columns since they
are all connected to ground. "f all the rows are high and a key is pressed+ one of the
columns will have , since the key pressed provides the path to high. "t is the function of
the microprocessor to scan the keyboard continuously to detect and identify the key
pressed.
Dept. of CSE REC,Hulkoti.
8086 Lab Manual !2
Label on
t0e ,e+top
;e3 ode Label on
t0e ,e+
top
;e3 ode
& & 0 &5
, , &$
- - V &E
. . W &F
/ / A5 ,&
1 1 5E ,,
' ' 5>L ,-
? ? X ,.
% % )5 ,/
D D )4 ,1
.
&A ) ,'
I &3 )I ,?
Proess o" !dent!"+!ng t0e ,e+ pressed(
To detect a pressed key+ the micro processor set high all rows by providing , to the output
latch+ then it reads the columns. "f the data read from the columns is PA&0PA? X
&&&&&&&&+ no key has been pressed and process continues until a key press is detected.
"f one of the column bits has a high+ this means that a key press has occurred.
For example+ if PA&0PA? X &&&&,&&&+ this means that a key in the PA/ column has been
pressed.
After a key press is detected+ the micro processor will go through the process of
identifying the key. Aow micro processor sets each row to ground then it reads the
columns. "f the data read is all &s+ no key in that row is activated and the process is
moved to next row. "t grounds the next row+ reads the columns+ and checks for any ,. This
process continues until the row is identified. After identification of the row in which the
key has been pressed+ the next task is to find out which column the pressed key belongs
to.
To identify the key press+ it rotates the column bits+ one bit at a time+ into the carry flag
and checks to see if it is high. 9pon finding the ,+ it pulls out the A*5"" code for that key
from the look0up tableF otherwise+ it increments the pointer to point to the next element of
the look0up table.
Dept. of CSE REC,Hulkoti.
8086 Lab Manual !3
B. #AC I'1E7DACE
The pin details of $A5 &%&& is given below and schematic diagram of the dual $A5
interface is given below.
The port A and port 3 of %-511A peripheral are used as output ports. The digital inputs to
the $A5s are porvided through these ports. The analog outputs of the $A5s are
connected to the inverting inputs of CP0amps ?/, which acts as current to voltage
converters. The outputs from the CP0amps are connected to points marked out and ;
out at which the waveforms are observed on a 54C. The power supplies of I,- and 0,-
are regulated for this interface.
Dept. of CSE REC,Hulkoti.
8086 Lab Manual !4
@. Elevator Inter"ae.
The above figure gives hardware details re=uired for the simulation of the elevator.
This interface has four keys+ marked &+ ,+ -+ and .7"n above fig L,+ L-+ L.+ L/8
representing the re=uest buttons at the four floors. These keys are connected to preset
7P48 of the $ flip0flop. "f this key is closed the output goes low and it goes high and thus
the corresponding re=uest (E$ will be CA.
The outputs of the four Flip0flops 7?/(*?/8 can be read through port 3 7P3C+ P3"+ P3-
and P3.8 so that the floor at which re=uest is re=uired is known and the same will be
serviced. Also+ the status of these signals is reflected by a setoff / (E$!s which are called
as re=uest (E$s whose cathode are connected to outputs of four flip0flopsF while anodes
are connected to I1v as shown in figure. The Flip0Flop can be rest 7(E$!s are cleared8
through higher bits of port A 7PA/+ PA1+ PA'+ and PA?8 so that after servicing the floor at
which re=uest was done the corresponding re=uest (E$ is turned CFF+ sending a low to
the flip0flop through port A.
Dept. of CSE REC,Hulkoti.
8086 Lab Manual !5
A column of ,& (E$!s+ representing the elevator can be controlled through Port A 7PA&+
PA,+ PA- and PA.8. These port lines are fed to the inputs of the 35$ to decimal decoder
"5?//- whose outputs are active0low used to control the onVoff states of the (E$!s which
simulate the motion of the elevator. These (E$* have their cathodes connected to the
outputs of the decoder through the resistors and the anodes are commonly connected to
the I1v supply as shown in the figure. As the output of 35$ decoders are active low and
logic low on output causes the corresponding (E$ goes CA. For Example+ "f &&,& is the
input to the decoder then line - goes low and the third (E$ goes CA.
The motion of elevator can be simulated by turning on successive (E$!s one at a time.
The delay between turning off one (E$ and turning on the next (E$ can simulate the
SspeedT of the elevator.
Dept. of CSE REC,Hulkoti.
8086 Lab Manual !6
V!va $uest!ons and Ans%ers
9. :0at !s a M!roproessorM
A'S( )icroprocessor is a program0controlled device+ which fetches the instructions from
memory+ decodes and executes the instructions. )ost )icro Processor are single0 chip
devices.
<. :0at !s t0e d!""erene bet%een GCG@ and GCGGM
A'S( The 3"9 in %&%% is %0bit data bus : ,'0 bit in %&%'."nstruction =ueue is / byte
long in %&%%and ' byte in %&%'.
=. %0at are t0e "unt!onal un!ts !n GCG@M
AA*# %&%' has two independent functional units because of that the processor speed is
more. The 3us interface unit and Exectuion unit are the two functional units.
>. :0at are t0e "lags !n GCG@M
A'S( "n %&%' 5arry flag+ Parity flag+ Auxiliary carry flag+ Gero flag+ Cverflow flag+
Trace flag+ "nterrupt flag+ $irection flag+ and *ign flag.
B. :0at !s t0e Ma3!mum lo, "re6uen+ !n GCG@M
A'S( 1 )hP is the )aximum clock fre=uency in %&%'.
@. :0at are t0e var!ous segment reg!sters !n GCG@M
A'S( 5ode+ $ata+ *tack+ Extra *egment registers in %&%'.
K. Log! alulat!ons are done !n %0!0 t+pe o" reg!stersM
A'S( Accumulator is the register in which Arithmetic and (ogic calculations are done.
G. ;o% GCG@ !s "aster t0an GCGBM
A'S( 3ecause of pipelining concept. %&%' 3"9 fetches the next instruction when E9
busy in executing the anoter instruction.
P. :0at does E5 doM
A'S( Execution 9nit receives program instruction codes and data from 3"9+ executes
these instructions and store the result in general registers.
9C. :0!0 Segment !s used to store !nterrupt and subrout!ne return address
reg!stersM
Dept. of CSE REC,Hulkoti.
8086 Lab Manual !
A'S( *tack *egment in segment register is used to store interrupt and subroutine return
address registers.
99. :0at does m!roproessor speed depend onM
A'S( The processing speed depends on $ATA 39* 6"$T>.
9<. :0at !s t0e s!/e o" data bus and address bus !n GCG@M
A'S( %&%' has ,'0bit data bus and -&0 bit address bus.
9=. :0at !s t0e ma3!mun memor+ address!ng apab!l!t+ o" GCG@M
A'S( The maximum memory capability of %&%' is ,)3.
9>. :0at !s "lagM
A'S( Flag is a flip0flop used to store the information about the status of a processor and
the status of the instruction executed most recently.
9B. :0!0 Dlags an be set or reset b+ t0e programmer and also used to ontrol t0e
operat!on o" t0e proessorM
A'S( Trace Flag+ "nterrupt Flag+ $irection Flag.
9@. In 0o% man+ modes GCG@ an be opertaed and 0o%M
A'S( %&%' can be opertaed in - modes. They are )inimum mode if )AV) pin is
active high and )aximum mode if )AV) pin is ground.
9K. :0at !s t0e d!""erene bet%een m!n mode and ma3 mode o" GCG@M
A'S( )inimum mode operation is the least expensive way to operate the %&%'
microprocessor because all the control signals for the memory and "VC are generated by
the micro processor. "n )aximum mode some of the control signals must be externally
generatred. This re=uires the addition of an external bus controller. "t used only when the
system contains external coprocessors such as %&%? arithmetic coprocessor.
9G. :0!0 bus ontroller used !n ma3!mum mode o" GCG@M
A'S( %-%% bus controller is used to provide the signals eliminated from the %&%' by the
maximum mode operation.
9P. :0at !s sta,M
A'S( *tack is a portion of 4A) used for saving the content of Program 5ounter and
general purpose registers.
Dept. of CSE REC,Hulkoti.
8086 Lab Manual !8
<C. :0!0 Sta, !s used !n GCG@M
A'S( F"FC 7First "n First Cut8 stack is used in %&%'."n this type of *tack the first stored
information is retrieved first.
<9. :0at !s t0e pos!t!on o" t0e Sta, Po!nter a"ter t0e P5S; !nstrut!onM
A'S( The address line is &- less than the earlier value.
<<. :0at !s t0e pos!t!on o" t0e Sta, Po!nter a"ter t0e P&P !nstrut!onM
A'S( The address line is &- greater than the earlier value.
<=. :0at !s !nterruptM
AA*# "nterrupt is a signal send by external device to the processor so as to re=uest the
processor to perform a particular work.
<>. :0at are t0e var!ous !nterrupts !n GCG@M
A'S( )askable interrupts+ Aon0)askable interrupts.
<B. :0at !s meant b+ Mas,able !nterruptsM
A'S( An interrupt that can be turned off by the programmer is known as )askable
interrupt.
<@. :0at !s 'onAMas,able !nterruptsM
A'S( An interrupt which can be never be turned off 7ie.disabled8 is known as Aon0
)askable interrupt.
<K. :0!0 !nterrupts are generall+ used "or r!t!al eventsM
A'S( Aon0)askable interrupts are used in critical events. *uch as Power failure+
Emergency+ *hut off etc.+
<G. G!ve e3ample "or 'onAMas,able !nterruptsM
A'S( Trap is known as Aon0)askable interrupts+ which is used in emergency condition.
<P. G!ve e3amples "or Mas,able !nterruptsM
A'S" 4*T ?.1+ 4*T'.1+ 4*T1.1 are )askable interrupts. 6hen 4*T1.1 interrupt is
received the processor saves the contents of the P5 register into stack and branches to
-5h 7hexadecimal8 address.
Dept. of CSE REC,Hulkoti.
8086 Lab Manual !!
6hen 4*T'.1 interrupt is received the processor saves the contents of the P5 register
into stack and branches to ./h 7hexadecimal8 address.
6hen 4*T?.1 interrupt is received the processor saves the contents of the P5 register
into stack and branches to .5h 7hexadecimal8 address.
=C. :0at !s SIM and 7IM !nstrut!onsM
A'S( *") is *et "nterrupt )ask. 9sed to mask the hardware interrupts. 4") is 4ead
"nterrupt )ask. 9sed to check whether the interrupt is )asked or not.
=9. :0at !s maroM
A'S( )acro is a set of instructions that perform a task and all the isntructions defined in
it is inserted in the program at the point of usage.
=<. :0at !s t0e d!""erene bet%een Maro and ProedureM
A'S( A procedure is accessed via a 5A(( instruction and a macro will inserted in the
program at the point of execution.
==. :0at !s meant b+ LA1C;M
A'S( (atch is a $0 type flip0flop used as a temporary storage device controlled by a
timing signal+ which can store & or ,. The primary function of a (atch is data storage. "t is
used in output devices such as (E$+ to hold the data for display
=>. :0at !s a omp!lerM
A'S( 5ompiler is used to translate the high0level language program into machine code
at a time. "t doesn.t re=uire special instruction to store in a memory+ it stores
automatically. The Execution time is less compared to "nterpreter.
=B. :0at !s t0e d!sadvantage o" m!roproessorM
A'S( "t has limitations on the siPe of data. )ost )icroprocessor does not support
floating0point operations.
36. Wat i! te G<CBBA de"ice#
$%S& The %-11AV%-511A interfaces peripheral "VC devices to the microcomputer system
bus. "t is programmable by the system software. "t has a .0state bi0directional %0bit buffer
which interfaces the %-11AV%-511A to the system data bus.
=K. :0at ,!nd o" !nput)output !nter"ae dose a PPI !mplementM
Dept. of CSE REC,Hulkoti.
8086 Lab Manual 100
A'S# "t provides a parallel interface+ which includes features such as single0bit+ /0bit+ and
byte0wide input and output portsF level0sensitive inputsF latched outputsF strobed inputs or
outputsF and strobed bidirectional inputVoutputs.
=G. ;o% man+ I)& l!nes are ava!lable on t0e G<CBBAM
$%S" 82C55# 0a/ a total of 24 '12 line/.
=P. #esr!bes t0e mode C2 mode 92 and mode < operat!ons o" t0e G<CBBAM
$%S" )C$E &# *imple "VC mode. "n this mode+ any of the ports A+ 3+ and 5 can be
programmed as input or output. "n this mode+ all the bits are out or in.
)C$E ,# Ports A and 3 can be used as input or output ports with handshaking
capabilities. >andshaking signals are provided by the bits of port 5.
)C$E -# Port A can be used as a bidirectional "VC port with handshaking capabilities
whose signals are provided by port 5. Port 3 can be used either in simple "VC mode or
handshaking mode ,.
>C. :0at !s t0e mode and I)& on"!gurat!on "or ports A2 B2 and C o" an G<CBBA
a"ter !ts ontrol reg!ster !s loaded %!t0 G<;M
A'S( "f control register is loaded with %->+ then the port 3 is configured as an input
port+ port A and port 5 are configured as output ports and in mode &.
Dept. of CSE REC,Hulkoti.

You might also like