Anda di halaman 1dari 43

Microprocessor Lab Manual 1a.

Search a key element in a list of 'n' 16-bit numbers using the Binary search algorithm. .MODEL SMALL .DATA LIST DB 1, 2,3,4,5 LNT D! " # LIST S$E% DB &3 MS'1 DB ()O*ND "( MS'2 DB (NOT )O*ND "( .+ODE MO, A-,.DATA MO, DS, AMO, SI,& MO, DI,LNT S*B DI,&1 BA$/ +M0 SI,DI 1A N) MO, B-,SI ADD B-,DI S = B-,&1 MO, Al, LIST@B-A +M0 Al, S$E% 1E %) 1B NM MO, DI,BS*B DI,&1 +M0 DI,& 1G N) 1M0 BA$ NM/ MO, SI,BADD SI,&1 1M0 BA$ N)/ LEA D-,MS'2 1M0 NE-T %)/ LEA D-,MS'1 NE-T/ MO, A ,&H INT 21 MO, A ,4+ INT 21 END Output: )oun4 2a. Write a !" macros: Dep6.o3 +SE, SSE,MuBBa 2&1&#2&11 pa;e 1

2To 3in4 5i4 poin6 27lo89:i;:< 2S:i36 bi6 6o ri;:6 ;i>es no.?2 2I3 7BeCDD@5i4A< Eu5p 6o 3oun4 2else i37BeCF@5i4A< Eu5p 6o NM 2 else DID5i4#1

2SID@5i491A

2)unc7&H:<,DisplaC S6rin;,D-Do33se6 o3 5s; /)unc74c:<,Ter5ina6e pro;ra5 2 +all DOS Ser>ice

Microprocessor Lab Manual i# $o rea% a character from the keyboar% in the mo%ule &1#&in a %ifferent file# ii# $o %isplay a character in mo%ule &2# &from %ifferent file# iii# 'se the abo(e 2 mo%ules to rea% a string of characters from the keyboar% terminate% by the carriage return an% print the string on the %isplay in the ne)t line. *+,!'-. %:/masm/m1.inc *+,!'-. %:/masm/m2.inc .1O-.! S1 !! .- $ S$2 -B 13 -'"&4# .,O-. 1O5 678- $ 1O5 -S7 6 1O5 S*73 2. -1: 2. ,1" !73-9 :. 9.2. 1O5 S$2;S*<7 ! *+, S* :1" 2. -1 9.2.: 1O5 ,67S* 1O5 S*73 1O5 -!713 -*S"! = -*S"1: 1O5 -!7S$2;S*< -*S"! = *+, S* !OO" -*S"1 1O5 97>,9 *+$ 219 .+m1.inc 0 macro to rea% a character character 2. - 1 ,2O 1O5 97 319 0?unc&31h#72ea% char *+$ 219 .+-1 Output: -sce -sce 0 macro to rea% a character 0 macro to %isplay a character

0 $o call macro 2ea% 0 3%h ascii (alue for carriage return

0 ascii (alue for line fee% 0$o call 1acro %isplay

m2.inc 0 macro to %isplay a -*S"! = 1 ,2O 1O5 97 329 0?unc&32h#7Write char *+$ 219 .+-1

@a. Sort a gi(en set of 'n' numbers in ascen%ing an% %escen%ing or%ers using Bubble sort Dep6.o3 +SE, SSE,MuBBa 2&1&#2&11 pa;e 2

Microprocessor Lab Manual algorithm. .MODEL SMALL .DATA A Db I5 ,H5 ,25 , 45 , 55 , 15 , J5 , 45 L D! " # A 2Len;6: o3 arraC .+ODE MO, A-, .DATA MO, DS, AMO, B-, L DE+ BN0/ MO, +-, BMO, SI, & NI/ MO, Al, A@SIA IN+ SI +M0 Al, A@SIA 1BE NE-T -+ ' Al, A@SIA MO, A@SI#1A,Al NE-T/ LOO0 NI DE+ B1NG N0 MO, A , 4+ INT 21 END 2B-DNo. o3 i6era6ions 2+-DNo. o3 co5parison in eac: i6era6ion

23or 4escen4in; or4er 1AE NE-T 2EKc:an;e I3 7ALL @SI91A<

Output: F4 A 15 45 45 55 J5 I5 H5

>a. 2ea% lphanumeric ,haracter A %isplay its eBui(alent S,** co%e at the centre of screen . Dep6.o3 +SE, SSE,MuBBa 2&1&#2&11 pa;e 3

Microprocessor Lab Manual

.MODEL SMALL 0=INT MA+=O MS' MO, A ,&H MO, D-,O))SET MS' INT 21 ENDM S+= MA+=O MO, A ,&& MO, AL,&3 INT 1& ENDM 0OS MA+=O MO, A ,&2 MO, B ,&& MO, D ,&+ MO, DL,23 INT 1& ENDM

2 Macro 6o 4isplaC s6rin;

2Macro 6o se6 >i4eo 5o4e

2Macro 6o Se6 6:e cursor

.DATA TM0 DB M TM01 DB M MS'1 DB 1&,13, (En6er 6:e alp:a#nu5eric c:arac6er/"( .+ODE MO, A-,.DATA MO, DS,AS+= 0=INT MS'1 MO, A ,&1 INT 21 MO, A ,&& MO, BL,1& DI, BL MO, TM01,A +M0 AL,1&D 1'E L2 ADD A-,3&3& MO, +-,A0OS MO, A ,&J MO, DL,+L INT 21 Dep6.o3 +SE, SSE,MuBBa

2i?p o3 c:ar ie, ascii eNui>alen6 co4e is s6ore4 in AL 24i>i4e 6:e no. 8i6: 1& ;i>es 6:e 4eci5al eNui>alen6 o3 :eK no. 2con>er6e4 no. is s6ore4 in A- re;is6er

24isplaC 6:e no. in 6:e cen6re o3 6:e screen

2&1&#2&11

pa;e 4

Microprocessor Lab Manual MO, A ,&J MO, DL,+ INT 21 1M0 LAST L2/ MO, A ,&& DI, BL ADD A-,3&3& MO, TM0,A 0OS MO, A ,&J MO, DL,AL INT 21 MO, A ,&J MO, DL,TM0 INT 21 MO, A ,TM01 ADD A ,3& MO, TM01,A MO, A ,&J MO, DL,TM01 INT 21 LAST/ MO, A ,4+ INT 21 END 2i3 a36er 1 4i> 6:e no. is no6 con>er6e4 4i>i4e i6 3ur6:er

Output: En6er 6:e alp:a#nu5eric c:arac6er / O

55

Ca. 2e(erse a gi(en string an% check Dhether it is a palin%rome or not. .MODEL SMALL .STA+$ 1&& Dep6.o3 +SE, SSE,MuBBa 2&1&#2&11 pa;e 5

Microprocessor Lab Manual .DATA ST= DB (MALA%ALAM( N DB "#ST= =ST= DB 1& D*07&< MS'1 DB (ST=IN' IS 0ALIND=OME"( MS'2 DB (NOT 0ALIND=OME"( .+ODE MO, A-,.DATA MO, DS,AMO, ES,AMO, +L,N DE+ +L MO, DI,+IN+ +BA$/ MO, A ,ST=@DIA MO, =ST=@SIA,A IN+ SI DE+ DI LOO0 BA$ LEA SI,ST= LEA DI,=ST= +LD MO, +L,N =E0E +M0SB 1E DMS'1 LEA D-,MS'2 1M0 -IT DMS'1/ LEA D-,MS'1 -IT/ MO, A ,&H INT 21 MO, A ,4+ INT 21 END Output: ST=IN' IS 0ALIND=OME

2To re>erse 6:e s6rin; 2 To re>erse 6:e s6rin;

2+LDSiPe o3 s6rin; 2To co5pare 6:e 2 s6rin;s 21u5p on eNual 6o )oun4 2I3 no6 eNual 4isplaC no6 3oun4

6a. 2ea% 2 strings7 store them in locations S$21 an% S$22 check Dhether they are eBual or not an% %isplay appropriate messages. lso %isplay the length of the store% strings . .MODEL SMALL .DATA Dep6.o3 +SE, SSE,MuBBa 2&1&#2&11 pa;e J

Microprocessor Lab Manual ST=1 DB 1&& DB & DB 1&& D*07&< ST=2 DB 1&& DB & DB 1&& D*07&< M1 DB (LENT O) T E ST=1/( L1 DB M,1&,13,("( M2 DB (LENT O) T E ST=2/( L2 DB M,1&,13,("( M3 DB (ST=1 IS ER*AL TO ST=2"( M4 DB (ST=1 IS NOT ER*AL TO ST=2"( .+ODE MO, A-,.DATA MO, DS,AMO, ES,ALEA D-, ST=1 MO, A ,&A INT 21 LEA D-,ST=2 INT 21 MO, +L,ST=191 MO, BL,ST=291 ADD +L,3& ADD BL,3& MO, L1,+L MO, L2,BL S*B +L,3& S*B BL,3& LEA D-,M1 MO, A ,&H INT 21 LEA D-,M2 INT 21 +M0 +L,BL 1G NE-T DM4/LEA D-,M4 MO, A ,&H INT 21 1M0 E-IT NE-T/ LEA SI,ST=192 LEA DI,ST=292 +LD =E0E +M0SB 1NG DM4 Dep6.o3 +SE, SSE,MuBBa 2&1&#2&11 2To s6ore 6:e len;6: Q 6:e s6rin;1 2 To s6ore 6:e len;6: Q 6:e s6rin;2

2To prin6 6:e len;6: o3 s6rin;1 2 To prin6 6:e len;6: o3 s6rin;2

2)unc7&A <,=ea4 Q 0rin6 s6rin;1 2 )unc7&A <,=ea4 Q 0rin6 s6rin;2 2+LDLen;6: o3 s6rin;1 2 BLDLen;6: o3 s6rin;2

2To 0rin6 6:e len;6: o3 s6rin;1 2 To 0rin6 6:e len;6: o3 s6rin;2 2+o5pare 6:e len;6: o3 s6rin;s 2I3 len;6: o3 s6rin;1Ds6rin;2,+o5pare 2I3 len;6: o3 s6rin;1SD s6rin;2 20rin6 No6 ENual Q EKi6 2Loa4 e33ec6i>e a44ress o3 s6rin;1 2 Loa4 e33ec6i>e a44ress o3 s6rin;2 2+o5pare 68o s6rin;s 2 I3 s6rin;s are no6 eNual prin6 no6 eNual pa;e O

Microprocessor Lab Manual LEA D-,M3 MO, A ,&H INT 21 E-IT/MO, A ,4+ INT 21 END Output: ra>i ra>i LENT O) T E ST=1/ 4 LENT O) T E ST=2/ 4 ST=1 IS ER*AL TO ST=2 2Else prin6 s6rin;s are eNual

Ea. 2ea% your name from the keyboar% an% %isplay it at a specifie% location on the screen in front of the message What is your name4 =ou must clear the entire screen before %isplay. .MODEL SMALL .DATA MS' DB (! AT IS %O*= NAME/( NEM DB 5& D*0 7&< Dep6.o3 +SE, SSE,MuBBa 2&1&#2&11 pa;e I

Microprocessor Lab Manual

.+ODE MO, A-,.DATA MO, DS,AMO, SI,& MO, A ,1 2)unc7&1 <,I?p a c:ar 8i6: ec:o 3ro5 BeCboar4 BA$/ INT 21 MO, NEM@SIA,AL 2Mo>e eac: c:arac6er 6o 6:e arraC IN+ SI +M0 AL,13 1NE BA$ MO, B%TE 0T= NEM@SIA,("( 2En4 o3 6:e s6rin; +ALL +L= 2+lear 6:e screen +ALL SET+ 2Se6 6:e cursor 6o 6:e speci3ie4 loca6ion LEA D-,MS' 2DisplaC 5essa;e !:a6 is Cour Na5eM MO, A ,H INT 21 MO, A ,4+ INT 21 +L=/MO, A ,J 20roce4ure 6o clear 6:e screen MO, AL,& MO, B ,O MO, + ,& MO, +L,& MO, D ,24 2D D0osi6ion o3 6:e ro8 MO, DL,OH 2 DLD0osi6ion o3 6:e col INT 1& =ET SET+/ MO, A ,2 20roce4ure 6o se6 6:e cursor MO, B ,& MO, D ,12 2D D0osi6ion o3 6:e ro8 MO, DL,2& 2DLD0osi6ion o3 6:e col INT 1& =ET END Output: =a>i !:a6 is Cour na5eM =a>i Fa. ,ompute the factorial of a positi(e integer 'n' using the recursi(e proce%ure . .MODEL SMALL .DATA N*M D! 5 =ES*LT D! M .+ODE Dep6.o3 +SE, SSE,MuBBa 2&1&#2&11 pa;e H

Microprocessor Lab Manual MO, A-,.DATA MO, DS,AMO, A-,&1 MO, B-,N*M +M0 B-,&& 2+o5pare nu5 8i6: && 1E NE-T +ALL )A+T NE-T/MO, =ES*LT,AMO, A ,4+ INT 21 )A+T 0=O+ NEA= 2=ecusi>e proce4ure 6o calcula6e )ac6orial +M0 B-,&1 2+o5pare nu5 8i6: &1 1G =I0 0*S BDE+ B+ALL )A+T 0O0 BM*L B=I0/=ET )A+T END0 END

Output: F4 =esul6 OI

Ga.,ompute n,r using recursi(e proce%ure. ssume that 'n' an% 'r' are non-negati(e integers . .MODEL SMALL .DATA N D! 5 = D! 3 N+= D! & .+ODE MO, A-,.DATA Dep6.o3 +SE, SSE,MuBBa 2&1&#2&11 pa;e 1&

Microprocessor Lab Manual MO, DS,AMO, A-,N MO, B-,= +ALL N+=0=O /=ecursi>e proce4ure 6o calcula6e N+= MO, A ,4+ INT 21 N+=0=O/+M0 B-,A2I3 B-DDA-,N+=D1 1E =ES1 +M0 B-,& 2I3 B-DD&.N+=D1 1E =ES1 +M0 B-,1 2I3 B-DD1 ,N+=D1 1E =ESN DE+ A+M0 B-,A2+o5pare B- Q A1E IN+= 2I3 B-DDA-,N+=D1 0*S A0*S B+ALL N+=0=O 0O0 B0O0 ADE+ B0*S A0*S B+ALL N+=0=O 0O0 B0O0 A=ET =ES1/IN+ N+= =ET IN+=/IN+ N+= =ESN/ ADD N+=,A=ET END Output: F D ncr &A 13a. ?in% out Dhether a gi(en sub string is present or not in a main string of characters. .MODEL SMALL .DATA ST= DB (ONE0L*ST!OISER*ALTOT =EE"( L1 D! "#ST= S*BS DB (0L*S"( L2 D! "#S*BS MS'1 DB (S*BST=IN' IS 0=ESENT IN MAIN ST=IN'"( MS'2 DB (S*BST=IN' IS NOT 0=ESENT IN MAIN ST=IN'"( .+ODE Dep6.o3 +SE, SSE,MuBBa 2&1&#2&11 pa;e 11

Microprocessor Lab Manual MO, A-,.DATA MO, DS,AMO, ES,AMO, +-,L1 MO, B-,L2 LEA DI,ST= LEA SI,S*BS +LD =0T/MO, AL,@SIA =E0NE S+ASB 2 +o5pares AL 8i6: e>erC le66er o3 ST= IN+ SI MO, D-,+DE+ BS*B +-,B2 i3 6:e len;6: o3 5ain s6rin; is L subs6rin; 4isplaC 5s;2 1B DMS'2 MO, +-,B=E0G +M0SB 2 else co5pare 6:e 68o s6rin;s 1NG N)T 2 i3 s6rin;s are no6 eNual 4isplaC 5s;2 LEA D-,MS'1 2 else 4isplaC 5s;1 MO, A ,H INT 21 1M0 E-IT DMS'2/ LEA D-,MS'2 MO, A ,H INT 21 E-IT/ MO, A ,4+ INT 21 N)T/MO, +-,DLEA SI,S*BS MO, B-,L2 1M0 =0T END Output: S*BST=IN' IS 0=ESENT IN MAIN ST=IN' 11a. Henerate the first InJ ?ibonacci numbers . .MODEL SMALL .STA+$ .DATA N DB 1& )NS DB 32 D*07&< .+ODE MO, A-,.DATA MO, DS,AMO, SI,& Dep6.o3 +SE, SSE,MuBBa 2&1&#2&11 pa;e 12

Microprocessor Lab Manual MO, )NS@SIA,& ADD SI,1 MO, )NS@SIA,1 MO, +L,N S*B +L,2 BA$/MO, AL,)NS@SI#1A ADD AL,)NS@SIA ADD SI,1 MO, )NS@SIA,AL LOO0 BA$ MO, A ,4+ INT 21 END Output: FD )NS && &1 &1 &2 &3 &5 &I &D 15 22 2 copC 6:e 3irs6 nu5ber 6o 6:e arraC 2 copC 6:e secon4 nu5ber 6o 6:e arraC 2 +LD n #2 73or 6:e res6 o3 6:e len;6:<

12a. 2ea% the current time from the system an% %isplay it in the stan%ar% format on the screen. .MODEL SMALL .+ODE MO, A ,2+ INT 21 MO, AL,+ +ALL DIS0 MO, DL,(/( MO, A ,2 INT 21 MO, AL,+L Dep6.o3 +SE, SSE,MuBBa

2 3unc72+:<, 6o ;e6 6:e sCs6e5 6i5e 2 s6ores :rs, 5ins, secs in + ,+L,D respec6i>elC

2&1&#2&11

pa;e 13

Microprocessor Lab Manual +ALL DIS0 MO, DL,(/( MO, A ,2 INT 21 MO, AL,D +ALL DIS0 MO, A ,4+ INT 21 DIS0 0=O+ NEA= AAM ADD A-,3&3& MO, B-,AMO, DL,A MO, A ,&2 INT 21 MO, DL,BL INT 21 =ET DIS0 END0 END Output: &H/55/45

2 +on>er6s E- >alues 6o unpacBe4 B+D 3or5a6

1@a. "rogram to simulate a %ecimal up-counter to %isplay 33-GG .MODEL SMALL .+ODE MO, A-,& NN/ 0*S A+ALL SET+ +ALL DIS0 +ALL DELA% MO, A ,&1 INT 1J 1NG E-IT 0O0 AADD AL,1 Dep6.o3 +SE, SSE,MuBBa

2 6o se6 6:e cursor posi6ion 2 6o 4isplaC 6:e nu5ber 2 4elaC be68een nu5bers

2&1&#2&11

pa;e 14

Microprocessor Lab Manual DAA +M0 AL,& 1NG NN E-IT/ MO, A ,4+ INT 21 SET+/ MO, A ,2 MO, D ,12 MO, DL,35 INT 1& =ET DIS0/ MO, BL,AL MO, DL,AL MO, +L,4 S = DL,+L ADD DL,3& MO, A ,2 INT 21 MO, DL,BL AND DL,&) ADD DL,3& INT 21 =ET DELA%/ MO, SI,&))) B2/ MO, DI,&)))) B1/ DE+ DI 1NG B1 DE+ SI 1NG B2 =ET END Output: HH 1>a. 2ea% a pair of input co-or%inates in B,- an% mo(e the cursor to the specifie% location on the screen . .MODEL SMALL .DATA MS'1 DB 1&,13,TENTE= =O! NO/"T MS'2 DB 1&,13,TENTE= +OL NO/"T MS'3 DB 1&,13,T0=ESS AN% $E% TO STO0"T =O! DB M +OL DB M .+ODE MO, A-,.DATA MO, DS,ALEA D-,MS'1 MO, A ,H Dep6.o3 +SE, SSE,MuBBa 2&1&#2&11 pa;e 15

Microprocessor Lab Manual INT 21 +ALL =EAD MO, =O!,AL LEA D-,MS'2 MO, A ,H INT 21 +ALL =EAD MO, +OL,AL LEA D-,MS'3 MO, A ,H INT 21 MO, A ,2 MO, D ,=O! MO, DL,+OL INT 1& MO, A ,I INT 21 MO, A ,4+ INT 21 =EAD/MO, A ,1 INT 21 AND AL, &) MO, BL,AL MO, A ,1 INT 21 AND AL,&) MO, A ,BL AAD =ET END Output: ENTE= =O! NO/ 12 ENTE= +OL NO/ 35 0=ESS AN% $E% TO STO0 U

2 rea4 6:e inpu6 ro8

2 rea4 6:e inpu6 col

2 5o>e 6:e cursor 6o 6:e en6ere4 ro8 an4 col

2 8ai6 3or a BeC 6o be presse4 6o eKi6

2 6o rea4 6:e inpu6 o3 68o nu5bers 2 an4 s6ore i6s eNui>alen6 4eci5al nu5ber in al

Dep6.o3 +SE, SSE,MuBBa

2&1&#2&11

pa;e 1J

Microprocessor Lab Manual

1Ca. "rogram to create a file &input file# an% to %elete an e)isting file . .MODEL SMALL .DATA MS'1 DB 1&,13,TENTE= )ILE NAME TO BE +=EATED/"T MS'2 DB 1&,13,TENTE= )ILE NAME TO BE DELETED/"T MS'3 DB T1/+=EATET,1&,13,T&/DELETE"T MS'4 DB 1&,13,TENTE= %O*= + OI+E/"T MS'5 DB TE==O="T )UNAME DB I& D*07&< .+ODE MO, A-,.DATA MO, DS,ALEA D-,MS'3 MO, A ,H INT 21 LEA D-,MS'4 Dep6.o3 +SE, SSE,MuBBa 2&1&#2&11 pa;e 1O

Microprocessor Lab Manual MO, A ,H INT 21 MO, A ,1 INT 21 +M0 AL,(1( 1G +U)ILE +M0 AL,(&( 1G DU)ILE E==O=/LEA D-,MS'5 MO, A ,H INT 21 MO, A ,4+ INT 21 +U)ILE/ LEA D-,MS'1 MO, A ,H INT 21 +ALL =EAD MO, +-,& MO, A ,3+ LEA D-,)UNAME INT 21 1+ E==O= MO, A ,4+ INT 21 DU)ILE/LEA D-,MS'2 MO, A ,H INT 21 +ALL =EAD LEA D-,)UNAME MO, A ,41 INT 21 1+ E==O= MO, A ,4+ INT 21 =EAD/MO, A ,1 LEA SI, )UNAME BA$/INT 21 +M0 AL,&D 1G DONE MO,@SIA,AL IN+ SI 1M0 BA$ DONE/=ET END Output: Dep6.o3 +SE, SSE,MuBBa 2&1&#2&11 pa;e 1I

2 3unc73+ <,6o crea6e a 3ile 8i6: 6:e na5e loa4e4 in D2 carrC 3la; is se6 i3 error 4urin; crea6ion

2 3unc741:<, 4ele6es a 3ile 8i6: 6:e na5e loa4e4 in D-

2 6o s6ore 6:e na5e o3 6:e 3ile

Microprocessor Lab Manual 1/+=EATE &/DELETE ENTE= %O*= + OI+E/1 ENTE= )ILE NAME TO BE +=EATED/ =a>i.as5

1b. 2ea% the status of eight input bits from the logic controller *nterface an% %isplay I??J it is e(en parity bits otherDise %isplay 33. lso %isplay number of 1Js in the input %ata. .MODEL SMALL .+ODE MO, D-,&E4&3 MO, AL,I2 O*T D-,AL MO, D-,&E4&1 IN AL,DMO, +L,I MO, A ,& N2/=O= AL,&1 1+ N1 DE+ +L 1NG N2 1M0 N-T N1/IN+ A DE+ +L Dep6.o3 +SE, SSE,MuBBa

2 6o se6 6:e con6rol 8or4 re;is6er 2 I2:# por6 A o?p an4 por6 B i?p

2 +L# s6ores 6:e no. o3 bi6s 2 i3 6:e bi6 in +) is 1 incre5en6 no. o3 1Vs 2 else 3in4 6:e neK6 bi6

2&1&#2&11

pa;e 1H

Microprocessor Lab Manual 1NG N2 N-T/MO, AL,A AND AL,1 +M0 AL,& 1G D)) MO, AL,& 1M0 NE-T D))/MO, AL,&)) NE-T /MO, D-,&E4&& O*T D-,AL MO, SI,4))) =ET2/MO, DI,&)))) =ET1/DE+ DI 1NG =ET1 DE+ SI 1NG =ET2 MO, AL,A MO, D-,&E4&& O*T D-,AL MO, A ,4+ INT 21 END

2 6o c:ecB i3 6:e no. o3 1Vs is e>en or o44 2 i3 e>en 4isplaC )) 2 else 4isplaC &&

2 4elaC 6o see clear o?p

2b. "erform the folloDing function using logic control *nterface i. B,- up-%oDn count .MODEL SMALL .+ODE MO, D-,&E4&3 MO, AL,I& O*T D-,AL MO, AL,& MO, D-,&E4&& *0/O*T D-,AL +ALL DELA% ADD AL,1 DAA +ALL STO0 +M0 AL,HH 1NE *0 DO!N/O*T D-,AL +ALL DELA% ADD AL,HH Dep6.o3 +SE, SSE,MuBBa

2 I& # all por6s o?p

2 con>er6 :eK no. 6o B+D 2 i3 no. L HH incre5en6 an4 4isplaC 2else 4ecre5en6 an4 4isplaC

2&1&#2&11

pa;e 2&

Microprocessor Lab Manual DAA +ALL STO0 +M0 AL,HH 1NE DO!N STO0/0*S AMO, A ,1 INT 1J 1NE E-IT 0O0 A=ET E-IT/MO, A ,4+ INT 21 DELA%/MO, SI,2))) =ET2/MO, DI,&)))) =ET1/DE+ DI 1NG =ET1 DE+ SI 1NG =ET2 =ET END ii. 2ing counter. .MODEL SMALL .+ODE MO, D-,&E4&3 MO, AL,I& O*T D-,AL MO, D-,&E4&& MO, AL,1 BA$/O*T D-,AL +ALL DELA% +ALL STO0 =OL AL,1 1M0 BA$ DELA%/MO, SI,&5))) =ET2/MO, DI,&)))) =ET1/DE+ DI 1NG =ET1 DE+ SI 1NG =ET2 =ET STO0/0*S AMO, A ,1 INT 1J 1NG -IT 0O0 A=ET Dep6.o3 +SE, SSE,MuBBa 2&1&#2&11 pa;e 21

Microprocessor Lab Manual -IT/ MO, A ,4+ INT 21 END

@b. 2ea% the status of tDo F-bits inputs&6 A =# from the !ogic ,ontroller *nterface an% %isplay 6K=. .MODEL SMALL .+ODE MO, D-,&E4&3 MO, AL,I2 O*T D-,AL MO, D-,&E4&1 IN AL,DMO, BL,AL MO, A ,I INT 21 MO, D-,&E4&1 IN AL,DM*L BL MO, D-,&E4&& O*T D-,AL +ALL DELA% MO, AL,A O*T D-,AL MO, A ,4+ Dep6.o3 +SE, SSE,MuBBa

2 6aBe inpu6 o3 -73irs6 no.< 3ro5 BeCboar4 2 8ai6 3or a BeCboar4 i?p 2 6aBe inpu6 o3 %73irs6 no.< 3ro5 BeCboar4 2 5ul6iplC 6:e nos. 7-W%< 2 4isplaC 6:e resul6an6

2&1&#2&11

pa;e 22

Microprocessor Lab Manual INT 21 DELA%/MO, SI,&5))) =ET2/MO, DI,&)))) =ET1/DE+ DI 1NG =ET1 DE+ SI 1NG =ET2 =ET END

>b.-isplay messages ?*2. an% 9.!" alternati(ely Dith flickering effects on a E-segment -isplay interface for a suitable perio% of time ..nsure a flashing rate that makes it easy to rea% both the message&.)aminer %oes not specify these %elay (alues nor it is necessary for the stu%ent to compute these (alues#. .MODEL SMALL .DATA DATA1 DB IJ ,&A) ,&+) ,IE DATA2 DB I+ ,&+O ,IJ:,IH .+ODE MO, A-,.DATA MO, DS,AMO, D-,&EI&3 MO, AL,I& O*T D-,AL BA$/ LEA SI,DATA1 +ALL DIS0LA% +ALL DELA% LEA SI,DATA2 +ALL DIS0LA% +ALL DELA% MO, A ,1 INT 1J: Dep6.o3 +SE, SSE,MuBBa

2 se>en#se;5en6 co4e 3or E,r,I,) respec6i>elC 2 se>en#se;5en6 co4e 3or 0,L,E, respec6i>elC

2loa4 6:e e33ec6i>e a44ress o3 eri3 24isplaC )IrE 24elaC 6o :a>e 3licBerin; e33ec6 2loa4 6:e e33ec6i>e a44ress o3 0LE 24isplaC EL0 24elaC 6o :a>e 3licBerin; e33ec6 2c:ecB 3or BeCs6roBe 6o s6op 4isplaC

2&1&#2&11

pa;e 23

Microprocessor Lab Manual 1G BA$ MO, A ,4+ INT 21 DIS0LA%/ MO, +-,&4 BA$2/ MO, BL,&I MO, AL,@SIA NE-T/ =OL AL,&1 MO, D-,&EI&1 O*T D-,AL 0*S AMO, D-,&EI&2 MO, AL,&)) O*T D-,AL MO, AL,&& O*T D-,AL DE+ BL 0O0 A1NG NE-T IN+ SI LOO0 BA$2 =ET DELA%/ MO, SI,2))) =E02/ MO, DI,&)))) =E01/ DE+ DI 1NG =E01 DE+ SI 1NG =E02 =ET END

2+L# no. o3 le66ers 6o be 4isplaCe4 2BL# no. o3 se;5en6 in eac: LED 2eac: se;5en6 is ou6pu66e4 a6 a 6i5e 3ro5 por6 B 2por6 + 6o ;enera6e a serial clocB pulse 8:ic: is nee4e4 6o 2 ou6pu6 e>erC bi6

Dep6.o3 +SE, SSE,MuBBa

2&1&#2&11

pa;e 24

Microprocessor Lab Manual

Cb. ssume any suitable message of 12 characters length an% %isplay it in the rolling fashion on a E-segment %isplay. *nterface for suitable perio% of time. .nsure a flashing rate that makes it easy to rea% both messages.&.)aminer %oes not specify these %elay (alues nor it is necessary for the stu%ent to compute these (alues#. .MODEL SMALL .DATA LIST DB &+O ,&A3 ,&AO ,II ,&A1 ,&AB ,&II ,&AB ,&II ,&HH ,&II ,&A1 2 lis6 se>en#se;5en6 co4e 3or L,o,+,A,D,n,A,n,i,r,S respec6i>elC .+ODE MO, A-,.DATA MO, DS,AMO, AL,I& MO, D-,&E4&3 O*T D-,AL =0T/MO, +-,12 2+-#no. o3 c:arac6ers 6o be 4isplaCe4 LEA SI,LIST N+/ MO, AL,@SIA +ALL DIS0 2DisplaC eac: c:arac6er +ALL DELA% 2;i>e a 4elaC 6o 4isplaC in rollin; 3as:ion +ALL STO0 2c:ecB 3or BeCboar4 s6roBe 6o s6op IN+ SI 2else 4isplaC neK6 c:ar LOO0 N+ 1M0 =0T STO0/MO, A ,1 Dep6.o3 +SE, SSE,MuBBa 2&1&#2&11 pa;e 25

Microprocessor Lab Manual INT 1J 1NG E-IT =ET E-IT/ MO, A ,4+ INT 21 DIS0/ MO, BL,&I NBIT/ =OL AL,1 MO, D-,&E4&1 O*T D-,AL 0*S AMO, D-,&E4&2 MO, AL,&)) O*T D-,AL MO, AL,&& O*T D-,AL 0O0 ADE+ BL 1NG NBIT =ET DELA%/ 0*S SI MO, SI,&4))) =ET2/ MO, DI,&)))) =ET1/ DE+ DI 1NG =ET1 DE+ SI 1NG =ET2 0O0 SI =ET END

Dep6.o3 +SE, SSE,MuBBa

2&1&#2&11

pa;e 2J

Microprocessor Lab Manual

6b.,on(ert a 16-bit binary (alue &assume to be an unsigne% integer# to B,- an% %isplay it from left to right an% right to left for specifie% number of times on a E-segment %isplay interface. .MODEL SMALL .DATA LIST DB &)) ,&)) ,&)) ,&)) ,M,M,M,M,M,&)) ,&)) ,&)) ,&)) 26o s6ore B+D eNui>alen6 O#se;5en6 co4e in place o3 M,M,M,M,M TABLE DB &+& ,&)H ,&A4 ,&B& ,HH ,H2 ,I2 ,&)I ,I& ,HI 2O#se;5en6 co4e 3ro5 & 6o H B+D DB 5 D*0 7M< 26o s6ore con>er6e4 B+D no. N*M D! &) 2binarC no. 6o be con>er6e4 .+ODE MO, A-,.DATA MO, DS,AMO, AL,I& MO, D-,&E4&3 O*T D-,AL LEA SI,B+D MO, A-, N*M 26o con>er6 1J#bi6 binarC no. 6o B+D MO, B-,1&&&& 24i>i4e 6:e no. bC 5ul6iples o3 1& an4 +ALL +ON, 2s6ore eac: no. in B+D arraC 6o ;e6 B+D no. MO, B-,1&&& +ALL +ON, MO, B-,1&& +ALL +ON, MO, B-,1& Dep6.o3 +SE, SSE,MuBBa 2&1&#2&11 pa;e 2O

Microprocessor Lab Manual +ALL +ON, MO, @SIA,DL LEA SI,B+D LEA DI,LIST9I LEA B-,TABLE MO, +-,5 NE-T/ MO, AL,@SIA -LAT 2 MO, @DIA,AL DE+ DI IN+ SI LOO0 NE-T 1M0 STA=T +ON,/ MO, D-,& DI, BMO, @SIA,AL MO, A-,DIN+ SI =ET STA=T/ MO, B ,1& LEA DI,LIST BA$1/ MO, SI,DI 0*S B+ALL DIS0 +ALL DELA% +ALL STO0 0O0 BIN+ DI DE+ B 1NG BA$1 MO, B ,H LEA DI,LIST9I BA$2/MO, SI,DI 0*S B+ALL DIS0 +ALL DELA% +ALL STO0 0O0 BDE+ DI DE+ B 1NG BA$2 1M0 STA=T STO0/ MO, A ,1 INT 1J 1NG E-IT =ET Dep6.o3 +SE, SSE,MuBBa

2+-D no. o3 B+D 4i;i6s 2copC 6:e eNui>alen6 O#se;5en6 6o 6:e LIST

2&1&#2&11

pa;e 2I

Microprocessor Lab Manual E-IT/ MO, A ,4+ INT 21 DIS0/ MO, +-,4 N+/ MO, BL,&I MO, AL,@SIA NB/ =OL AL,1 MO, D-,&E4&1 O*T D-,AL 0*S AMO, D-,&E4&2 MO, AL,&)) O*T D-,AL MO, AL,&& O*T D-,AL 0O0 ADE+ BL 1NG NB IN+ SI LOO0 N+ =ET DELA%/MO, B-,&2))) =ET2/ MO, +-,&)))) =ET1/ LOO0 =ET1 DE+ B1NG =ET2 =ET END

Dep6.o3 +SE, SSE,MuBBa

2&1&#2&11

pa;e 2H

Microprocessor Lab Manual

Eb.-ri(e a stepper motor interface to rotate the motor in clock Dise %irection by + steps.&+ is specifie% by the e)aminer#.*ntro%uce a %elay betDeen successi(e steps.& ny arbitrary (alue for the may be assume% by the stu%ent#. .MODEL SMALL .+ODE MO, +-,3& MO, D-,&E4&3 MO, AL,I& O*T D-,AL MO, D-,&E4&& MO, AL,II =E01/O*T D-,AL +ALL DELA% =O= AL,1 DE+ +1NG =E01 MO, A ,4+ INT 21 DELA%/MO, SI,2))) BA+$2/MO, DI,&)))) BA+$1/DE+ DI 1NG BA+$1 DE+ SI 1NG BA+$2 =ET END

2+-#no. o3 s6eps

26o ener;iPe 6:e nor6: pole an4 sou6: pole o3 6:e 5o6or 21& && 1& && A Q + poles are ener;iPe4 i.e, 1& 2B Q D are no6 ener;iPe4 2 ;i>es clocB8ise 5o6ion

Dep6.o3 +SE, SSE,MuBBa

2&1&#2&11

pa;e 3&

Microprocessor Lab Manual

Fb.-ri(e a stepper motor interface to rotate the motor in nti-clockDise %irection by + steps.&+ is specifie% by the e)aminer#. *ntro%uce suitable %elay betDeen successi(e steps.& ny arbitrary (alue for the %elay may be assume% by the stu%ent#. .MODEL SMALL .+ODE MO, +-,2& MO, D-,&E4&3 MO, AL,I& O*T D-,AL MO, D-,&E4&& MO, AL,II =E01/O*T D-,AL +ALL DELA% =OL AL,1 DE+ +1NG =E01 MO, A ,4+ INT 21 DELA%/MO, SI,2))) BA+$2/MO, DI,&)))) BA+$1/DE+ DI 1NG BA+$1 DE+ SI 1NG BA+$2 =ET END

2 ;i>es an6i#clocB8ise 5o6ion

Dep6.o3 +SE, SSE,MuBBa

2&1&#2&11

pa;e 31

Microprocessor Lab Manual

Gb.-ri(e a stepper motor interface to rotate the motor by + steps left %irection an% + steps right %irection &+ is specifie% by the e)aminer#.*ntro%uce a suitable %elay betDeen successi(e steps.& ny arbitrary (alue for the %elay may be assume% by the stu%ent#. .MODEL SMALL .+ODE MO, +-,3& MO, D-,&E4&3 MO, AL,I& O*T D-,AL MO, D-,&E4&& MO, AL,II =E01/O*T D-,AL +ALL DELA% =O= AL,1 DE+ +1NG =E01 MO, +-,3& =E02/O*T D-,AL +ALL DELA% =OL AL,1 DE+ +1NG =E02 MO, A ,4+ INT 21 DELA%/ MO, SI,&))) BA+$2/ MO, DI,&)))) BA+$1/ DE+ DI 1NG BA+$1 DE+ SI 1NG BA+$2 =ET Dep6.o3 +SE, SSE,MuBBa

2 ;i>es clocB8ise 5o6ion

2 ;i>es an6i#clocB8ise 5o6ion

2&1&#2&11

pa;e 32

Microprocessor Lab Manual END

13b.Scan F)@ keypa% for keypa% closure an% to store the co%e of the key presse% in a memory location or %isplay it on the screen. lso %isplay roD an% column numbers of the key presse%. .MODEL SMALL .DATA $E%S DB (&12345JOIHAB+DE)' I1$LMN( 2arraC 3or 24 BeCs o3 BeCpa4 $E% DB M MS'1 DB 1&,13, (T E =O! NO IS D( =O! DB M,13,1&,("( MS'2 DB (T E +OL NO IS D( +OL DB M,("( .+ODE MO, A-,.DATA MO, DS,AMO, D-,&E4&3 MO, AL,H& O*T D-,AL =E01/MO, D-,&E4&2 26o ac6i>a6e pc& ie, 6o c:ecB ro81 MO, AL,&1 O*T D-,AL MO, D-,&E4&& 26aBe inpu6 usin; por6 B IN AL,D+M0 AL,&& 2i3 BeC presse4 in ro81 1NG )= 2Eu5p 6o 3irs6 ro8 MO, D-,&E4&2 2else ac6i>a6e pc1 ie, 6o c:ecB ro82 MO, AL,&2 O*T D-,AL MO, D-,&E4&& 26aBe inpu6 usin; por6 B IN AL,D+M0 AL,&& 2i3 BeC presse4 in ro82 1NG S= 2Eu5p 6o secon4 ro8 MO, D-,&E4&2 2 else ac6i>a6e pc2 ie, 6o c:ecB ro83 Dep6.o3 +SE, SSE,MuBBa 2&1&#2&11 pa;e 33

Microprocessor Lab Manual MO, AL,&4 O*T D-,AL MO, D-,&E4&& IN AL,D+M0 AL,&& 1NG T= 1M0 =E01 )=/+ALL DELA% LEA SI,$E%S MO, =O!,31 MO, +L,3& NE-T1/ IN+ +L S = AL,1 1+ DIS0 IN+ SI 1M0 NE-T1 S=/ +ALL DELA% LEA SI,$E%S ADD SI,&I MO, =O!,32 MO, +L,3& NE-T2/ IN+ +L S = AL,1 1+ DIS0 IN+ SI 1M0 NE-T2 T=/ +ALL DELA% LEA SI,$E%S ADD SI,1& MO, =O!,33 MO, +L,3& NE-T3/IN+ +L S = AL,1 1+ DIS0 IN+ SI 1M0 NE-T3 DIS0/ MO, DL,@SIA MO, A ,&2 INT 21 LEA D-,MS'1 MO, A ,&H INT 21 MO, +OL,+L LEA D-,MS'2 INT 21 1M0 E-IT Dep6.o3 +SE, SSE,MuBBa

26aBe inpu6 usin; por6 B 2i3 BeC presse4 in ro83 2Eu5p 6o 6:ir4 ro8 2repea6 6:e c:ecB 6ill anC BeC is presse4 231Dascii >alue 3or 1 ie, 3irs6 ro8 2clDcolu5n >alue 2c:ecB 3or 6:e presse4 BeC 8:ic: 8ill be 1

2secon4 ro8 s6ar6s 3ro5 I6: BeC 232Dascii >alue 3or 2 ie, secon4 ro8

2secon4 ro8 s6ar6s 3ro5 1J6: BeC 233Dascii >alue 3or 3 ie, 6:ir4 ro8

26o 4isplaC 6:e BeC presse4 26o 4isplaC 6:e ro8 no. 26o 4isplaC 6:e col no.

2&1&#2&11

pa;e 34

Microprocessor Lab Manual DELA%/ MO, SI,2))) BA$2/ MO, DI,&)))) BA$1/ DE+ DI 1NG BA$1 DE+ SI 1NG BA$2 =ET E-IT/ MO, A ,4+ INT 21 END 11b.Scan a @)F keypa% for key closure an% simulate -- an% S'B$2 ,$ operations as in a calculator .&!imitation: it is a single %igit calculator#. .MODEL SMALL .DATA )$ DB 4 D*07M< 2arraC 6o s6ore 6:e eKpression $E% DB M E=MS' DB 1&,13,TE==O=S"T E-0N DB 1&,13,TENTE= E-0=ESSION/"T NANS DB & .+ODE MO, A-,.DATA MO, DS,AMO, D-,&E4&3 MO, AL,H& O*T D-,AL LEA D-,E-0N MO, A ,H INT 21 MO, DI,4 2eKpression con6ains 4 c:ar, e;. 59JD LEA SI,)$ BA$/+ALL =EAD 2rea4 6:e inpu6 +ALL DELA% MO, AL,$E% 2s6ore 6:e rea4 inpu6 in )$ as eKpression MO, @SIA,AL IN+ SI DE+ DI 1NG BA$ +M0 )$@1A,&B 2co5pare 6:e secon4 c:ar 8i6: X9V 1G ADDN 2i3 eNual Eu5p 6o a44i6ion +M0 )$@1A,&+ 2co5pare 6:e secon4 c:ar 8i6: X#X 1G S*BN 2i3 eNual Eu5p 6o sub6rac6ion 1M0 E== 2i3 opera6or is nei6:er o3 6:e5 Eu5p 6o error MO, A ,4+ INT 21 Dep6.o3 +SE, SSE,MuBBa 2&1&#2&11 pa;e 35

Microprocessor Lab Manual ADDN/MO, AL,)$@&A ADD AL,)$@2A +M0 )$@3A,13 1NG E== +ALL DIS0 MO, A ,4+ INT 21 E==/LEA D-,E=MS' MO, A ,H INT 21 MO, A ,4+ INT 21 S*BN/MO, AL,)$@&A S*B AL,)$@2A 1N+ 0OSITI,E NE' AL MO, NANS,1 0OSITI,E/ +M0 )$@3A,13 1NG E== +ALL DIS0 MO, A ,4+ INT 21 =EAD/ MO, AL,I& MO, $E%,& MO, BL,3 NE-T=O!/=OL AL,1 MO, B ,AL MO, D-,&E4&2 O*T D-,AL MO, +L,I MO, D-,&E4&& IN AL,DNE-T+OL/ =O= AL,1 1+ $E%+ODE IN+ $E% DE+ +L 1NG NE-T+OL MO, AL,B DE+ BL 1NG NE-T=O! 1M0 =EAD $E%+ODE/ MO, DL,$E% +M0 DL,&B 1NG NE-T MO, DL,(9( MO, A ,2 Dep6.o3 +SE, SSE,MuBBa 26o a44 )$@&A an4 )$@2A 2co5pare 6:e 6:ir4 c:ar 8i6: XDV 2i3 no6 eNual Eu5p 6o error 24isplaC 6:e ans8er 24isplaC error

26o sub6rac6 )$@&A an4 )$@2A 2i3 6:e resul6 is a posi6i>e no. Eu5p 6o posi6i>e 2else 3in4 68oVs co5ple5en6 2nansDne;a6i>e ans8erD1, ie, 6rue 2co5pare 6:e 6:ir4 c:ar 8i6: XDV 24isplaC 6:e ans8er

2blDcoun6 3or 3 ro8s 2alD&1, c:ecB 3or ro81 2 Enable 0+&,0+1 an4 0+2 lines 2 =ea4 BeC presse4 3ro5 0or6 A 26o 3in4 6:e BeC presse4 2S6ores 6:e >alue o3 BeC bein; presse4

2 i3 no BeC presse4 ;o 6o neK6 ro8 26o co5pare i3 6:e BeC presse4 is X9V

2&1&#2&11

pa;e 3J

Microprocessor Lab Manual INT 21 =ET NE-T/+M0 DL,&+ 1NG NE-T1 MO, DL,(#( MO, A ,2 INT 21 =ET NE-T1/ +M0 DL,13 1NG NE-T2 MO, DL,(D( MO, A ,2 INT 21 =ET NE-T2/ ADD DL,3& MO, A ,2 INT 21 =ET DIS0/ +M0 NANS,1 1NG S$I0 0*S AMO, DL,(#( MO, A ,2 INT 21 0O0 AS$I0/AAM ADD A-,3&3& MO, B-,AMO, A ,2 MO, DL,B INT 21 MO, DL,BL INT 21 =ET DELA%/MO, B-,2))) B2/ MO, +-,&)))) B1/ LOO0 B1 DE+ B1NG B2 =ET END

26o co5pare i3 6:e BeC presse4 is X#X

26o co5pare i3 6:e BeC presse4 is XDV

2 else 6:e BeC presse4 is a 4i;i6

2i3 ne;a6i>e ans8er is 3alse ie, & Eu5p 6o sBip 2else a44 X#X sC5bol be3ore 6:e no. an4 4isplaC

Dep6.o3 +SE, SSE,MuBBa

2&1&#2&11

pa;e 3O

Microprocessor Lab Manual

12b.Henarate a sine Da(e using the - , interface&$he output of the - , is to be %isplaye% on a ,2O#. .MODEL SMALL .DATA A DB &&,22,43,J3,I1,HO,1&H,11H,125,12O 2 poin6s 6o plo6 .+ODE MO, A-,.DATA MO, DS,AMO, AL,I& MO, D-,&E4&3 O*T D-,AL 2 MO, SI,&)))) 2SI#no. o3 sine 8a>e3or5s MO, B-,& 2B-#coun6 no. o3 poin6s MO, D-,&E4&1 2por6B as o?p por6 B1/MO, AL,A@B-A ADD AL,12O 2&#255 le>els possible. Me4ian is 12O O*T D-,AL IN+ B+M0 B-,H 1B B1 B2/MO, AL,A@B-A ADD AL,12O O*T D-,AL DE+ B+M0 B-,& 1NG B2 B3/MO, AL,A@B-A MO, +L,12O S*B +L,AL MO, AL,+L O*T D-,AL IN+ B+M0 B-,H 1B B3 B4/ MO, AL,A@B-A MO, +L,12O S*B +L,AL Dep6.o3 +SE, SSE,MuBBa 2&1&#2&11 pa;e 3I

Microprocessor Lab Manual MO, AL,+L O*T D-,AL DE+ B+M0 B-,& 1NG B4 DE+ SI 1NG B1 MO, A ,4+ INT 21 END

Dep6.o3 +SE, SSE,MuBBa

2&1&#2&11

pa;e 3H

Microprocessor Lab Manual

1@b.Henerate a 9alf 2ectifie% Sine Da(e form using the - , interface.&$he output of the - , is to %isplay on a ,2O#. .MODEL SMALL .DATA A DB &&,22,43,J3,I1,HO,1&H,11H,125,12O .+ODE MO, A-,.DATA MO, DS,AMO, AL,I& MO, D-,&E4&3 O*T D-,AL 2MO, +-,&)))) MO, B-,& MO, D-,&E4&& 2por6A as o?p por6 B1/ MO, AL,A@B-A ADD AL,12O O*T D-,AL IN+ B+M0 B-,H 1B B1 B2/ MO, AL,A@B-A ADD AL,12O O*T D-,AL DE+ B+M0 B-,& 1NG B2 MO, SI,14 =0T/ MO, AL,12O 2loop 3or :al3 rec6i3ie4 8a>e O*T D-,AL DE+ SI 1NG =0T 1M0 B1 E-IT/ MO, A ,4+ INT 21 END

Dep6.o3 +SE, SSE,MuBBa

2&1&#2&11

pa;e 4&

Microprocessor Lab Manual

1>b. Henerate a ?ully 2ectifie% Sine Da(e from using the - , interface &$he ouput of the - , is to be %isplaye% on a ,2O#. .MODEL SMALL .DATA A DB &&,22,43,J4,I2,HO,11&,11H,125,12O .+ODE MO, A-,.DATA MO, DS,AMO, AL,I& MO, D-,&E4&3 O*T D-,AL 2 MO, +-,&)))) 2+-#no. o3 8a>e3or5s MO, B-,& MO, D-,&E4&1 B1/MO, AL,A@B-A ADD AL,12O O*T D-,AL IN+ B+M0 B-,H 1B B1 B2/MO, AL,A@B-A ADD AL,12I O*T D-,AL DE+ B+M0 B-,& 1NG B2 1M0 B1 MO, A ,4+ INT 21 END

Dep6.o3 +SE, SSE,MuBBa

2&1&#2&11

pa;e 41

Microprocessor Lab Manual

1Cb.-ri(e .le(ator *nterface in the folloDing Day: i. *nitially the ele(ator shoul% be in the groun% floor7 Dith all reBuests in O?? state. ii. When a reBuest is ma%e from a floor7 the ele(ator shoul% mo(e to that floor7 Dait there for a couple of secon%s7 an% then come %oDn to groun% floor an% stop. *f some reBuests occur %uring going up or coming %oDn they shoul% be ignore%. .MODEL SMALL .+ODE MO, D-,&E4&3 MO, AL,I2 O*T D-,AL BA+/ MO, A ,&1 INT 1J 1NE E-IT MO, AL,& MO, D-,&E4&& O*T D-,AL MO, AL,&)& O*T D-,AL LOO01/+ALL =R+ E 1G LOO01 S = AL,1 1N+ 'ND S = AL,1 1N+ )) S = AL,1 1N+ S) 1M0 T) =R+ E/MO, D-,&E4&1 IN AL,DO= AL,&)& +M0 AL,&)) =ET 'ND/+ALL DELA% +ALL DELA% MO, AL,&)& 1M0 BA+ ))/MO, AL,&)& MO, +L,&3 +ALL M*0 +ALL DELA% +ALL DELA% Dep6.o3 +SE, SSE,MuBBa

2por6 B as i?p por6 2i3 a BeC is presse4 3ro5 6:e BeCboar4 6:en eKi6

2c:ecB i3 6:ere is a reNues6 2i3 no reNues6 8ai6 2c:ecB 3or ;n4 3loor 2i3 eNual ;o 6o ;n4 2c:ecB 3or 1s6 3loor 2i3 eNual ;o 6o )) 2c:ecB 3or 2n4 3loor 2i3 eNual ;o 6o 2n4 3loor 2else ;o 6o 3r4 3loor 26aBe 6:e i?p 3ro5 6:e in6er3ace 2co5pare i3 no BeC is presse4 2s6aC in ;roun4 3loor 3or 3e8 secs 2clear 6:e i?p 4a6a an4 Eu5p 3or neK6 reNues6 2clear 6:e i?p 4a6a 2clDcoun6 3or no. o3 LEDVs,3or 3irs6 3loor LEDVsD3 26o 5o>e up8ar4s

2&1&#2&11

pa;e 42

Microprocessor Lab Manual MO, +L,&3 +ALL DO!N 1M0 BA+ S)/MO, AL,&)& MO, +L,&J +ALL M*0 +ALL DELA% +ALL DELA% MO, +L,&J +ALL 'OD! 1M0 BA+ T)/MO, AL,&)& MO, +L,&H +ALL M*0 +ALL DELA% +ALL DELA% MO, +L,&H +ALL 'OD! 1M0 BA+ E-IT/MO, A ,4+ INT 21 M*0/MO, D-,&E4&& *0/IN+ AL +ALL DELA% O*T D-,AL LOO0 *0 =ET 'OD!/MO, D-,&E4&& DO!N/DE+ AL +ALL DELA% O*T D-,AL LOO0 DO!N =ET DELA%/MO, SI,2))) =0T2/MO, DI,&)))) =0T1/DE+ DI 1NG =0T1 DE+ SI 1NG =0T2 =ET END 26o 5o>e 4o8n8ar4s 2;o 6o bac 3or neK6 reNues6 2clDcoun6 3or no. o3 LEDVs, 3or secon4 3loor LEDVsDJ

2clDcoun6 3or no. o3 LEDVs, 3or 6:ir4 3loor LEDVDH

2sen4 6:e o?p 6o por6 A 2incre5en6 6:e >alue o3 AL 6o 5o>e up 2loop 6ill +LD& 2sen4 6:e o?p 6o por6 A 24ecre5en6 6:e >alue o3 AL 6o co5e 4o8n 2loop 6ill +LD&

Dep6.o3 +SE, SSE,MuBBa

2&1&#2&11

pa;e 43