micro processor manual with viva.doc
-
Upload
mallikarjun-talwar -
Category
Documents
-
view
264 -
download
0
Transcript of micro processor manual with viva.doc
-
7/26/2019 micro processor manual with viva.doc
1/100
8086 Lab Manual 1
IV SEM CSE
LAB MANUAL
MICROPROCESSORLAB (8086)
Sub Code: 06CSL48
Mr. J B.Sasanur Mr. Basavaraj G.Kumbar
Dept. of CSE REC,Hulkoti.
-
7/26/2019 micro processor manual with viva.doc
2/100
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.
-
7/26/2019 micro processor manual with viva.doc
3/100
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 givenbelow.
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 inprogram regarding to syntax the assembler will generates an object module as discussabove.
C()"oldername*l!n, "!lename.obj
After verifying the program for correct syntax and the generated object filesshould be linked together. For this the above link command should be executed and it willgive 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. Forthis the above command is used and the execution of the program can be done in differentways. "t is as shown below#
44 g omplete e3eut!on o" program !n s!ngle step.
Dept. of CSE REC,Hulkoti.
-
7/26/2019 micro processor manual with viva.doc
4/100
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.
-
7/26/2019 micro processor manual with viva.doc
5/100
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 thestudent 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 numbers1. 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 searchalgorithm.
b84ead the status of eight input bits from the (ogic 5ontroller "nterface anddisplay 2FF! if it is even parity bits otherwise display &&. Also display number of,!s in the input data.
2. a86rite 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 keyboardterminated by the carriage return and print the string on the display in the nextline.
b8Perform 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 the3ubble *ort algorithm.
b84ead the status of two %0bit inputs 7 : ;8 from the (ogic 5ontroller "nterfaceand display
-
7/26/2019 micro processor manual with viva.doc
6/100
8086 Lab Manual 6
Ensure a flashing rate that makes it easy to read both the messages 7Examinerdoes not specify these delay values nor it is necessary for the student to computethese values8.
5. a84everse a given string and check whether it is a palindrome or not.
b8Assume any suitable message of ,- characters length and display it in therolling 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. 7Examinerdoes not specify these delay values nor it is necessary for the student to computethese values8.
6. a84ead two strings+ store them in locations *T4, and *T4-. 5heck whether theyare e=ual or not and display appropriated messages. Also display the length of thestored strings.
b85onvert a ,'0bit binary value 7assumed to be an unsigned integer8 to 35$ anddisplay it from left to right and right to left for specified number of times on a ?0segment display interface.
. a84ead your name from the keyboard and display it at a specified location on thescreen in front of the message 6hat is your name@ ;ou must clear the entirescreen before display.
b8$rive a *tepper )otor interface to rotate the motor in clockwise direction by steps 7 is specified by the examiner8. "ntroduce suitable delay betweensuccessive steps. 7Any arbitrary value for the delay may be assumed by thestudent8.
8. a85ompute the factorial of a positive integer 2n! using recursive procedure.
b8$rive a stepper motor interface to rotate the motor in anticlockwise directionby steps 7 is specified by the examiner8. "ntroduce suitable delay betweensuccessive steps 7 Any arbitrary value for he delay may be assumed by thestudent8.
!. a85ompute n5r using recursive procedure. Assume that 2n! and 2r! are non0negative integers.
b8$rive a stepper motor interface to rotate the motor by steps left direction and steps right direction 7 is specified by the examiner8. "ntroduce suitable delaybetween successive steps. 7Any arbitrary value for the delay may be assumed bythe student8.
10. a8 Find out whether a given sub0string is present or not in a main string ofcharacters.
Dept. of CSE REC,Hulkoti.
-
7/26/2019 micro processor manual with viva.doc
7/100
8086 Lab Manual
b8*can a % x keypad for key closure and to store the code of the key pressed ina memory location or display on screen. Also display row and column numbers ofthe key pressed.
11. a8Benerate the first 2n! Fibonacci numbers.
b8*can a % x keypad for key closure and simulate A$$ and *93T4A5Toperations as in a calculator.
12. a84ead the current time from the system and display it in the standard format onthe screen.
b8Benerate the *ine 6ave using $A5 interface 7The output of the $A5 is to bedisplayed on the 54C8.
13. a8Program to simulate a $ecimal 9p0counter to display &&0DD.
b8Benerate a >alf 4ectified *ine wave form using the $A5 interface. 7Theoutput of the $A5 is to be displayed on the 54C8.
14. a84ead a pair of input co0ordinates in 35$ and move the cursor to the specifiedlocation on the screen.
b8Benerate a Fully 4ectified *ine waveform using the $A5 interface. 7Theoutput of the $A5 is to be displayed on the 54C8.
15. a8Program 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 CFFstate.!!.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.
ote# "n the examination each student picks one =uestion from a lot of all ,1 =uestions
Dept. of CSE REC,Hulkoti.
-
7/26/2019 micro processor manual with viva.doc
8/100
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+data mov ds+ax $ATA *EB)ET ""T"A("GAT"C
mov al+num, mov ah+al
mov bh+ah mov bl+al )CHE* 3;TE (EBT> CF $ATA F4C) 4EB.A( TC 4EB.3(
mov cx+num- mov dx+cx
mov si+axmov di+si )CHE* 6C4$ (EB>T CF $ATA F4C) 4EB.5 TC 4EB.$
int TE4)"ATE* T>E P4CB4A) EE59T"C
align ,' $ATA *EB)ET *TA4T* F4C) PABE 3C9$A4;end
Run1" #$%5050, &$%5050, C$%1234, D$%1234, S'%1234, D'%1234
Dept. of CSE REC,Hulkoti.
-
7/26/2019 micro processor manual with viva.doc
9/100
8086 Lab Manual !
-
7/26/2019 micro processor manual with viva.doc
10/100
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+data mov ds+ax ""T"A("GE* $ATA *EB)ET
mov al+num, mov bl+num- add al+bl A$$ T>E - 3;TE* mov sum+al *TC4E* T>E 4E*9(T " )E)C4;
mov cx+num add cx+num/ A$$ T>E - 6C4$* mov sum-+cx *TC4E* T>E 4E*9(T " )E)C4;
int TE4)"ATE T>E P4CB4A) EE59T"C
align ,' $* *TA4T* F4C) PABE 3C9$A4;end
Run1" #$%((0&, C$%1236
Dept. of CSE REC,Hulkoti.
-
7/26/2019 micro processor manual with viva.doc
11/100
8086 Lab Manual 11
>. ALP 1& M5L1IPL? 1:& 9@BI1 '5MBE7S
.model small
.data
num, dw ,-/hnum- dw &ffffhres dw 1 dup7&8
.ode
mov ax+datamov ds+ax ""T"A("GAT"C CF $ATA *EB)ET
mov ax+num,mov dx+num-mul dx )9(T"P("E* - ,'03"T 9)3E4*
mov res+axmov resI-+dx *TC4E* T>E " )E)C4;
int TE4)"ATE T>E P4CB4A) EE59T"Calign ,' $* *TA4T* F4C) PABE 3C9$A4;
end
Dept. of CSE REC,Hulkoti.
-
7/26/2019 micro processor manual with viva.doc
12/100
8086 Lab Manual 12
. ALP 1& #IVI#E =
-
7/26/2019 micro processor manual with viva.doc
13/100
8086 Lab Manual 13
@. ALP 1& !llustrate t0e use o" AAA !nstrut!on
.model small
.data
read macro *tart of a macromov ah+&,h read a single key strokeint -,hendm end of macro
.ode
mov ax+datamov ds+ax ""T"A("GAT"C CF $ATA *EB)ET
read 5A(( )A54C 4EA$mov bl+al *TC4E T>E 4EA$ LE; " 3( 4EB"*TE4
readmov cl+al
add al+bl A$$ A( 6"T> 3( A$ *TC4E* T>E 4E*9(T " A(.
mov dl+almov ah+&aaa A$M9*T T>E A( HA(9E TC 9PA5LE$ 35$
mov si+ax
int TE4)"ATE* T>E P4CB4A) EE59T"Cend
Dept. of CSE REC,Hulkoti.
-
7/26/2019 micro processor manual with viva.doc
14/100
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, 9
.data
array db 1+ ,-+ -+ /1+ '&+ '?+ D'+ ,&& len e=u N0array key db ,&& msg, db OfoundNO msg- db Onot foundNO.ode
mov ax+ data 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+ bxinc 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.
-
7/26/2019 micro processor manual with viva.doc
15/100
8086 Lab Manual 15
Conlus!on(
This program performs a search for a key element in an array. "f the searchelement is found it will display a message 2found!. As the search element 7key inprogram8 is not present in the given array it will display a message 2not found!.
Dept. of CSE REC,Hulkoti.
-
7/26/2019 micro processor manual with viva.doc
16/100
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+ . Also d!spla+ number o" 9s !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+ datamov ds+ ax
mov dx+ ctrlmov al+ %-h
out dx+ al
mov dx+ pb in al+ dx mov bl+ &&h mov cx+ &%up( rcl al+, jnc down inc bldo%n( loop up
test bl+&,h jn oddp
mov al+&ffh jmp nextoddp( mov al+&&hne3t( mov dx+pa
out dx+al
call delay
mov al+ blmov dx+ paout dx+ al
int
dela+ pro mov ax+&ffffhup
-
7/26/2019 micro processor manual with viva.doc
17/100
8086 Lab Manual 1
jn up, .dec ax)n* up2ret
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 delaydisplay 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.
-
7/26/2019 micro processor manual with viva.doc
18/100
8086 Lab Manual 18
-
7/26/2019 micro processor manual with viva.doc
19/100
8086 Lab Manual 1!
endm
Conlus!on(
This program reads a string message till enter key is pressed 7user has to enterthe string8. As soon as enter key pressed the read string will displayed on the screen.
Dept. of CSE REC,Hulkoti.
-
7/26/2019 micro processor manual with viva.doc
20/100
8086 Lab Manual 20
-
7/26/2019 micro processor manual with viva.doc
21/100
8086 Lab Manual 21
do%n( mov al+clmov dx+paout dx+alcmp cl+&&h
je downmov al+clsub al+&,dasmov cl+aljmp down,
do%n( mov cl+DDhdo%n9( jmp upe3!t( int
dela+ pro mov ax+ &ffffhup
-
7/26/2019 micro processor manual with viva.doc
22/100
8086 Lab Manual 22
7!ng ounter
.model small
.data
pa e=u &d%&&h
pb e=u &d%&,hpc e=u &d%&-hctrl e=u &d%&h
.ode
start( mov ax+datamov ds+ax
mov al+%-hmov dx+ctrlout dx+al
mov cl+&-hup( call delaymov al+clmov dx+paout dx+alrol cl+&,
mov ah+&'hmov dl+&ffhint -,hcmp al+R=Rje exitjmp up
e3!t( int
dela+ pro
mov ax+&ffffhup
-
7/26/2019 micro processor manual with viva.doc
23/100
8086 Lab Manual 23
9
9
9
9
9
(
(
(
(
(
Dept. of CSE REC,Hulkoti.
-
7/26/2019 micro processor manual with viva.doc
24/100
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+ ,hlen, e=u N0arr, arr- db -Dh+ ,-h+ /1h+ %Dh+ /h len- e=u N0arr-.ode
start( mov ax+ data mov ds+ ax
Ascending *ort mov ch+ len,0, no of itterationsagn9( mov cl+ ch no of comparisions
mov si+ offset arr,rept9( mov al+ JsiK inc si cmp al+ JsiK jbe next, xchg al+ JsiK mov Jsi0,K+ alne3t9( dec cl jn rept, dec ch jn agn,
$escending *ort mov ch+ len-0, no of itterationsagn
-
7/26/2019 micro processor manual with viva.doc
25/100
8086 Lab Manual 25
Conlus!on(
This program performs an ascending order and descending order sort on givenarray. "t will store the result in data segment. 6e have to observe the data segmentmemory location for our given array.
Dept. of CSE REC,Hulkoti.
-
7/26/2019 micro processor manual with viva.doc
26/100
8086 Lab Manual 26
=. b. 7ead t0e status o" t%o b!t !nputs FH ?8 "rom t0e Log!al Controller
Inter"ae and d!spla+ H?.
.model small
.data
pa e=u &d%&&hpb e=u &d%&,hpc e=u &d%&-hctrl e=u &d%&h db @; db @G dw @str, db ,+,&+Oread NOstr- db ,+,&+Oread ;NOstr db ,+,&+Sdisplay result N+,+,&
.ode
start( mov ax+datamov ds+ax
mov al+%-hmov dx+ctrlout dx+al
up( mov ah+&Dhmov dx+offset str,int -,h
mov ah+&,int -,h
mov dx+pbin al+dxmov x+al
mov ah+&Dhmov dx+offset str-int -,h
mov ah+&,int -,h
mov dx+pbin al+dxmov y+al
mov ah+xmul ah
Dept. of CSE REC,Hulkoti.
-
7/26/2019 micro processor manual with viva.doc
27/100
8086 Lab Manual 2
mov +ax
mov ah+&Dhmov dx+offset strint -,h
mov dx+pamov ax+mov al+ahout dx+al
call delaymov dx+pamov ax+out dx+al
mov ah+&,int -,hcmp al+OyOje upint
dela+ pro
mov ax+&FFFF>upup9( dec bx
jn up,dec axjn up-
retdela+ endp
end start
Conlus!on(
The program performs the multiplication between two bytes and gives theresult. A message appears on the screen as enter t0e "!rst number.First byte it readsfrom the port 3 of logic controller 7user as to provide8 and waits for enter key to bepressed and once enter key is pressed it will display a message on screen as enter t0eseond numberand once again it reads the data from port 3 7user as to provide one moredata from the same port8 and waits for enter key to be pressed. 4esult will be displayedon the port A of the logic controller.
Dept. of CSE REC,Hulkoti.
-
7/26/2019 micro processor manual with viva.doc
28/100
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+ data mov ds+ ax
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+ &?hadd=( add al+ &h mov ascii+ al
mov al+ alpha and al+ &fh cmp al+ &Dh jbe add&h add al+ &?hadd=0( add al+ &h mov asciiI,+ al 5(EA4 T>E *54EE
mov cx+ &hE 594*C94 PC*"T"C TC $E*"4E$ (C5AT"C. mov ah+ &-h mov bh+ && mov dl+ & column no. mov dh+ ,1 row no. int ,&h
Dept. of CSE REC,Hulkoti.
-
7/26/2019 micro processor manual with viva.doc
29/100
8086 Lab Manual 2!
mov dx+ offset ascii mov ah+ &Dh int -,h
P4E** ETE4 LE;
mov ah+ &,hint -,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 thecursor 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 isnot been terminated until enter key is pressed.
Dept. of CSE REC,Hulkoti.
-
7/26/2019 micro processor manual with viva.doc
30/100
8086 Lab Manual 30
>. b. #!spla+ messages DI7E and ;ELP alternatel+ %!t0 "l!,er!ng e""ets on a
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, 9
.data
pa e=u &d%&&h pb e=u &d%&,h
pc e=u &d%&-hctrl e=u &d%&hstr, db %eh+ &fDh+ %%h+ %'hstr- db %Dh+ %'h+ &c?h+ %ch
.ode
start( mov ax+ data
mov ds+ ax
mov al+ %&hmov dx+ ctrlout dx+ al
aga!n( mov bx+ offset str,call displaycall delaymov bx+ offset str-call displaycall delay
mov ah+ &'hmov dl+ &ffhint -,hcmp al+ R=Rjne again
int
d!spla+ pro
mov si+ &hup9( mov cl+ &%h
mov ah+ JbxIsiKup( mov dx+ pb
rol ah+ ,mov al+ ahout dx+ al
call clock
Dept. of CSE REC,Hulkoti.
-
7/26/2019 micro processor manual with viva.doc
31/100
8086 Lab Manual 31
dec cljn updec sicmp si+ 0,jne up,
retd!spla+ endp
lo, pro
mov dx+ pcmov al+ &,hout dx+ almov al+ &out dx+ almov dx+ pbret
lo, endp
dela+ pro
push cxpush bxmov cx+ &ffffh
d
-
7/26/2019 micro processor manual with viva.doc
32/100
8086 Lab Manual 32
. 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 Oot PalindromeNO.ode
start( mov ax+data 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 cldrepe 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 theoriginal string as it is and compares both the strings. "t will check each and everycharacter. "f all the characters are same then the given string is said to be as palindromeand it will display a message Spal!ndrome on screen otherwise the given string is notpalindrome and it will display a message Snot pal!ndrome on screen.
Dept. of CSE REC,Hulkoti.
-
7/26/2019 micro processor manual with viva.doc
33/100
8086 Lab Manual 33
. b. Assume an+ su!table message o" 9< 0araters lengt0 and d!spla+ !t !n t0e
roll!ng "as0!on on a Segment 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, 9.data
pa e=u &d%&&hpb e=u &d%&,hpc e=u &d%&-hctrl e=u &d%&hstr, db &c&h+&fDh+&a/h+&b&h+DDh+D-h+%h+&f%h+%&h+D%h+&c&h+&fDh
.ode
start( mov dx+ datamov ds+ dx
mov al+ %&hmov dx+ ctrlout dx+ al
aga!n( mov bx+ offset str,call displaycall delaymov ah+ &'hmov dl+ &ffhint -,hcmp al+ R=Rjn againint
d!spla+ pro
mov si+ &bh
up9( call delaymov cl+ &%hmov ah+ JbxIsiK
up( mov dx+ pbrol ah+ ,mov al+ ahout dx+ al
call clock dec cljn up
Dept. of CSE REC,Hulkoti.
-
7/26/2019 micro processor manual with viva.doc
34/100
8086 Lab Manual 34
dec sicmp si+ 0,jne up,ret
d!spla+ endp
lo, pro
mov dx+ pcmov al+ &,hout dx+ almov al+ &out dx+ almov dx+ pbret
lo, endp
dela+ propush cxpush bx
mov cx+ &ffffhd
-
7/26/2019 micro processor manual with viva.doc
35/100
8086 Lab Manual 35
@. a. 7ead t%o str!ngs store t0em !n loat!ons S179 and S17
-
7/26/2019 micro processor manual with viva.doc
36/100
8086 Lab Manual 36
disp msg- mov si+&h
upET>E4 *T4"B* A4E EU9A( C4 CT. mov cx+len, cmp cx+len- jne note=
mov si+offset str, mov di+offset str- cldrepe cmpsb jne note=
disp msg/ jmp next
note6( disp msgne3t( 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 itchecks the length of the strings and if lengths are e=ual then it will checks each and everycharacter. "f all the characters are same then the given strings are said to be e=ual and itwill display a message Sstrings are e=ual along with length of both the strings on screen.
Dept. of CSE REC,Hulkoti.
-
7/26/2019 micro processor manual with viva.doc
37/100
8086 Lab Manual 3
@. b. Convert a 9@b!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
Segment d!spla+ Inter"ae.
.model small
.data pa e=u &d%&&hpb e=u &d%&,hpc e=u &d%&-hctrl e=u &d%&hbin dw &&&Dhbcd db / dup7&8count db &-disptbl db &c&h+ &fDh+ &a/h+ &b&h+ DDh+ D-h+ %-h+ &f%h+ %&h+ D%h
.ode
start( mov ax+ data
mov ds+ ax
mov al+ %&hmov dx+ ctrlout dx+ al
mov bx+ ,&mov cx+ &/mov ax+ bin
ba,( mov dx+ &div bxpush dxloop backlea si+ bcdmov cx+ &/
ba,9( pop dx
mov JsiK+ dlinc siloop back,
mov bx+ offset disptbl
d!sp( call display,call delaycall displaycall delaydec countjn dispint
d!spla+ pro
Dept. of CSE REC,Hulkoti.
-
7/26/2019 micro processor manual with viva.doc
38/100
8086 Lab Manual 38
mov si+ &&n3t0ar(mov al+ bcdJsiK
xlatmov ah+ %
n3tseg( mov dx+ pb
rol al+ &,out dx+ almov ch+ al
call clockmov al+chdec ahjn nxtseg
inc sicmp si+/
jne nxtcharretd!spla+ endp
d!spla+9 pro
mov si+ &n3t0ar9( mov al+ bcdJsiK
xlatmov ah+ %
n3tseg9( mov dx+ pbrol al+ &,out dx+ almov ch+ al
call clockmov al+chdec ahjn nxtseg,
dec sicmp si+0,jne nxtchar,ret
d!spla+9 endp
lo, pro
mov dx+ pcmov al+ &,hout dx+ almov al+ &
Dept. of CSE REC,Hulkoti.
-
7/26/2019 micro processor manual with viva.doc
39/100
8086 Lab Manual 3!
out dx+ almov dx+ pbret
lo, endp
dela+ propush cxpush bx
mov cx+ &ffffhd
-
7/26/2019 micro processor manual with viva.doc
40/100
8086 Lab Manual 40
. 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 :0at !s +our nameN +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 maromov dx+ offset mov ah+ &Dint -,h
endm
start( mov ax+data mov ds+ax FC4 4EA$"B T>E *T4"B disp msg, mov si+&hup( mov ah+ &, int -,h cmp al+&dh je down mov strJsiK+al inc si jmp updo%n( mov strJsiK+RNR FC4 5(EA4"B T>E *54EE mov cx+ -Dh
-
7/26/2019 micro processor manual with viva.doc
41/100
8086 Lab Manual 41
Conlus!on(
This program will reads a string and displays the same string on the screen at thedesired position after clearing the screen.
Dept. of CSE REC,Hulkoti.
-
7/26/2019 micro processor manual with viva.doc
42/100
8086 Lab Manual 42
. 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%&&hpb e=u &d%&,hpc e=u &d%&-hctrl e=u &d%&hnstep db -
.ode
start( mov ax+ datamov ds+ ax
mov al+ %&hmov dx+ ctrl
out dx+ al
mov bh+ nstepmov al+ %%h
aga!n9( call stepror al+ ,dec bhjn again,
int
step pro
mov dx+ paout dx+ al
mov cx+ &ffffhd
-
7/26/2019 micro processor manual with viva.doc
43/100
8086 Lab Manual 43
. a. Compute t0e "ator!al o" a pos!t!ve !nteger On us!ng reurs!ve proedure.
.model small
.sta, ,&&h
.data
n, dw nfact dw @
.ode
start( mov ax+ data mov ds+ ax
mov ax+ &, mov dx+ && mov cx+ n,
5A(( T>E P4C5E$94E FA5T 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 cxe3!t( ret"atn endp
end start
Conlus!on(
This program computes the factorial of a given number and stores the result in Aand $ registers.
Dept. of CSE REC,Hulkoti.
-
7/26/2019 micro processor manual with viva.doc
44/100
8086 Lab Manual 44
. b. #r!ve a Stepper Motor Inter"ae to rotate t0e motor !n ant!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%&&hpb e=u &d%&,hpc e=u &d%&-hctrl e=u &d%&hnstep db -
.ode
start( mov ax+ datamov ds+ ax
mov al+ %&h
mov dx+ ctrlout dx+ al
mov bh+ nstepmov al+ %%h
aga!n9( call steprol al+ ,dec bhjn again,
int
step pro
mov dx+ paout dx+ al
mov cx+ &bfffhd
-
7/26/2019 micro processor manual with viva.doc
45/100
8086 Lab Manual 45
. a. Compute nCr us!ng reurs!ve proedure. Assume t0at On and Or are non
negat!ve !ntegers.
.model small
.sta, -&
.data n db &%h r db &1h ncr db @.ode
start( mov ax+data mov ds+ax mov ncr+&&h mov al+n mov bl+r call encer
int
ener propara9( cmp al+bl je para%para( dec al cmp bl+al je paraDpara( push ax push bx call encerpara@( pop bx pop ax dec bl push ax push bx call encerpara( pop bx pop ax retpara( inc ncr retpara( inc ncrpara9( add ncr+al retener endp
end start
Dept. of CSE REC,Hulkoti.
-
7/26/2019 micro processor manual with viva.doc
46/100
8086 Lab Manual 46
Conlus!on(
This program performs n5r using recursive procedure. Cutput is stored in datasegment. To observe the output in data segment we have to search for our given OnandOrvalues as program is written to store the result after the given data in data segment.
Dept. of CSE REC,Hulkoti.
-
7/26/2019 micro processor manual with viva.doc
47/100
8086 Lab Manual 4
. 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%&&hpb e=u &d%&,hpc e=u &d%&-hctrl e=u &d%&hnstep db -
.ode
start( mov ax+ datamov ds+ ax
mov al+ %&h
mov dx+ ctrlout dx+ al
mov bh+ nstep
mov al+ %%h
aga!n9( call stepror al+ ,dec bhjn again,
mov bh+ nstepmov al+ %%h
aga!n
-
7/26/2019 micro processor manual with viva.doc
48/100
8086 Lab Manual 48
retstep endp
end start
Conlus!on(
This program drives a stepper motor interface to rotate by % steps left directionand % steps right direction. After each rotation a delay is introduced to observe therotation. After completing the rotations the execution will get stopped.
Dept. of CSE REC,Hulkoti.
-
7/26/2019 micro processor manual with viva.doc
49/100
8086 Lab Manual 4!
9. a. D!nd out %0et0er a g!ven substr!ng !s present or not !n a ma!n str!ng o"
0araters.
.model small
.data
str, db RLA4ATALAR 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+data 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 jn 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+ald!spla+( mov ah+&Dh int -,h int
Dept. of CSE REC,Hulkoti.
-
7/26/2019 micro processor manual with viva.doc
50/100
8086 Lab Manual 50
end start
Conlus!on(
This program checks a sub0string is present or not in main string. 3oth sub0stringand main string are provided in data segment of program. "f substring is found in main
string it will display a message Ssubstring found. "f not it will display a message asSsubstring not found.
Dept. of CSE REC,Hulkoti.
-
7/26/2019 micro processor manual with viva.doc
51/100
8086 Lab Manual 51
9. b. San a 3= ,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, ,&&.datapa e=u &d%&&hpb e=u &d%&,hpc e=u &d%&-hctrl e=u &d%&hA*5""5C$E db O&,-/1'?%D.I0
-
7/26/2019 micro processor manual with viva.doc
52/100
8086 Lab Manual 52
mov cl+&rol bh+clmov cl+bhmov al+ahlea bx+A*5""5C$E
add bl+clxlatmov key+al
disp msgdisp str,mov ah+ &,int -,hcmp al+RyRje again,int
san promov cx+&mov bh+&mov al+%&h
n3tro%( rol al+,mov bl+almov dx+pcout dx+almov dx+pain al+dxcmp al+&jne keyid
mov al+blinc bhloop nxtrowret
,e+!d( mov si+,mov cx+%mov ah+&
agn( ror al+,jc skipinc ahloop agn
s,!p( retsan endp
end start
Dept. of CSE REC,Hulkoti.
-
7/26/2019 micro processor manual with viva.doc
53/100
8086 Lab Manual 53
Conlus!on(
This program reads the data from the %
-
7/26/2019 micro processor manual with viva.doc
54/100
8086 Lab Manual 54
99. a. Generate t0e "!rst On D!bona! numbers.
.model small
.sta, -&
.data
fib db ,1 dup7@8 n dw &Dh.ode
start( mov ax+data mov ds+ax
mov cx+n lea si+fib mov byte ptr JsiK+&&h inc si dec cx
mov byte ptr JsiK+&, dec cxa9( 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 beobserved in data segment. Fibonacci series of first D numbers is &&+ &,+ &,+ &-+ &+ &1+ &%+&$+ ,1.
Dept. of CSE REC,Hulkoti.
-
7/26/2019 micro processor manual with viva.doc
55/100
8086 Lab Manual 55
99. b. San an 3= ,e+pad "or ,e+ losure and s!mulate A## and S5B17AC1
operat!ons as !n a alulator.
.model small
.data
pa e=u &d%&&hpb e=u &d%&,hpc e=u &d%&-hctrl e=u &d%&hasciicode db O&,-/1'?%D.I0
-
7/26/2019 micro processor manual with viva.doc
56/100
8086 Lab Manual 56
cmp al+R0Rje sub,disp msg/jmp up
add9( mov al+op,add al+op-sub al+'&hmov res+RIRaamadd ax+ &&hmov resI,+ ahmov resI-+ aljmp exit
sub9( mov al+op,
mov bl+op-cmp al+bljnc next
mov res+R0Rxchg al+bljmp next,
ne3t( mov res+RIRne3t9( sub al+bl
aamadd ax+ &&hmov resI,+ ahmov resI-+ al
e3!t( disp msg1int
,b pro
mov si+&&haga!n9( call delay
call scancmp si+&&hje again,mov cl+&rol bh+clmov cl+bhmov al+ahlea bx+asciicodeadd bl+clxlatmov JdiK+al
Dept. of CSE REC,Hulkoti.
-
7/26/2019 micro processor manual with viva.doc
57/100
8086 Lab Manual 5
ret,b endp
san pro
mov cx+&
mov bh+&mov al+%&h
nro%( rol al+,mov bl+almov dx+pcout dx+almov dx+pain al+dxcmp al+&&hjne keyid
mov al+blinc bhloop nrowret
,e+!d ( mov si+,mov ah+&mov cx+%
agn( rcr al+,jc skipinc ahloop agn
s,!p( retsan endp
dela+ pro
mov bx+&bfffhnet9( mov cx+&fff&hnet( loop net
dec bxjn net,ret
dela+ endp
end start
Conlus!on(
This program reads the data from the %
-
7/26/2019 micro processor manual with viva.doc
58/100
8086 Lab Manual 58
9>#)). 3ut by using the sameDOS functionwe canalso display the seconds and milliseconds.
Dept. of CSE REC,Hulkoti.
-
7/26/2019 micro processor manual with viva.doc
59/100
8086 Lab Manual 5!
9
-
7/26/2019 micro processor manual with viva.doc
60/100
8086 Lab Manual 60
Conlus!on(
This program generates a sine wave of having amplitude of 1H. Cutput will beseen in 54C. "t will be continues wave. "t stops execution as soon as any key is pressedfrom the key board.
Dept. of CSE REC,Hulkoti.
-
7/26/2019 micro processor manual with viva.doc
61/100
8086 Lab Manual 61
9=. a. Program to s!mulate a #e!mal 5pCounter to d!spla+ Q .
.model small
.data
string db Othe count is O
nors db @+@+RNR.odestart( mov ax+data mov ds+ax
mov ah+&h mov bh+&&h int ,&hup( mov cl+&&hup9( 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+&ffffhd9( mov dx+&fffhd
-
7/26/2019 micro processor manual with viva.doc
62/100
8086 Lab Manual 62
end start
Conlus!on(
5ount from && to DD will given by this program. 5ount will continue until a keyis pressed in key board.
Dept. of CSE REC,Hulkoti.
-
7/26/2019 micro processor manual with viva.doc
63/100
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/&,hpc e=u &c/&-hctrl e=u &c/&htable 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+data
mov ds+ax
mov al+%&hmov dx+ctrlout dx+al
aga!n=( mov bx+&1hup( mov cx+%
mov si+&&
aga!n>( mov dx+pamov al+tableJsiKout dx+alinc siloop again/
mov cx+%mov al+,-%
ne3t( out dx+alloop nextdec bxcmp bx+&&hjn up
mov ah+&'hmov dl+&ffhint -,hj again
int end start
Dept. of CSE REC,Hulkoti.
-
7/26/2019 micro processor manual with viva.doc
64/100
8086 Lab Manual 64
Conlus!on( This program generates a half 0 rectified sine wave of 1H amplitude. Cutputwill be seen in 54C. "t stops execution as soon as any key is pressed from the key board.
Dept. of CSE REC,Hulkoti.
-
7/26/2019 micro processor manual with viva.doc
65/100
8086 Lab Manual 65
9>. a. 7ead a pa!r o" !nput oord!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+data
mov ds+axmov 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.
-
7/26/2019 micro processor manual with viva.doc
66/100
8086 Lab Manual 66
5(EA4 *54EE mov ah+&-h mov cx+ ,Dh
-
7/26/2019 micro processor manual with viva.doc
67/100
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/&,hpc e=u &c/&-hctrl e=u &c/&htable db ,-%+,-+,?+,/,+,/'+,1&+,1/+,1D+,'+,'?+,?,+,?'+,%&+,%/+,%%
db ,D-+,D'+,DD+-&+-&'+-,&+-,+-,?+--&+--+-,?+--&+--+--'+--Ddb -,+-/+-'+-D+-/,+-/+-/1+-/?+-/%+-1&+-1,+-1-+-1+-1/+-11db -1/+-1+-1-+-1,+-1&+-/%+-/?+-/1+-/+-/,+-D+-'+-/+-,+--Ddb --'+--+--&+-,?+-,+-,&+-&'+-&+,DD+,D'+,D-+,%%+,%/+,%&+,?'db ,?,+,'?+,'+,1D+,1/+,%&+,/'+,/,+,?+,-+,-%
count dw %.ode
start( mov ax+datamov ds+ax
mov al+%&hmov dx+ctrlout dx+al
agn ( mov bx+&1ba,9( mov cx+count
mov si+&&h
ba,( mov al+tableJsiKmov dx+paout dx+alinc siloop back
dec bxcmp bx+&&jn back,
mov ah+&'hmov dl+&ffhint -,hj agnint
end start
Conlus!on(
This program generates a fully rectified sine wave of 1H amplitude. Cutput willbe seen in 54C. "t stops execution as soon as key is pressed from the key board.
Dept. of CSE REC,Hulkoti.
-
7/26/2019 micro processor manual with viva.doc
68/100
8086 Lab Manual 68
9. 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 marox lea dx+ x mov ah+ &Dh
int -,h endm
start( mov ax+data 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+&&hup9( mov ah+&,h
Dept. of CSE REC,Hulkoti.
-
7/26/2019 micro processor manual with viva.doc
69/100
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
-
7/26/2019 micro processor manual with viva.doc
70/100
8086 Lab Manual 0
9. 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%&&hpb e=u &d%&,hpc e=u &d%&-hctrl e=u &d%&htf db &cf db &
.ode
mov ax+ datamov ds+ axmov al+ %-hmov dx+ ctrl
out dx+ al
"nitially display lift in ground floormov cf+ &hmov al+ cfor al+ &f&hmov dx+ paout dx+ al
5heck for the re=uested floorstart( call chk
cmp al+R=Rj exitcmp al+ &fehje gfrcmp al+ &fdhje ffrcmp al+ &fbhje sfrcmp al+ &f?hje tfrjmp start
e3!t( int
Bround floorg"r( mov tf+&
call floorne3t( mov al+ &e&h
mov dx+ paout dx+ aljmp start
Dept. of CSE REC,Hulkoti.
-
7/26/2019 micro processor manual with viva.doc
71/100
8086 Lab Manual 1
First floor""r( mov tf+ ,
call floorne3t9( mov al+ &dh
mov dx+ paout dx+ aljmp start
*econd floors"r( mov tf+-
call floorne3t( mov dx+ pb check the status of target floorin al+dxor al+ &f&hcmp al+&ffhj chkmov tf+ alret
0, endp
procedure to move lift up and down"loor pro
mov al+ mul tfmov cl+al target floor lift position
Dept. of CSE REC,Hulkoti.
-
7/26/2019 micro processor manual with viva.doc
72/100
8086 Lab Manual 2
mov al+ &mul cfmov ch+ al current floor lift positioncmp cl+chje ext,
ja upba,( call updowndec ch to move lift downcmp cl+chjle backjmp ext
up( call updowninc ch to move lift upcmp cl+chjge up
e3t( mov cl+ tf
mov cf+ cle3t9( ret"loor endp
updo%n pro
mov al+chor al+ &f&hmov dx+ paout dx+ alcall delayret
updo%n endp
dela+ pro
push bxpush cxmov cx+&fffh
b
-
7/26/2019 micro processor manual with viva.doc
73/100
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 and A( after addition when working with35$ 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 A> X &&+ A( X &FhAAA A> X &,+ A( X &1
AAS 'o &perands
ASCII Adjust a"ter Subtrat!on.
5orrects result in A> and A( after subtraction when working with35$ 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.
-
7/26/2019 micro processor manual with viva.doc
80/100
8086 Lab Manual 80
in both cases#clear the high nibble of A(.
Example#)CH A+ &-FFh A> X &-+ A( X &FFhAA* 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 A( X &FhAA) A> X &,+ A( X &1
Interrupt I'1
-
7/26/2019 micro processor manual with viva.doc
81/100
8086 Lab Manual 81
E3ample(
)ov A>+ &,h"T -,h
Dunt!on on entry+ then thisfunction 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# #LX &\-11 Parameters for "VP# #LX -11.
4eturns# for CVP# ALX #L. For "VP# Dset if no character available : ALX &
Dclear if character available : ALX character.E3ample(
)ov A>+ &'h)ov $(+ &ffh"T -,h
Dunt!on 0- :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 controlcharacters such as carriage return 7&$>8 and line feed 7&A>8.
"nvoked by# #SX string to write. A;X &Dh
E3ample()ov A>+ &Dh)ov $+offset str Address of the string to be displayed"T -,h
Dunt!on
-
7/26/2019 micro processor manual with viva.doc
82/100
8086 Lab Manual 82
E3ample(
)ov A>+ -ch"T -,h
Dunt!on =C0- Create or trunate "!le.
"nvoked by# CHX file attributes#mov cx+ & normal 0 no attributes.mov cx+ , read0only.mov cx+ - hidden.mov cx+ / systemmov cx+ ? hidden+ system and read0only]mov cx+ ,' archive
mov cx+ &3> Holume labelmov cx+ ,&> *ubdirectory
#S( #H0Z filename. A;X5h
4eturns#CDclear if successful+ AHX file handle.CDset on error AHX error code.
E3ample(
)ov A>+ ch)ov 5+ &,)ov $+ offset Filename
"T -,h
Dunt!on >900 #elete "!le7unlink8.
"nvoked by# #S( #H0Z A*5"G filename 7no wildcards+ but see notes8.A;X/,h
4eturn#CDclear if successful+ AHdestroyed.CDset on error AHX error code.
E3ample(
)ov A>+ /,h)ov $+ offset Filename"T -,h
Dunt!on >C0 Q 1erm!nate a proess.
"nvoked by# A;X /ch4eturn# returns control to the operating system.
Dept. of CSE REC,Hulkoti.
-
7/26/2019 micro processor manual with viva.doc
83/100
-
7/26/2019 micro processor manual with viva.doc
84/100
8086 Lab Manual 84
inputs from transducers like sensorsVlimit switches+ key inputs etc.. perform a se=uence oflogical and arithmetic opertaions on them and use the result to maitain the process withinspecified safe operating conditions while providing information on the status of theprocess 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 areTT( compatible. The input signals are connected to port 3 of %-511A while output linesare 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.
-
7/26/2019 micro processor manual with viva.doc
85/100
8086 Lab Manual 85
-
7/26/2019 micro processor manual with viva.doc
86/100
8086 Lab Manual 86
The hardware uses four shift register "5s ?/,'/. ?/,'/ is an %0bit serial in0parallel outshift register with asynchronous reset and two input pins. "t re=uires % clock cycles atS5(L pin to shift the serial data from input to % parallel outputs. After % shifts+ the firstserial 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 thuscommon anode displays are used. The anode is connected to IH cc. The last output of thefirst sift register is connected to input of the -nd shift register and the last output o f -nd
shift register to input of rdand so on. Thus the shift register are serial in parallel out andthey are connected to displays+ in such a way that output &A is connected to displaysegment 2a! and &3 to 2b! and so on up to &> through & ohm resistors.
The shifting of data bit takes place for each clock cycle. ?/&/ "5 used provides isolationand 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 isgenerated at a port bit which will be connected to the clock of the shift register.
P3& is used for data bit 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 tobe updated the microprocessor fetches all bytes one by one from 4A) and outputscorresponding display codes serially that is bit by bit to display. >exadecimal code isstores in the 4A). The code conversion from hexa to ? segment is done just before thedisplay 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 aretwo important types of ?0segment (E$ display."n a ommon at0odedisplay+ the cathodes of all the (E$s are joined together and theindividual segments are illuminated by >"B> voltages."n a ommon anodedisplay+ the anodes of all the (E$s are joined together and theindividual 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 inputmust 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 characterthe corresponding segment must be given low inputs.
Dept. of CSE REC,Hulkoti.
-
7/26/2019 micro processor manual with viva.doc
87/100
8086 Lab Manual 8
The one shown above is a common anode display since all anodes are joined together andgo to the positive supply. The cathodes are connected individually to ero volts. 4esistorsmust be placed in series with each diode to limit the current through each diode to a safevalue. The d.prepresents a decimal point.
The following table shows how to form characters# R&R means that pin is connected toground. 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.
-
7/26/2019 micro processor manual with viva.doc
88/100
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 mechanicalmovement. "n applications such as disk drives+ dot matrix printers+ and robotics+ thestepper motor is used for Position control.
Every stepper motor has a permanent magnet rotor 7also called the shaft.8 surrounded bya stator. The most common stepper motors have four common stator windings that arepairs with a center0taped common. This type of stepper motor is commonly referred to asa 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 sies for stepper motors range from &.Ddegrees to & degrees.
%-511A is used to provide the drive signals that are used to rotate the armature of themotor in either the right0hand or left0hand direction.
Dept. of CSE REC,Hulkoti.
-
7/26/2019 micro processor manual with viva.doc
89/100
8086 Lab Manual 8!
The power circuit for one winding of the stepper motor is as shown in figure above. "t isconnected to the port A 7PA&8 of %-511A. *imilar circuits are connected to the remaininglower bits of port A 7PA,+ PA-+ PA8. Cne winding is energied at a time. The coils areturned CVCFF one at a time successively.
Dept. of CSE REC,Hulkoti.
-
7/26/2019 micro processor manual with viva.doc
90/100
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.
-
7/26/2019 micro processor manual with viva.doc
91/100
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 theyare all connected to ground. "f all the rows are high and a key is pressed+ one of thecolumns will have , since the key pressed provides the path to high. "t is the function ofthe microprocessor to scan the keyboard continuously to detect and identify the keypressed.
Dept. of CSE REC,Hulkoti.
-
7/26/2019 micro processor manual with viva.doc
92/100
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 outputlatch+ 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 ofidentifying the key. ow micro processor sets each row to ground then it reads thecolumns. "f the data read is all &s+ no key in that row is activated and the process ismoved to next row. "t grounds the next row+ reads the columns+ and checks for any ,. Thisprocess continues until the row is identified. After identification of the row in which thekey has been pressed+ the next task is to find out which column the pressed key belongsto.To identify the key press+ it rotates the column bits+ one bit at a time+ into the carry flagand checks to see if it is high. 9pon finding the ,+ it pulls out the A*5"" code for that key
from the look0up table otherwise+ it increments the pointer to point to the next element ofthe look0up table.
Dept. of CSE REC,Hulkoti.
-
7/26/2019 micro processor manual with viva.doc
93/100
8086 Lab Manual !3
. #AC I'1E7DACE
The pin details of $A5 &%&& is given below and schematic diagram of the dual $A5interface is given below.
The port A and port 3 of %-511A peripheral are used as output ports. The digital inputs tothe $A5s are porvided through these ports. The analog outputs of the $A5s areconnected to the inverting inputs of CP0amps ?/, which acts as current to voltageconverters. 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.
-
7/26/2019 micro processor manual with viva.doc
94/100
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/8representing the re=uest buttons at the four floors. These keys are connected to preset7P48 of the $ flip0flop. "f this key is closed the output goes low and it goes high and thusthe corresponding re=uest (E$ will be C.
The outputs of the four Flip0flops 7?/(*?/8 can be read through port 3 7P3C+ P3"+ P3-and P38 so that the floor at which re=uest is re=uired is known and the same will beserviced. Also+ the status of these signals is reflected by a setoff / (E$!s which are calledas re=uest (E$s whose cathode are connected to outputs of four flip0flops while anodesare connected to I1v as shown in figure. The Flip0Flop can be rest 7(E$!s are cleared8through higher bits of port A 7PA/+ PA1+ PA'+ and PA?8 so that after servicing the floor atwhich re=uest was done the corresponding re=uest (E$ is turned CFF+ sending a low tothe flip0flop through port A.
Dept. of CSE REC,Hulkoti.
-
7/26/2019 micro processor manual with viva.doc
95/100
8086 Lab Manual !5
A column of ,& (E$!s+ representing the elevator can be controlled through Port A 7PA&+PA,+ PA- and PA8. 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 whichsimulate the motion of the elevator. These (E$* have their cathodes connected to theoutputs 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 andlogic low on output causes the corresponding (E$ goes C. For Example+ "f &&,& is theinput to the decoder then line - goes low and the third (E$ goes C.
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 theSspeed of the elevator.
Dept. of CSE REC,Hulkoti.
-
7/26/2019 micro processor manual with viva.doc
96/100
8086 Lab Manual !6
V!va $uest!ons and Ans%ers
9. :0at !s a M!roproessor
A'S( )icroprocessor is a program0controlled device+ which fetches the instructions from
memory+ decodes and executes the instructions. )ost )icro Processor are single0 chipdevices.
. :0at are t0e "lags !n @
A'S("n %&%' 5arry flag+ Parity flag+ Auxiliary carry flag+ Gero flag+ Cverflow flag+Trace flag+ "nterrupt flag+ $irection flag+ and *ign flag.
. :0at !s t0e Ma3!mum lo, "re6uen+ !n @
A'S( 1 )h is the )aximum clock fre=uency in %&%'.
@. :0at are t0e var!ous segment reg!sters !n @
A'S( 5ode+ $ata+ *tack+ Extra *egment registers in %&%'.
. Log! alulat!ons are done !n %0!0 t+pe o" reg!sters
A'S(Accumulator is the register in which Arithmetic and (ogic calculations are done.
. ;o% @ !s "aster t0an
A'S(3ecause of pipelining concept. %&%' 3"9 fetches the next instruction when E9
busy in executing the anoter instruction.
. :0at does E5 do
A'S(Execution 9nit receives program instruction codes and data from 3"9+ executesthese instructions and store the result in general registers.
9. :0!0 Segment !s used to store !nterrupt and subrout!ne return address
reg!sters
Dept. of CSE REC,Hulkoti.
-
7/26/2019 micro processor manual with viva.doc
97/100
8086 Lab Manual !
A'S(*tack *egment in segment register is used to store interrupt and subroutine returnaddress registers.
99. :0at does m!roproessor speed depend on
A'S(The processing speed depends on $ATA 39* 6"$T>.
9. :0at !s "lag
A'S( Flag is a flip0flop used to store the information about the status of a processor andthe status of the instruction executed most recently.
9. :0!0 Dlags an be set or reset b+ t0e programmer and also used to ontrol t0e
operat!on o" t0e proessor
A'S(Trace Flag+ "nterrupt Flag+ $irection Flag.
9@. In 0o% man+ modes @ an be opertaed and 0o%
A'S(%&%' can be opertaed in - modes. They are )inimum mode if )V) pin isactive high and )aximum mode if )V) pin is ground.
9. :0at!s t0e d!""erene bet%een m!n mode and ma3 mode o" @
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 bythe micro processor. "n )aximum mode some of the control signals must be externallygeneratred. This re=uires the addition of an external bus controller. "t used only when thesystem contains external coprocessors such as %&%? arithmetic coprocessor.
9. :0!0 bus ontroller used !n ma3!mum mode o" @
A'S(%-%% bus controller is used to provide the signals eliminated from the %&%' by themaximum mode operation.
9. :0at !s sta,
A'S(*tack is a portion of 4A) used for saving the content of Program 5ounter andgeneral purpose registers.
Dept. of CSE REC,Hulkoti.
-
7/26/2019 micro processor manual with viva.doc
98/100
8086 Lab Manual !8
-
7/26/2019 micro processor manual with viva.doc
99/100
8086 Lab Manual !!
6hen 4*T'.1 interrupt is received the processor saves the contents of the P5 registerinto stack and branches to /h 7hexadecimal8 address.
6hen 4*T?.1 interrupt is received the processor saves the contents of the P5 registerinto stack and branches to 5h 7hexadecimal8 address.
=. :0at !s SIM and 7IM !nstrut!ons
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 maro
A'S()acro is a set of instructions that perform a task and all the isntructions defined init is inserted in the program at the point of usage.
=
-
7/26/2019 micro processor manual with viva.doc
100/100
8086 Lab Manual 100
A'S# "t provides a parallel interface+ which includes features such as single0bit+ /0bit+ andbyte0wide input and output ports level0sensitive inputs latched outputs strobed inputs oroutputs and strobed bidirectional inputVoutputs.
=. ;o% man+ I)& l!nes are ava!lable on t0e . :0at !s t0e mode and I)& on"!gurat!on "or ports A2 B2 and C o" an + then the port 3 is configured as an inputport+ port A and port 5 are configured as output ports and in mode &.