Sie sind auf Seite 1von 139

SUDHARSAN ENGINEERING COLLEGE Sathiyamangalam-Pudukkottai

EC2308: MICROPROCESSORS & MICROCONTROLLERS LAB MANUAL V SEM ECE

1. INTRODUCTION TO 8085 INTEL 8085 is one of the most popular 8-bit mi ropro essor apable of addressing !" #$ of memory and its ar hite ture is simple% The de&i e has "0 pins' re(uires )5 * po+er supply and an operate +ith ,-./ single phase lo k% ALU (Ari !"# i$ L%&i$ U'i (: The 80850 has a simple 8-bit 0L1 and it +orks in oordination +ith the a umulator' temporary registers' 5 flags and arithmeti and logi ir uits% 0L1 has the apability of performing se&eral mathemati al and logi al operations% The temporary registers are used to hold the data during an arithmeti and logi operation% The result is stored in the a umulator and the flags are set or reset a ording to the result of the operation% The flags are affe ted by the arithmeti and logi operation% They are as follo+s2 Sign flag 0fter the e3e ution of the arithmeti - logi operation if the bit 45 of the result is 6' the sign flag is set% This flag is used +ith signed numbers% If it is 6' it is a negati&e number and if it is 0' it is a positi&e number% 7ero flag

The /ero flag is set if the 0L1 operation results in /ero% This flag is modified by the result in the a umulator as +ell as in other registers% 0u3illary arry flag In an arithmeti au3illary flag is set% Parity flag 0fter arithmeti 9 logi operation' if the result has an e&en number of 6:s the flag is set% If it has odd number of 6:s it is reset% ;arry flag If an arithmeti operation results in a arry' the arry flag is set% The arry flag also ser&es as a borro+ flag for subtra tion% Ti"i'& )'* $%' r%+ ,'i This unit syn hroni/es all the mi ropro essor operation +ith a lo k and generates the ontrol signals ne essary for ommuni ation bet+een the mi ropro essor and peripherals% The ontrol signals <4 =read> and ?< =+rite> indi ate the a&ailability of data on the data bus% operation +hen a arry is generated by digit 4, and passed on to 4"' the

I'- r,$ i%' r#&i- #r )'* *#$%*#r The instru tion register and de oder are part of the 0L1% ?hen an instru tion is fet hed from memory it is loaded in the instru tion register% The de oder de odes the instru tion and establishes the se(uen e of e&ents to follo+% R#&i- #r )rr). The 8085 has si3 general purpose registers to store 8-bit data during program e3e ution% These registers are identified as $' ;' 4' E' . and L% they an be ombined as $;' 4E and .L to perform 6!-bit operation% A$$,",+) %r 0 umulator is an 8-bit register that is part of the 0L1% This register is used to store 8-bit data and to perform arithmeti and logi operation% The result of an operation is stored in the a umulator% Pr%&r)" $%,' #r The program ounter is a 6!-bit register used to point to the memory address of the ne3t instru tion to be e3e uted% S )$/ 0%i' #r

"

It is a 6!-bit register +hi h points to the memory lo ation in <@? memory' alled the Sta k%

C%"",'i$) i%' +i'#8085 mi ropro essor performs data transfer operations using three ommuni ation lines alled buses% They are address bus' data bus and ontrol bus% 0ddress bus 9 it is a group of 6!-bit lines generally identified as 00 9 065% The address bus is unidire tional i%e%' the bits flo+ in one dire tion from mi ropro essor to the peripheral de&i es% It is apable of addressing 8 6! memory lo ations% 4ata bus 9 it is a group of 8 lines used for data flo+ and it is bidire tional% The data ranges from 00 9 AA% ;ontrol bus 9 it onsist of &arious single lines that arry syn hroni/ing signals% The mi ropro essor uses su h signals for timing purpose%

2(A(. 8 BIT DATA ADDITION AIM: To add t+o 8 bit numbers stored at onse uti&e memory lo ations% ALGORITHM: 6% Initiali/e memory pointer to data lo ation%
!

8% Bet the first number from memory in a umulator% ,% Bet the se ond number and add it to the a umulator% "% Store the ans+er at another memory lo ation% RESULT: Thus the 8 bit numbers stored at "500 C"506 are added and the result stored at "508 C "50,%

1LO2 CHART:
ST0<T

F;G

00.

F.LG

"500.

F0G

F-G

F.LGF.LG)6

F0GF0G)F-G

Is there a ;arry H

F;GF;G)6

ND EES

F.LGF.LG)6

F-G

F0G

F.LGF.LG)6

F-G

F;G

STDP

PROGRAM: ADDRESS OPCODE LABEL MNEMONICS OPERAND COMMENT "600 ST0<T -*I ;' 00 ;lear ; reg% "606 "608 LII .' "500 Initiali/e .L reg% to "60, "500 "60" "605 -D* 0' Transfer first data to a umulator "60! INI . In rement .L reg% to point ne3t memory Lo ation% "605 044 0dd first number to a % ;ontent% "608 JN; L6 Jump to lo ation if "60K

"600 "60$ "60; L6 IN< INI ; .

"604

-D*

-' 0

"60E

INI

"60A "660

-D* .LT

-' ;

result does not yield arry% In rement ; reg% In rement .L reg% to point ne3t memory Lo ation% Transfer the result from a % to memory% In rement .L reg% to point ne3t memory Lo ation% -o&e arry to memory Stop the program

OBSERVATION: INP1T "500 "506 D1TP1T "508 "50,

60

2(B(. 8 BIT DATA SUBTRACTION AIM: To Subtra t t+o 8 bit numbers stored at onse uti&e memory lo ations% ALGORITHM: 6% 8% ,% "% Initiali/e memory pointer to data lo ation% Bet the first number from memory in a umulator% Bet the se ond number and subtra t from the a umulator% If the result yields a borro+' the ontent of the a % is omplemented and 06. is added to it =8:s omplement>% 0 register is leared and the ontent of that reg% is in remented in ase there is a borro+% If there is no borro+ the ontent of the a % is dire tly taken as the result% 5% Store the ans+er at ne3t memory lo ation% RESULT: Thus the 8 bit numbers stored at "500 C"506 are subtra ted and the result stored at "508 C "50,%

66

ST0<T

F;G

00.

F.LG "500.

F0G

F-G

F.LGF.LG)6

F0GF0G-F-G

1LO2 CHART:
Is there a $orro+ H ;omplement F0G 0dd 06. to F0G F;GF;G)6

F.LGF.LG)6

F-G

F0G

F.LGF.LG)6

F-G

F;G

68
STDP

ND

EES

PROGRAM: ADDRESS OPCODE LABEL MNEMONICS OPERAND COMMENT "600 ST0<T -*I ;' 00 ;lear ; reg%
6,

"608 "608 "60, "60" "605 "60!

LII -D* INI

.' "500 0' .

"605 "608 "60K "600 "60$ "60; "604 "60E "60A L6

S1$ JN;

L6

IN< ;-0 04I INI

06. .

"660

-D*

-' 0
6"

Initiali/e .L reg% to "500 Transfer first data to a umulator In rement .L reg% to point ne3t mem% Lo ation% Subtra t first number from a % ;ontent% Jump to lo ation if result does not yield borro+% In rement ; reg% ;omplement the 0 % ontent 0dd 06. to ontent of a % In rement .L reg% to point ne3t mem% Lo ation% Transfer the

"666

INI

"668 "66, OBSERVATION: INP1T "500 "506

-D* .LT

-' ;

result from a % to memory% In rement .L reg% to point ne3t mem% Lo ation% -o&e arry to mem% Stop the program

D1TP1T "508 "50,

65

3(A(. 8 BIT DATA MULTIPLICATION AIM: To multiply t+o 8 bit numbers stored at onse uti&e memory lo ations and store the result in memory% ALGORITHM: LOGIC: -ultipli ation an be done by repeated addition% 6% 8% ,% "% 5% !% 5% 8% Initiali/e memory pointer to data lo ation% -o&e multipli and to a register% -o&e the multiplier to another register% ;lear the a umulator% 0dd multipli and to a umulator 4e rement multiplier <epeat step 5 till multiplier omes to /ero% The result' +hi h is in the a umulator' is stored in a memory lo ation%

RESULT: Thus the 8-bit multipli ation +as done in 8085p using repeated addition method%

6!

1LO2 CHART:
ST0<T

F.LG "500

$ -

F.LG F.LG)6

0 00

; 00

65

F0G F0G )F-G

Is there any arry

ND

EES
; ;)6

$ $-6

ND IS
$L0

EES
0 0

F.LGF.LG)6

F-G

F0G

F.LGF.LG)6

F-G

F;G

STDP

68

6K

PROGRAM: ADDRE OPCO SS DE "600 "606 "608 "60, "60" "605 "60! "605 "608 "60K "600 "60$ "60; "604 "60E "60A "660 "666 "668 "66, LABE MNEMON OPERA COMMENT L ICS ND ST0<T LII .' "500 Initiali/e .L reg% to "500 -D* $' Transfer first data to reg% $ INI . In rement .L reg% to point ne3t mem% Lo ation% -*I 0' 00. ;lear the a % -*I ;' 00. ;lear ; reg for arry 0dd multipli and multiplier times% Jump to NEIT if there is no arry In rement ; reg 4e rement $ reg Jump to L6 if $ is not /ero% In rement .L reg% to point ne3t mem% Lo ation% Transfer the result from a %
80

L6

044 JN; IN< 4;< JN7 INI -D*

NEIT ; $ L6 . -' 0

NEIT

"66" "665 "66! OBSERVATION: INP1T "500 "506 AIM:

INI -D* .LT

. -' ;

to memory% In rement .L reg% to point ne3t mem% Lo ation% Transfer the result from ; reg% to memory% Stop the program

D1TP1T "508 "50, 3(B(. 8 BIT DIVISION

To di&ide t+o 8-bit numbers and store the result in memory% ALGORITHM: LOGIC: 4i&ision is done using the method <epeated subtra tion% 6% Load 4i&isor and 4i&idend 8% Subtra t di&isor from di&idend ,% ;ount the number of times of subtra tion +hi h e(uals the (uotient "% Stop subtra tion +hen the di&idend is less than the di&isor %The di&idend no+ be omes the remainder% Dther+ise go to step 8% 5% stop the program e3e ution%

86

RESULT: Thus an 0LP +as +ritten for 8-bit di&ision using repeated ST0<T subtra tion method and e3e uted using 8085 p kits
$ 00 F.LG "500 0 F.LG F.LG)6 - 0--

F$G F$G )6

IS 0M0 0 0) -

$ $-6

F.LGF.LG)6

1LO2CHART:

F-G

F0G

F.LGF.LG)6

F-G

F$G

88
STDP

ND EES

8,

PROGRAM: ADDRE OPCO SS DE "600 "606 "608 "60, "60" "605 "60! "605 "608 "60K "600 "60$ "60; "604 "60E LDDP LABE L MNE MONI CS -*I LII OPE RAN D $'00 .'"50 0 0'. $ LDDP $ . COMMENTS ;lear $ reg for (uotient Initiali/e .L reg% to "500. Transfer di&idend to a % In rement .L reg% to point ne3t mem% Lo ation% Subtra t di&isor from di&idend In rement $ reg Jump to LDDP if result does not yield borro+ 0dd di&isor to a % 4e rement $ reg In rement .L reg% to point ne3t mem% Lo ation%
8"

-D* INI S1$ IN< JN; 044 4;< INI

"60A "660 "666 "668 OBSERVATION: S.NO 6 8

-D* INI -D* .LT

-'0 . -'$

Transfer the remainder from a % to memory% In rement .L reg% to point ne3t mem% Lo ation% Transfer the (uotient from $ reg% to memory% Stop the program

INPUT 044<ESS 40T0 "500 "506 "500 "506

OUTPUT 044<ESS 40T0 "508 "50, "508 "50,

85

3(A(. 14 BIT DATA ADDITION AIM: To add t+o 6!-bit numbers stored at onse uti&e memory lo ations% ALGORITHM: 6% Initiali/e memory pointer to data lo ation% 8% Bet the first number from memory and store in <egister pair% ,% Bet the se ond number in memory and add it to the <egister pair% "% Store the sum C arry in separate memory lo ations% RESULT: Thus an 0LP program for 6!-bit addition +as +ritten and e3e uted in 8085p using spe ial instru tions%

8!

85

1LO2 CHART:
ST0<T

FLG F.G F4EG

F8050 .G F8056 .G F.LG

FLG F.G

F8058.G F805,.G

F0G00.

F.LGF.LG)F4EG

Is there a ;arryH

F0GF0G)6

F805"GF LG

ND

F8055G F.G

EES
F805!G F0G

STDP

88

PROGRAM: ADDRESS OPCODE LABEL MNEMONICS OPERAND COMMENT 8000 ST0<T L.L4 8050. Load the augend in 8006 4E pair 8008 through .L 800, I;.B pair% 800" L.L4 8058. Load the addend in 8005 .L pair% 800! 8005 -*I 0' 00. Initiali/e reg% 0 for arry 8008 800K 404 4 0dd the ontents of .L Pair +ith that of 4E pair% 8000 JN; LDDP If there is no arry' go to 800$

8K

800;

8004 800E 800A 8060 8066 8068 806, LDDP

IN< S.L4

0 805".

ST0

805!.

806"

.LT

the instru tion labeled LDDP% Dther+ise in rement reg% 0 Store the ontent of .L Pair in 805".=LS$ of sum> Store the arry in 805!. through 0 % =-S$ of sum>% Stop the program%

OBSERVATION: INP1T 044< 40T0 ESS 8050. 8056. 8058. 805,. D1TP1T 044<E 40T0 SS 805". 8055. 805!.

,0

3(B(. 14 BIT DATA SUBTRACTION AIM: To subtra t t+o 6!-bit numbers stored at onse uti&e memory lo ations% ALGORITHM: 6% Initiali/e memory pointer to data lo ation% 8% Bet the subtrahend from memory and transfer it to register pair% ,% Bet the minuend from memory and store it in another register pair% "% Subtra t subtrahend from minuend% 5% Store the differen e and borro+ in different memory lo ations% RESULT: Thus an 0LP program for subtra ting t+o 6!-bit numbers +as +ritten and e3e uted%

,6

1LO2 CHART:
ST0<T

FLG F.G

F8050 .G F8056 .G

F4EG

F.LG

FLG F.G

F8058.G F805,.G

,8

F.LGF.LG-F4EG

Is there a borro+H

ND
F;GF;G)6

EES
F805"GF LG

F8055G F.G

F805!G

F;G

STDP

PROGRAM: ADDRESS OPCODE LABEL MNEMO OPER COMMENTS NICS AND 8000 ST0<T -*I ;' 00
,,

8006 8008 800, 800" 8005 800! 8005 8008 800K 8000 L.L4 I;.B L.L4 -D* S1$

800$ 800; 8004

-D* -D* S$$

800E 800A 8060

-D* S.L4

Initiali/e ; reg% 8050. Load the subtrahend in 4E reg% Pair through .L reg% pair% 8058. Load the minuend in .L reg% Pair% 0' L -o&e the ontent of reg% L to 0 % E Subtra t the ontent of reg% E from that of a % L' 0 -o&e the ontent of 0 % to reg% L 0' . -o&e the ontent of reg% . to 0 % 4 Subtra t ontent of reg% 4 +ith that of 0 % .' 0 Transfer ontent of a % to reg% . 805". Store the ontent of .L

,"

8066

8068 806, 806" 8065 806! 8065 8068 806K 8060 NEIT

JN;

IN< -D* ST0

.LT

pair in memory lo ation 850".% NEIT If there is borro+' go to the instru tion labeled NEIT% ; In rement reg% ; 0' ; Transfer the ontent of reg% ; to 0 % 805!. Store the ontent of a % to the memory lo ation 850!. Stop the program e3e ution%

OBSERVATION: INP1T D1TP1T 044< 40T0 044<E 40T0 ESS SS 8050. 805". 8056. 8055. 8058. 805!. 805,. 5(A(. 14 BIT MULTIPLICATION AIM:
,5

To multiply t+o 6! bit numbers and store the result in memory% ALGORITHM: 6% 8% ,% "% Bet the multiplier and multipli and% Initiali/e a register to store partial produ t% 0dd multipli and' multiplier times% Store the result in onse uti&e memory lo ations%

RESULT: Thus the 6!-bit multipli ation +as done in 8085p using repeated addition method%

,!

,5

1LO2CHART:
ST0<T L . F8050G F8056G

SP .L

L .

F8058G F805,G

4E

.L

.L0000 $;0000

.L.L)SP

Is ;arry flag setH

$;$;)6

4E4E)6 NO

Is 7ero flag setH

5ES

,8

NO 5ES
0

F805"G F8055G

L .

F805!G F8055G

; $

STDP

,K

"0

ADDR OPCO LAB E D S E S

MNE

8000 8006 8008 800, 800" 8005 800! 8005 8008

ST0

OPER COMMENTS M A O N N D I C S L.L4 8050 Load the first No% in sta k pointer through .L reg% pair SP.L L.L4 8058 Load the se ond No% in .L reg% pair C E3 hange +ith 4E reg% pair% 0 0 ;lear .L C 4E reg% pairs% 0 0 .

I;.B LII .'

800K 8000 800$

LII

$' 0 0 0 0 .

800; 8004 800E

LDD

404

SP

0dd SP +ith .L pair%

"6

800A 8060 8066 8068 806, 806" 8065 806! 8065 8068 806K 8060 806$ 806; 8064 806E 806A 8080 8086 8088 808, 808" OBSERVATION: INP1T 044<ESS 40T0 8050 8056 8058 805,

JN; INI 4;I -D* D<0 JN7 S.L4

NEIT $ 4 0'E 4 LDDP 805"

NEI

If there is no arry' go to the instru tion labeled NEIT In rement $; reg% pair 4e rement 4E reg% pair% -o&e the ontent of reg% E to 0 % D< 0 % +ith 4 reg% If there is no /ero' go to instru tion labeled LDDP Store the ontent of .L pair in memory lo ations 805" C 8055% -o&e the ontent of reg% ; to 0 % Store the ontent of 0 % in memory lo ation 805!% -o&e the ontent of reg% $ to 0 % Store the ontent of 0 % in memory lo ation 805!% Stop program e3e ution

-D* ST0 -D* ST0 .LT

0' ; 805! 0' $ 8055

D1TP1T 044<ESS 40T0 805" 8055 805! 8055


"8

5(B(. 146 BIT DIVISION AIM: To di&ide t+o 6!-bit numbers and store the result in memory using 8085 mnemoni s% ALGORITHM: 6% Bet the di&idend and di&isor% 8% Initiali/e the register for (uotient% ,% <epeatedly subtra t di&isor from di&idend till di&idend be omes less than di&isor% "% ;ount the number of subtra tion +hi h e(uals the (uotient% 5% Store the result in memory% RESULT: Thus the 6!-bit 4i&ision +as done in 8085p using repeated subtra tion method%

",

1LO2CHART:
ST0<T L F8056G . F8058G

.L

4E

L F8050G . F8056G

$; 0000.

LN 00- E L0

0. 00- .- $orro+ .0

$;$;) 6

Is ;arry flag set H

""

ND

EES

"5

$;$;- 6 .L.L)4E

LF805"G .F8055G

0;

F805!G 0

0$

F8055G 0

STDP

"!

PROGRAM: ADDR OPCO LABE MNE ESS DE L MON ICS 8000 ST0< L.L4 T 8006 8008 800, I;. B 800" L.L4 8005 800! 8005 8008 800K 8000 800$ 800; LII

OPER A ND 8058

COMMENTS Load the first No% in sta k pointer through .L reg% pair

8050

Load the se ond No% in .L reg% pair C E3 hange +ith 4E reg% pair% ;lear $; reg% pair% -o&e the ontent of reg% L to 0 % Subtra t reg% E from that of 0 % -o&e the ontent of 0 to
"5

$' 0000. 0' L E L' 0

LDDP -D* S1$ -D*

8004 800E 800A 8060 8066 8068 806, 806" 8065 806! 8065 8068 806K 8060 806$ 806; 8064 806E 806A 8080 8086 OBSERVATION: INP1T 044<ESS 40T0 8050 8056

-D* S$$ -D* INI JN; 4;I 404

0' . 4 .' 0 $ LDDP $ 4

L% -o&e the ontent of reg% . 0 % Subtra t reg% 4 from that of 0 % -o&e the ontent of 0 to .% In rement reg% Pair $; If there is no arry' go to the lo ation labeled LDDP% 4e rement $; reg% pair% 0dd ontent of .L and 4E reg% pairs% Store the ontent of .L pair in 805" C 8055% -o&e the ontent of reg% ; to 0 % Store the ontent of 0 % in memory 805! -o&e the ontent of reg% $ to 0 % Store the ontent of 0 % in memory 8055% Stop the program e3e ution%

S.L4 805" -D* ST0 -D* ST0 .LT D1TP1T 044<ESS 40T0 805" 8055 0' ; 805! 0' $ 8055

"8

8058 805, AIM:

805! 8055 4(A(. LARGEST ELEMENT IN AN ARRA5

To find the largest element in an array% ALGORITHM: 6% Pla e all the elements of an array in the onse uti&e memory lo ations% 8% Aet h the first element from the memory lo ation and load it in the a umulator% ,% Initiali/e a ounter =register> +ith the total number of elements in an array% "% 4e rement the ounter by 6% 5% In rement the memory pointer to point to the ne3t element% !% ;ompare the a umulator ontent +ith the memory ontent =ne3t ontent Else ontinue% 8% 4e rement the ounter by 6% K% <epeat steps 5 to 8 until the ounter rea hes /ero 60% Store the result =a umulator ontent> in the spe ified memory lo ation%
"K

element>% =largest element> to the a umulator%

5% If the a umulator ontent is smaller' then mo&e the memory

RESULT: Thus the largest number in the gi&en array is found out%

ST0<T F.LG F8600.G

F$G 0". F0G F.LG

1LO2 CHART:

F.L F.LG ) 6

IS F0G M F.LGH F0G F.LG F$G F$G-6

IS F$G L 0H F8605G F0G STDP

50

ND EES

ND EES

PROGRAM:
56

ADDR E SS 8006 8008 800, 800" 8005 800! 8005 8008 800K 8000 800$ 800; 8004 800E 800A 8060 8066 8068 806, 806"

OPC O DE

LAB EL

MNE M ONIC S LII

OPE R AND

COMMENTS

.'860 Initiali/e .L reg% to 0 8600. Initiali/e $ reg +ith no% of omparisons=n6> 0'- Transfer first data to a % . In rement .L reg% to point ne3t memory lo ation ;ompare - C 0 LDDP If 0 is greater than then go to loop Transfer data from to 0 reg $ 4e rement $ reg LDDP If $ is not 7ero go to 6 loop6 8605 Store the result in a memory lo ation% Stop the program 0'$'0"

-*I -D* LDDP 6 INI ;-P JN; -D* LDDP 4;< JN7

ST0 .LT

58

OBSERVATION: INP1T 044<ESS 40T0 8600 8606 8608 860, 860" D1TP1T 044<ESS 40T0 8605

4(B(. SMALLEST ELEMENT IN AN ARRA5 AIM: To find the smallest element in an array% ALGORITHM: 6% Pla e all the elements of an array in the onse uti&e memory lo ations% 8% Aet h the first element from the memory lo ation and load it in the a umulator% ,% Initiali/e a ounter =register> +ith the total number of elements in an array% "% 4e rement the ounter by 6%
5,

5% In rement the memory pointer to point to the ne3t element% !% ;ompare the a umulator ontent +ith the memory ontent =ne3t ontent Else ontinue% 8% 4e rement the ounter by 6% K% <epeat steps 5 to 8 until the ounter rea hes /ero 60% Store the result =a umulator ontent> in the spe ified memory lo ation% RESULT: Thus the smallest number in the gi&en array is found out% element>% =largest element> to the a umulator% 5% If the a umulator ontent is smaller' then mo&e the memory

5"

1LO2 CHART:
ST0<T F.LG F8600.G

F$G 0". F0G F.LG F.L F.LG ) 6

IS F0G M F.LGH F0G F.LG F$G F$G-6

EES

ND
IS F$G L 0H F8605G F0G STDP

ND EES

55

PROGRAM: ADDR E SS 8006 8008 800, 800" 8005 800! 8005 8008 800K 8000 800$ LDDP 6 OPC O DE LAB EL MNE M ONIC S LII OPE R AND COMMENTS

.'860 Initiali/e .L reg% to 0 8600. Initiali/e $ reg +ith no% of omparisons=n6> 0'- Transfer first data to a % . In rement .L reg% to point ne3t memory lo ation ;ompare - C 0 LDDP If 0 is lesser than then go to loop $'0"

-*I -D* INI ;-P J;

5!

800; 8004 800E 800A 8060 8066 8068 806, 806" OBSERVATION: INP1T 044<ESS 40T0 8600 8606 8608 860, 860" LDDP

-D* 4;< JN7

Transfer data from to 0 reg $ 4e rement $ reg LDDP If $ is not 7ero go to 6 loop6 8605 Store the result in a memory lo ation% Stop the program

0'-

ST0 .LT

D1TP1T 044<ESS 40T0 8605

7(A(.ASCENDING ORDER AIM:

55

To sort the gi&en number in the as ending order using 8085 mi ropro essor% ALGORITHM: 6% Bet the numbers to be sorted from the memory lo ations% 8% ;ompare the first t+o numbers and if the first number is larger than se ond then I inter hange the number% ,% If the first number is smaller' go to step " "% <epeat steps 8 and , until the numbers are in re(uired order RESULT: Thus the as ending order program is e3e uted and thus the numbers are arranged in as ending order%

58

ST0<T F$G 0".

1LO2CHART:

F.LG F8600.G

F;G 0". F0G F.LG F.L F.LG ) 6

IS F0G M F.LGH F4G F.LG

F.LG F0G

EES

F.LG F.LG - 6

F.LG F4G

ND

F.LG F.LG ) 6 F;G F;G 9 06 . 5K

IS F;G L 0H F$G F$G-6

ND EES

IS F$G L 0H !0 STDP

ND EES

PROGRAM: ADD RE OPC O LAB EL MNEM ONICS OPE R COMMENTS

!6

SS 8000 8006 8008 800, 800" 8005 800! 8005 8008 800K 8000 800$ 800; 8004 800E 800A 8060 8066 8068 806, 806"

DE -*I LDDP , LII

AND $'0" Initiali/e $ reg +ith number of omparisons =n-6> .'860 Initiali/e .L reg% to 0 8600. Initiali/e ; reg +ith no% of omparisons=n6> 0'- Transfer first data to a % . In rement .L reg% to point ne3t memory lo ation ;ompare - C 0 LDDP If 0 is less than 6 then go to loop6 4'-'0 . -'4 . ; Transfer data from to 4 reg Transfer data from a to 4e rement .L pair Transfer data from 4 to In rement .L pair 4e rement ; reg ;'0"

-*I LDDP 8 -D* INI ;-P J;

-D* -D* 4;I -D* LDDP 6 INI 4;< JN7

LDDP If ; is not /ero go to 8 loop8

!8

8065 806! 8065 8068 806K 8060 OBSERVATION:

4;< JN7

$ 4e rement $ reg LDDP If $ is not 7ero go to , loop, Stop the program

.LT

INP1T -E-D<E 40T0 LD;0TIDN 8600 8606 8608 860, 860"

D1TP1T -E-D<E 40T0 LD;0TIDN 8600 8606 8608 860, 860"

7(B(. DESCENDING ORDER AIM: To sort the gi&en number in the des ending order using 8085 mi ropro essor% ALGORITHM: 6% Bet the numbers to be sorted from the memory lo ations% 8% ;ompare the first t+o numbers and if the first number is smaller than se ond then I inter hange the number% ,% If the first number is larger' go to step " "% <epeat steps 8 and , until the numbers are in re(uired order

!,

RESULT: Thus the des ending order program is e3e uted and thus the numbers are arranged in des ending order%
ST0<T F$G 0". F.LG F8600.G

F;G 0". F0G F.LG F.L F.LG ) 6

IS F0G M F.LGH F4G F.LG

F.LG F0G

F.LG F.LG - 6

F.LG F4G F.LG F.LG ) 6

1LO2CHART:
F;G F;G 9 06 . !"

ND EES

!5

IS F;G L 0H F$G F$G-6

ND EES

IS F$G L 0H STDP

ND EES

!!

PROGRAM: ADDRE OPCO LABEL MNEM OPER COMMENTS SS DE ONICS AND 8000 -*I $'0" Initiali/e $ reg +ith number of 8006 omparisons =n6> 8008 LDDP , LII .'8600 Initiali/e .L reg% to 800, 8600. 800" 8005 -*I ;'0" Initiali/e ; reg +ith no% of 800! omparisons=n-6> 8005 LDDP8 -D* 0'- Transfer first data
!5

8008 800K 8000 800$ 800; 8004 800E 800A 8060 8066 8068 806, 806" 8065 806! 8065 8068 806K 8060 OBSERVATION: INP1T -E-D<E 40T0 LDDP6

INI ;-P JN; -D* -D* 4;I -D* INI 4;< JN7 4;< JN7 .LT

to a % . In rement .L reg% to point ne3t memory lo ation ;ompare - C 0 LDDP6 If 0 is greater than - then go to loop6 4'- Transfer data from - to 4 reg -'0 Transfer data from a to . 4e rement .L pair -'4 Transfer data from 4 to . In rement .L pair ; 4e rement ; reg LDDP8 If ; is not /ero go to loop8 $ 4e rement $ reg LDDP, If $ is not 7ero go to loop, Stop the program

D1TP1T -E-D<E 40T0


!8

LD;0TIDN LD;0TIDN 8600 8600 8606 8606 8608 8608 860, 860, 860" 860" 8(A(. CODE CONVERSION 8DECIMAL TO HE9 AIM: To on&ert a gi&en de imal number to he3ade imal% ALGORITHM: 6% Initiali/e the memory lo ation to the data pointer% 8% In rement $ register% ,% In rement a umulator by 6 and adOust it to de imal e&ery time% "% ;ompare the gi&en de imal number +ith a umulator &alue% 5% ?hen both mat hes' the e(ui&alent he3ade imal &alue is in $ register% !% Store the resultant in memory lo ation% RESULT: Thus an 0LP program for on&ersion of de imal to he3ade imal +as +ritten and e3e uted%

!K

50

1LO2CHART:

ST0<T .L "500.

0 00

$ $

00. $)6

0 )6

4e imal adOust a umulator

Is 0L-H

8606

ND 0
Stop

EES

56

PROGRAM: ADDR E SS 8000 8006 8008 800, 800" 8005 800! 8005 8008 800K 8000 800$ 800; 8004 800E OPC O DE LAB EL MNE M ONIC S LII OPE R AND COMMENTS

.'860 Initiali/e .L reg% to 0 8600. 0'00 $'00 $ 06 Initiali/e 0 register% Initiali/e $ register%% In rement $ reg% In rement 0 reg

-*I -*I LDDP IN< 04I 400 ;-P JN7

4e imal 0dOust 0 umulator ;ompare - C 0 LDDP If a and gi&en number are not e(ual' then go to LDDP
58

800A 8060 8066 8068 806, RESULT: INP1T 044<ESS 40T0 8600

-D* ST0 .LT

0'$ 8606

Transfer $ reg to a % Store the result in a memory lo ation% Stop the program

D1TP1T 044<ESS 40T0 8606

8(B(. CODE CONVERSION 8HE9ADECIMAL TO DECIMAL AIM: To on&ert a gi&en he3ade imal number to de imal% ALGORITHM:

5,

6% Initiali/e the memory lo ation to the data pointer% 8% In rement $ register% ,% In rement a umulator by 6 and adOust it to de imal e&ery time% "% ;ompare the gi&en he3ade imal number +ith $ register &alue% 5% ?hen both mat h' the e(ui&alent de imal &alue is in 0 register% !% Store the resultant in memory lo ation% RESULT: Thus an 0LP program for on&ersion of he3ade imal to de imal +as +ritten and e3e uted%

5"

55

1LO2CHART:
.L

ST0<T 8600.

0 00

$ ; $

00. 00. $)6

0 )6

4e imal adOust a umulator

Is there arryH ; ;)6 4 0' 0 $'

Is 0L-H

8606 8608

0' 0 0
Stop

5!

ND EES

PROGRAM: ADDR E SS 8000 8006 8008 800, 800" 8005 800! 8005 8008 800K 8000 800$ 800; 8004 800E OPC O DE LAB EL MNE M ONIC S LII OPE R AND COMMENTS

.'860 Initiali/e .L reg% to 0 8600. 0'00 $'00 ;'00 $ 06 Initiali/e 0 register% Initiali/e $ register% Initiali/e ; register for arry% In rement $ reg% In rement 0 reg

-*I -*I -*I LDDP IN< 04I 400 JN;

4e imal 0dOust 0 umulator NEIT If there is no arry go to NEIT%


55

800A 8060 8066 8068 806, 806" 8065 806! 8065 8068 806K 8060 806$ 806; 8064 806E 806A RESULT:

IN< NEIT -D* -D* ;-P -D* JN7 ST0 -D* ST0 .LT

; 4'0 0'$ 0'4 LDDP 8606 0'; 8608

In rement register% Transfer 0 to 4 Transfer $ to 0 ;ompare - C 0 Transfer 4 to 0 If a and gi&en number are not e(ual' then go to LDDP Store the result in a memory lo ation% Transfer ; to 0 Store the arry in another memory lo ation% Stop the program

INP1T 044<ESS 8600

40T 0

D1TP1T 044<ESS 8606 8608

40T0

:(A( BCD ADDITION AIM: To add t+o 8 bit $;4 numbers stored at onse uti&e memory lo ations% ALGORITHM:
58

6% 8% ,% "%

Initiali/e memory pointer to data lo ation% Bet the first number from memory in a umulator% Bet the se ond number and add it to the a umulator 0dOust the a umulator &alue to the proper $;4 &alue using 400 instru tion% 5% Store the ans+er at another memory lo ation% RESULT: Thus the 8 bit $;4 numbers stored at "500 C"506 are added and the result stored at "508 C "50,%

5K

ST0<T

1LO2 CHART:
F;G 00.

F.LG

"500.

F0G

F-G

F.LGF.LG)6

F0GF0G)F-G 4e imal 0dOust 0 umulator

Is there a ;arry H

F;GF;G)6

F.LGF.LG)6

ND
F-G F0G

F.LGF.LG)6

EES

F-G

F;G

80
STDP

PROGRAM: ADDRESS OPCODE LABEL MNEMONICS OPERAND COMMENT "600 ST0<T -*I ;' 00 ;lear ; reg% "60, "608 LII .' "500 Initiali/e .L reg% to "60, "500 "60" "605 -D* 0' Transfer first data to a umulator "60! INI . In rement .L reg% to point ne3t memory

86

"605 "608 "60K "600 "60$ "60; "604 L6

044 400 JN;

L6

IN< INI

; .

"60E

-D*

-' 0

"60A

INI

"660 "666

-D* .LT

-' ;

Lo ation% 0dd first number to a % ;ontent% 4e imal adOust a umulator Jump to lo ation if result does not yield arry% In rement ; reg% In rement .L reg% to point ne3t memory Lo ation% Transfer the result from a % to memory% In rement .L reg% to point ne3t memory Lo ation% -o&e arry to memory Stop the program

88

OBSERVATION: INP1T "500 "506 D1TP1T "508 "50,

:(B(. BCD SUBTRACTION AIM: To Subtra t t+o 8 bit $;4 numbers stored at onse uti&e memory lo ations% ALGORITHM: 6% 8% ,% "% 5% Load the minuend and subtrahend in t+o registers% Initiali/e $orro+ register to 0% Take the 600:s omplement of the subtrahend% 0dd the result +ith the minuend +hi h yields the result% 0dOust the a umulator &alue to the proper $;4 &alue using 400 instru tion% If there is a arry ignore it% !% If there is no arry' in rement the arry register by 6 5% Store the ontent of the a umulator =result>and borro+ register in the spe ified memory lo ation RESULT: Thus the 8 bit $;4 numbers stored at "500 C"506 are subtra ted and the result stored at "508 C "50,%
8,

ST0<T

F4G 00. .L "500 $ .L .L) 6 ; 0 KK F0G F0G 9 F;G F0G F0G)6

1LO2 CHART:

F0GF0G)F$G 400

Is there a ;arry H

F4GF4G)6

F.LGF.LG)6

F"508G 0 F"50,G 4

8"
STDP

EES

ND

PROGRAM:
85

ADDRESS OPCODE LABEL MNEMONICS OPERAND COMMENT "600 ST0<T -*I 4' 00 ;lear 4 reg% "606 "608 LII .' "500 Initiali/e .L reg% to "60, "500 "60" "605 -D* $' Transfer first data to a umulator "60! INI . In rement .L reg% to point ne3t mem% Lo ation% "605 -D* ;' -o&e se ond no% to $ reg% "608 -*I 0' KK -o&e KK to the "60K 0 umulator "600 S1$ ; Subtra t F;G from a % ;ontent% "60$ IN< 0 In rement 0 register "60; 044 $ 0dd F$G +ith F0G "604 400 0dOust 0 umulator &alue for 4e imal digits "60E J; LDDP Jump on arry to loop "60A
8!

"660 "666 "668 "66, LDDP

IN< INI -D*

4 . -'0

"66"

INI

"665

-D*

-' 4

"66! OBSERVATION:

.LT

In rement 4 reg% In rement .L register pair -o&e the 0 % ontent to the memory lo ation In rement .L reg% to point ne3t mem% Lo ation% Transfer 4 register ontent to memory% Stop the program

INP1T D1TP1T "500 "508 "506 "50, 10. 2 9 2 MATRI9 MULTIPLICATION AIM:

85

To perform the 8 3 8 matri3 multipli ation% ALGORITHM: 6% Load the 8 input matri es in the separate address and initiali/e the .L and the 4E register pair +ith the starting address respe ti&ely% 8% ;all a subroutine for performing the multipli ation of one element of a matri3 +ith the other element of the other matri3% ,% ;all a subroutine to store the resultant &alues in a separate matri3% RESULT: Thus the 8 3 8 matri3 multipli ation is performed and the result is stored at "500'"506 ' "508 C "50,%

88

1LO2 CHART:
ST0<T ; .L 00. 8500.

0
.L .L)6 4E 4E)6N 4E 4E)6 ;all subroutine -1L 0 0)$

4E

8!00.

;all subroutine -1L

;all subroutine STD<E 0 ;

.L .L)6 4E 4E)6N 4E 4E)6 ;all subroutine -1L 0 0)$

Is 0L0". H In rement .L reg% pair STDP

;all subroutine STD<E .L .L-6 4E 4E-6N ;all subroutine -1L $ 0

EES

ND

$ 0

0 8K

-1L

STD<E

F0G FF4EGG 4 0 . . .- 6

$ 85

F0GFF$;GG

; ;) 6 Is .L0 H <ET

F4GF4G)6

EES ND
;all subroutine -1L

. .- 6

Is .L0 H

F.G85N F4G8!

K0
<ET

ND

EES

PROGRAM: ADDRE OPC SS ODE 8600 8606 8608 860, 860" LAB EL MNE OPER MON AND ICS -*I ;' 00 LII COMMENT ;lear ; reg%

.' 8500 Initiali/e .L reg% to "500

K6

8605 860! 8605 8608 860K 8600 860$ 860; 8604 860E 860A 8660 8666 8668 866, 866" 8665 866! 8665 8668 866K 8660 866$ 866; 8664 866E 866A 8680 8686 8688 868,

LDDP 8

LII

4' 8!00 Load 4E register pair

;0LL -D* INI INI INI ;0LL

-1L $'0 . 4 4 -1L

;all subroutine -1L -o&e 0 to $ reg% In rement .L register pair % In rement 4E register pair In rement 4E register pair ;all subroutine -1L

044 $ 0dd F$G +ith F0G ;0LL STD<E ;all subroutine STD<E 4;I 4;I ;0LL -D* INI INI INI ;0LL . 4 -1L $'0 . 4 4 -1L 4e rement .L register pair 4e rement 4E register pair ;all subroutine -1L Transfer 0 reg ontent to $ reg% In rement .L register pair In rement 4E register pair In rement 4E register pair ;all subroutine -1L

044 $ 0dd 0 +ith $ ;0LL STD<E ;all subroutine -1L


K8

868" 8685 868! 8685 8688 868K 8680 868$ 868; 8684 868E 868A 86,0 86,6 86,8 86,, 86," 86,5 86,! 86,5 86,8 86,K 86,0 86,$ 86,;

-D* ;PI J7 INI J-P LDDP 6 -1L .LT L40 I

Transfer ; register ontent to 0 % 0" ;ompare +ith 0" to he k +hether all elements are multiplied% LDDP6 If ompleted' go to loop6 . In rement .L register Pair% LDDP8 Jump to LDDP8% Stop the program% 4

0';

Load a from the memory lo ation pointed by 4E pair% -D* 4'0 Transfer a ontent to 4 register% -D* .'- Transfer from memory to . register% 4;< . 4e rement . register% J7 LDDP, If . is /ero go to LDDP,% 4 0dd 0 +ith 4 reg

LDDP 044 " 4;< JN7

. 4e rement . register% LDDP" If . is not /ero go to LDDP"%

K,

86,4 86,E 86,A 86"0 86"6 86"8 86", 86"" 86"5 86"!

LDDP ,

-*I -*I

.'85 4'8! $'85 $ ;

Transfer 85 TD . register% Transfer 8! to 4 register% <eturn to main program% Transfer 85 to $ register% Load 0 from memory lo ation pointed by $; pair% In rement ; register% <eturn to main program%

STD< E

<ET -*I ST0I IN< <ET

OBSERVATION: "500 "506 "508 "50, INP1T "!00 "!06 "!08 "!0, D1TP1T "500 "506 "508 "50,

11. BIOS;DOS CALLS 8 DISPLA5 AIM: To display a message on the ;<T s reen of a mi ro omputer using 4DS alls%

K"

ALGORITHM: 6% Initiali/e the data segment and the message to be displayed% 8% Set fun tion &alue for display% ,% Point to the message and run the interrupt to display the message in the ;<T% PROGRAM: 0SS1-E ;S2 ;D4E' 4S2 40T0 40T0 SEB-ENT -SB 4$ 04.' 00.' PBDD4 -D<NINBQ ' D4.' D0.' PRQ 40T0 EN4S ;D4E SEB-ENT ST0<T2 -D* 0I' 40T0 -D* 4S' 0I -D* 0.' 0K. -D* 4I' DAASET -SB INT 86. -D* 0.' ";. INT 86. ;D4E EN4S EN4 ST0<T

K5

RESULT: 0 message is displayed on the ;<T s reen of a mi ro omputer using 4DS alls

K!

12. BIOS;DOS CALLS 8 1ILE MANIPULATION AIM: To open a file using 4DS alls% ALGORITHM: 6% Initiali/e the data segment' file name and the message to be displayed% 8% Set the file attribute to reate a file using a 4DS all% ,% If the file is unable t o reate a file display the message PROGRAM: 0SS1-E ;S2 ;D4E' 4S2 40T0 40T0 SEB-ENT AILEN0-E 4$ PS0-PLE%40TQ' PRQ -SB 4$ 04.' 00.' PAILE NDT ;<E0TE4Q' D4.' D0.' PRQ 40T0 EN4S ;D4E SEB-ENT ST0<T2 -D* 0I' 40T0 -D* 4S' 0I -D* 4I' DAASET AILEN0-E -D* ;I' 00. -D* 0.' ,;. INT 86. JN; LDDP6 -D* 0I' 40T0 -D* 4S' 0I
K5

-D* 4I' DAASET -SB -D* 0.' 0K. INT 86. LDDP6 -D* 0.' ";. INT 86. ;D4E EN4S EN4 ST0<T RESULT: 0 file is opened using 4DS alls%

K8

13. BIOS;DOS CALLS 8 DIS< IN1ORMATION AIM: To display the disk information% ALGORITHM: 6% Initiali/e the data segment and the message to be displayed% 8% Set fun tion &alue for disk information% ,% Point to the message and run the interrupt to display the message in the ;<T% PROGRAM: 0SS1-E ;S2 ;D4E' 4S2 40T0 40T0 SEB-ENT -SB 4$ 04.' 00.' PBDD4 -D<NINBQ ' D4.' D0.' PRQ 40T0 EN4S ;D4E SEB-ENT ST0<T2 -D* 0I' 40T0 -D* 4S' 0I -D* 0.' ,!. -D* 4I' DAASET -SB INT 86. -D* 0.' ";.
KK

INT 86. ;D4E EN4S EN4 ST0<T RESULT: The disk information is displayed%

1.8084 STRING MANIPULATION 8 SEARCH A 2ORD AIM: To sear h a +ord from a string% ALGORITHM: 6% Load the sour e and destination inde3 register +ith starting and the ending address respe ti&ely% 8% Initiali/e the ounter +ith the total number of +ords to be opied% ,% ;lear the dire tion flag for auto in rementing mode of transfer% "% 1se the string manipulation instru tion S;0S? +ith the prefi3 <EP to sear h a +ord from string%

600

5% If a mat h is found =/L6>' display 06 in destination address% Dther+ise' display 00 in destination address% RESULT: 0 +ord is sear hed and the ount of number of appearan es is displayed%

PROGRAM:

606

0SS1-E ;S2 ;D4E' 4S2 40T0 40T0 SEB-ENT LIST 4? 5,.' 65.' 6K.' 08. 4EST ES1 ,000. ;D1NT ES1 05. 40T0 EN4S ;D4E SEB-ENT ST0<T2 -D* 0I' 40T0 -D* 4S' 0I -D* 0I' 65. -D* SI' DAASET LIST -D* 4I' 4EST -D* ;I' ;D1NT -D* 0I' 00 ;L4 <EP S;0S? J7 LDDP -D* 0I' 06 LDDP -D* F4IG' 0I -D* 0.' ";. INT 86. ;D4E EN4S EN4 ST0<T

608

INPUT: LIST2 5,.' 65.' 6K.' 08. OUTPUT: ,000 06

60,

2.8084 STRING MANIPULATION 81IND AND REPLACE A 2ORD AIM: To find and repla e a +ord from a string% ALGORITHM: 6% Load the sour e and destination inde3 register +ith starting and the ending address respe ti&ely% 8% Initiali/e the ounter +ith the total number of +ords to be opied% ,% ;lear the dire tion flag for auto in rementing mode of transfer% "% 1se the string manipulation instru tion S;0S? +ith the prefi3 <EP to sear h a +ord from string% 5% If a mat h is found =/L6>' repla e the old +ord +ith the urrent +ord in destination address% Dther+ise' stop% RESULT: 0 +ord is found and repla ed from a string%

60"

PROGRAM: 0SS1-E ;S2 ;D4E' 4S2 40T0 40T0 SEB-ENT LIST 4? 5,.' 65.' 6K.' 08. <EPL0;E ES1 ,0. ;D1NT ES1 05. 40T0 EN4S

605

;D4E SEB-ENT ST0<T2 -D* 0I' 40T0 -D* 4S' 0I -D* 0I' 65. -D* SI' DAASET LIST -D* ;I' ;D1NT -D* 0I' 00 ;L4 <EP S;0S? JN7 LDDP -D* 4I' L0$EL LIST -D* F4IG' <EPL0;E LDDP ;D4E EN4S EN4 ST0<T INPUT: LIST2 5,.' 65.' 6K.' 08. OUTPUT: LIST2 5,.' ,0.' 6K.' 08. -D* 0.' ";. INT 86.

60!

3. 8084 STRING MANIPULATION 8 COP5 A STRING AIM: To opy a string of data +ords from one lo ation to the other% ALGORITHM: !% Load the sour e and destination inde3 register +ith starting and the ending address respe ti&ely% 5% Initiali/e the ounter +ith the total number of +ords to be opied% 8% ;lear the dire tion flag for auto in rementing mode of transfer% K% 1se the string manipulation instru tion -D*S? +ith the prefi3 <EP to opy a string from sour e to destination% RESULT: 0 string of data +ords is opied from one lo ation to other%

605

PROGRAM: 0SS1-E ;S2 ;D4E' 4S2 40T0 40T0 SEB-ENT SD1<;E ES1 8000. 4EST ES1 ,000. ;D1NT ES1 05. 40T0 EN4S ;D4E SEB-ENT

608

ST0<T2

-D* 0I' 40T0 -D* 4S' 0I -D* ES' 0I -D* SI' SD1<;E -D* 4I' 4EST -D* ;I' ;D1NT ;L4

<EP -D*S? -D* 0.' ";. INT 86. ;D4E EN4S EN4 ST0<T INPUT: 8000 8006 8" 8008 800, K0 800" 86 !5 "8 OUTPUT: ,000 "8 ,006 8" ,008 !5 ,00, K0 ,00" 86

60K

3.8084 STRING MANIPULATION 8 SORTING AIM: To sort a group of data bytes% ALGORITHM: Pla e all the elements of an array named list =in the onse uti&e memory lo ations>% Initiali/e t+o ounters 4I C ;I +ith the total number of elements in the array% 4o the follo+ing steps until the ounter $ rea hes 0% o Load the first element in the a umulator o 4o the follo+ing steps until the rea hes 0% 6% ;ompare the a umulator ontent +ith the ne3t element present in the ne3t memory lo ation% If the a umulator ontent is smaller go to ne3t stepN other+ise' s+ap the ontent of a umulator +ith the ontent of memory lo ation% 8% In rement the memory pointer to point to the ne3t element% ,% 4e rement the ounter ; by 6% Stop the e3e ution% RESULT:
660

ounter ;

0 group of data bytes are arranged in as ending order%

PROGRAM: 0SS1-E ;S2 ;D4E' 4S2 40T0 40T0 SEB-ENT LIST 4? 5,.' 85.' 6K.' 08. ;D1NT ES1 0". 40T0 EN4S ;D4E SEB-ENT ST0<T2 -D* 0I' 40T0 -D* 4S' 0I

666

-D* 4I' ;D1NT-6 LDDP82 0B0IN2 -D* ;I' 4I -D* SI' DAASET LIST -D* 0I' FSIG ;-P 0I' FSI)8G J; LDDP6 I;.B FSI )8G' 0I I;.B FSIG' 0I LDDP62 044 SI' 08 LDDP 0B0IN 4E; 4I JN7 LDDP8 -D* 0.' ";. INT 86. ;D4E EN4S EN4 ST0<T INPUT: LIST2 5,.' 85.' 6K.' 08. OUTPUT: LIST2 08.' 6K.' 85.' 5,.

668

3. INTER1ACING 8255 2ITH 8085 AIM: To interfa e programmable peripheral interfa e 8855 +ith 8085 and study its hara teristi s in mode0'mode6 and $S< mode% APPARATUS RE=UIRED: 8085 p kit' 8855Interfa e board' 4; regulated po+er supply' *IT parallel bus I;O MODES: C%' r%+ 2%r*:

66,

MODE 0 8 SIMPLE I;O MODE: This mode pro&ides simple I@D operations for ea h of the three ports and is suitable for syn hronous data transfer% In this mode all the ports an be onfigured either as input or output port% Let us initiali/e port 0 as input port and port $ as output port

PROGRAM: ADDRE OPCOD LAB MNEMON OPERA SS ES EL ICS ND "600 ST0< -*I 0' K0 T2 "606 "608 "60, "60" "605 "60! "605 "608 "60K "600 "60$ D1T IN D1T ST0 ;! ;0 ;8 "800 COMME NTS Initiali/e port 0 as Input and Port $ as output% Send -ode ;ontrol +ord <ead from Port 0 4isplay the data in port $ Store the data read from Port 0 in "800 Stop the program%
66"

.LT

MODE1 STROBED I;O MODE: In this mode' port 0 and port $ are used as data ports and port ; is used as ontrol signals for strobed I@D data transfer% Let us initiali/e port 0 as input port in mode6 MAIN PROGRAM: ADDRE OPCOD LAB MNEMON OPERA SS ES EL ICS ND "600 ST0< -*I 0' $" T2 "606 "608 "60, "60" "605 "60! "605 "608 "60K "600 "60$ EI -*I SIEI .LT 0'08 Enable <ST5%5 Stop the program% D1T -*I ;! 0'0K COMME NTS Initiali/e port 0 as Input port in mode 6% Send -ode ;ontrol +ord Set the P;" bit for INTE 0 4isplay the data in port $

D1T

;!

ISR (I' #rr,0 S#r>i$# R%, i'#(

665

ADDRE OPCOD LAB SS ES EL "800 ST0< T2 "806 "808 "80, "80" "805

MNEMON OPERA ICS ND IN ;0 ST0 .LT "500

COMME NTS <ead from port 0 Store in "500% Stop the program%

S,? 0r%&r)": ADDRE OPCOD LAB SS ES EL "05E "05A "0!0 MNEMON OPERA ICS ND J-P "800 COMME NTS Bo to "800

BSR MODE (Bi S# R#-# "%*#(

66!

0ny lines of port an be set or reset indi&idually +ithout affe ting other lines using this mode% Let us set P;0 and P;, bits using this mode% PROGRAM: ADDRE OPCOD LAB MNEMON OPERA SS ES EL ICS ND "600 ST0< -*I 0' 06 T2 COMME NTS Set P;0

665

"606 "608 "60, "60" "605 "60! "605 "60K

D1T -*I D1T .LT

;! 0'05 ;!

Send -ode ;ontrol +ord Set P;, Send -ode ;ontrol +ord Stop the program%

RESULT: Thus 8855 is interfa ed and its hara teristi s in mode0'mode6 and $S< mode is studied%

4. INTER1ACING 8253 TIMER 2ITH 8085 I' #r@)$i'& 8253 Pr%&r)"")?+# I' #r>)+ Ti"#r Ai ! 8085 0 AIM2 To interfa e 885, Interfa e board to 8085 p and &erify the operation of 885,in si3 different modes%
668

APPARATUS RE=UIRED2 8085 p kit' 885, Interfa e board' 4; regulated po+er supply' *IT parallel bus' ;<D%

M%*# 0 8 I' #rr,0 %' #r"i')+ $%,' 2 The output +ill be initially lo+ after mode set operations% 0fter loading the ounter' the output +ill be remaining lo+ +hile ounting and on terminal ountN the output +ill be ome high' until reloaded again%

Let us set the hannel 0 in mode 0% ;onne t the ;L# 0 to the deboun e ir uit by hanging the Oumper J, and then e3e ute the follo+ing program% Pr%&r)": A**r#- O0$%*# "600 "608 L)?#+ M'#"%'i $ ST0<T -*I 2 D1T O0#r)'* 0' ,0 ;E C%""#' ;hannel 0 in mode 0 Send -ode ;ontrol +ord LS$ of ount ?rite ount to
66K

"60" "60!

-*I D1T

0' 05 ;8

"608 "600 "60;

-*I D1T .LT

0' 00 ;8

register -S$ of ount ?rite ount to register

It is obser&ed in ;<D that the output of ;hannel 0 is initially LD?% 0fter gi&ing si3 lo k pulses' the output goes .IB.% M%*# 1 8 Pr%&r)"")?+# ONE6SHOT: 0fter loading the ounter' the output +ill remain lo+ follo+ing the rising edge of the gate input% The output +ill go high on the terminal ount% It is retriggerableN hen e the output +ill remain lo+ for the full ount' after any rising edge of the gate input% EB)"0+#: The follo+ing program initiali/es hannel 0 of 885, in -ode 6 and also initiates triggering of Bate 0% D1T 0 goes lo+' as lo k pulse after triggering the goes ba k to high le&el after 5 lo k pulses% E3e ute the program' gi&e lo k pulses through the deboun e logi and &erify using ;<D% A**r#"600 "608 O0$%*# L)?#+ M'#"%'i $ ST0<T -*I 2 D1T O0#r)'* 0' ,8 ;E C%""#' ;hannel 0 in mode 6 Send -ode ;ontrol +ord LS$ of

"60"

-*I

0' 05

680

"60! "608 "600 "60; "600

D1T -*I D1T D1T .LT

;8 0' 00 ;8 40

ount ?rite ount to register -S$ of ount ?rite ount to register Trigger Bate0

M%*# 2 8 R) # G#'#r) %r: It is a simple di&ide by N ounter% The output +ill be lo+ for one period of the input lo k% The period from one output pulse to the ne3t e(uals the number of input ounts in the ount register% If the ount register is reloaded bet+een output pulses the present period +ill not be affe ted but the subse(uent period +ill refle t the ne+ &alue%

EB)"0+#2 1sing -ode 8' Let us di&ide the lo k present at ;hannel 6 by 60% ;onne t the ;L#6 to P;L#% A**r#O0$%*# L)?#+ M'#"%'i $ O0#r)'* C%""#' 686

"600 "608

,E 5" 4, ;E

ST0<T -*I 2 D1T

0' 5" ;E

"60" "60! "608 "600

,E 00 4, ;0 ,E 00 4, ;0

-*I D1T -*I D1T

0' 00 ;0 0' 00 ;0

;hannel 6 in mode 8 Send -ode ;ontrol +ord LS$ of ount ?rite ount to register -S$ of ount ?rite ount to register

"60; 5! .LT In ;<D obser&e simultaneously the input lo k to hannel 6 and the output at Dut6% M%*# 3 SC,)r# A)># &#'#r) %r2 It is similar to -ode 8 e3 ept that the output +ill remain high until one half of ount and go lo+ for the other half for e&en number ount% If the ount is odd' the output +ill be high for = ount ) 6>@8 ounts% This mode is used of generating $aud rate for 88560 =1S0<T>%

EB)"0+#:

688

?e utili/e -ode 0 to generate a s(uare +a&e of fre(uen y 650 #./ at hannel 0% A**r#- O0$%*# L)?#+ M'#"%'i O0#r)'* C%""#' $ "600 ,E ,! ST0<T -*I 0' ,! ;hannel 0 2 in mode , "608 4, ;E D1T ;E Send -ode ;ontrol +ord "60" ,E 00 -*I 0' 00 LS$ of ount "60! 4, ;8 D1T ;8 ?rite ount to register "608 ,E 00 -*I 0' 00 -S$ of ount "600 4, ;8 D1T ;8 ?rite ount to register "60; 5! .LT Set the Oumper' so that the lo k 0 of 885, is gi&en a s(uare +a&e of fre(uen y 6%5 -./% This program di&ides this P;L# by 60 and thus the output at hannel 0 is 650 #./% *ary the fre(uen y by &arying the ount% .ere the ma3imum ount is AAAA .% So' the s(uare +a&e +ill remain high for 5AAA . ounts and remain lo+ for 5AAA . ounts% Thus +ith the input lo k fre(uen y of 6%5 -./' +hi h orresponds to a period of 0%0!5 mi rose onds' the resulting s(uare +a&e has an DN time of 0%0868" mi rose onds and an DAA time of 0%0868" mi rose onds% To in rease the time period of s(uare +a&e' set the Oumpers su h that ;L#8 of 885, is onne ted to D1T 0% 1sing the abo&e-

68,

mentioned program' output a s(uare +a&e of fre(uen y 650 #./ at hannel 0% No+ this is the lo k to hannel 8% M%*# 3: S%@ A)r# Tri&&#r#* S r%?#: The output is high after mode is set and also during ounting% Dn terminal ount' the output +ill go lo+ for one lo k period and be omes high again% This mode an be used for interrupt generation% The follo+ing program initiali/es hannel 8 of 885, in mode "% EB)"0+#: ;onne t D1T 0 to ;L# 8 =Oumper J6>% E3e ute the program and obser&e the output D1T 8% ;ounter 8 +ill generate a pulse after 6 se ond% A**r#"600 "608 O0$%*# L)?#+ M'#"%'i $ ST0<T -*I 2 D1T O0#r)'* 0' ,! ;E C%""#' ;hannel 0 in mode 0 Send -ode ;ontrol +ord LS$ of ount ?rite ount to register -S$ of ount ?rite ount to register

"60" "60! "608 "600

-*I D1T -*I D1T

0' 00 ;8 0' 00 ;8

68"

"60; "60E

-*I D1T

0' $8 ;E

"660 "668 "66" "66! "668

-*I D1T -*I D1T .LT

0' K8 ;; 0' ,0 ;;

;hannel 8 in -ode " Send -ode ontrol ?ord LS$ of ;ount ?rite ;ount to register -S$ of ;ount ?rite ;ount to register

M%*# 5 H)r*A)r# ri&&#r#* - r%?#: ;ounter starts ounting after rising edge of trigger input and output goes lo+ for one lo k period +hen terminal ount is rea hed% The ounter is retriggerable% E3ample2 The program that follo+s initiali/es hannel 0 in mode 5 and also triggers Bate 0% ;onne t ;L# 0 to deboun e ir uit% E3e ute the program% 0fter gi&ing Si3 lo k pulses' you an see using ;<D' the initially .IB. output goes LD?% The output = D1T 0 pin> goes high on the ne3t lo k pulse% A**r#"600 O0$%*# L)?#+ M'#"%'i $ ST0<T -*I O0#r)'* 0' 60 C%""#' ;hannel 0
685

2 "608 D1T ;E

"60" "60! "608 "600 "60;

-*I D1T -*I D1T .LT

0' 05 ;8 0' 00 40

in mode 5 Send -ode ;ontrol +ord LS$ of ount ?rite ount to register -S$ of ount Trigger Bate 0

R#-,+ : Thus the 885, has been interfa ed to 8085 p and si3 different modes of 885, ha&e been studied%

7. INTER1ACING 827: 2ITH 8085 8. INTER1ACING 8251 2ITH 8085

68!

:. 8051 6 SUM O1 ELEMENTS IN AN ARRA5 AIM: To find the sum of elements in an array%

685

ALGORITHM: 6% Load the array in the onse uti&e memory lo ation and initiali/e the memory pointer +ith the starting address% 8% ,% "% 5% !% 5% Load the total number of elements in a separate register as a ounter% ;lear the a umulator% Load the other register +ith the &alue of the memory pointer% 0dd the register +ith the a umulator% ;he k for arry' if e3ist' in rement the arry register by 6% other+ise' ontinue 4e rement the ounter and if it rea hes 0' stop% Dther+ise in rement the memory pointer by 6 and go to step "% RESULT: The sum of elements in an array is al ulated%

688

PROGRAM: -D* 4PT<' T"800 -D*I 0' U4PT< -D* <0' 0 -D* $' T00 -D* <6' $ IN; 4PT< LDDP82 ;L< ; -D*I 0' U4PT< 044 0' $ -D* $' 0 JN; LDDP

68K

IN; <6 LDDP2 IN; 4PT< 4JN7 <0' LDDP8 -D* 4PT<' T"500 -D* 0' <6 -D*I U4PT<' 0 IN; 4PT< -D* 0' $ -D*I U4PT<' 0 .LT2 SJ-P .LT

INPUT "800 "806 "806 "808 "80, 0" 05 0! 0, 08

OUTPUT: "500 0A "506 00

6,0

10(A(.8051 6 HE9ADECIMAL TO DECIMAL CONVERSION AIM: To perform he3ade imal to de imal on&ersion% ALGORITHM: 6% a umulator% 8% If the number is less than 600 =!".>' go to .a&e the ne3t stepN other+ise' subtra t 600 =!".> repeatedly until the remainder is less than 600 =!".>% ,% ount=600:s &alue> in separate register +hi h is the arry% If the number is less than 60 =00.>' go to ne3t stepN other+ise' subtra t 60 =00.> repeatedly until the remainder is less than 60 =00.>% .a&e the ount=ten:s &alue> in separate register% "% 5% !% The a umulator no+ has the units% -ultiply the ten:s &alue by 60 and add it Store the result and arry in the spe ified Load the number to be on&erted into the

+ith the units% memory lo ation% RESULT

6,6

The gi&en he3ade imal number is on&erted into de imal number%

PROGRAM: -D* 4PT<' T"500 -D*I 0' U4PT< -D* $' T!" 4I* 0' $

6,8

-D* 4PT<' T"506 -D*I U4PT<' 0 -D* 0' $ -D* $' T00 4I* 0' $ IN; 4PT< -D*I U4PT<' 0 IN; 4PT< -D* 0' $ -D*I U4PT<' 0 .LT2 INPUT "500 45 SJ-P .LT OUTPUT: "506 65 "508 08

6,,

10(B(.8051 6 DECIMAL TO HE9ADECIMAL CONVERSION AIM: To perform de imal to he3ade imal on&ersion ALGORITHM: 6% 8% ,% "% Load the number to be on&erted in the a umulator% Separate the higher order digit from lo+er order% -ultiply the higher order digit by 60 and add it +ith the lo+er order digit% Store the result in the spe ified memory lo ation% RESULT: The gi&en de imal number is on&erted to he3ade imal number% PROGRAM: -D* 4PT<' T"500 -D*I 0' U4PT< -D* $' T00 -1L 0' $ -D* $' 0

6,"

IN; 4PT< -D*I 0' U4PT< 044 0' $ IN; 4PT< -D*I U4PT<' 0 .LT2 INPUT "500 8, SJ-P .LT OUTPUT "506 65

13. STEPPER MOTOR INTER1ACING 2ITH 8051 AIM: To interfa e a stepper motor +ith 8056 mi ro ontroller and operate it%

6,5

THEOR5: 0 motor in +hi h the rotor is able to assume only dis rete stationary angular position is a stepper motor% The rotary motion o urs in a step-+ise manner from one e(uilibrium position to the ne3t% Stepper -otors are used &ery +isely in position ontrol systems like printers' disk dri&es' pro ess ontrol ma hine tools' et % The basi t+o-phase stepper motor onsists of t+o pairs of stator poles% Ea h of the four poles has its o+n +inding% The e3 itation of any one +inding generates a North Pole% 0 South Pole gets indu ed at the diametri ally opposite side% The rotor magneti system has t+o end fa es% It is a permanent magnet +ith one fa e as South Pole and the other as North Pole% The Stepper -otor +indings 06' 08' $6' $8 are y li ally e3 ited +ith a 4; urrent to run the motor in lo k+ise dire tion% $y re&ersing the phase se(uen e as 06' $8' 08' $6' anti lo k+ise stepping an be obtained% 8-P.0SE S?IT;.INB S;.E-E2 In this s heme' any t+o adOa ent stator +indings are energi/ed% The s+it hing s heme is sho+n in the table gi&en belo+% This s heme produ es more tor(ue% ANTICLOC<2ISE STE A A2 B B2 P 1 1 6 6 0 0 6 8 0 6 0 6 , 0 6 6 0 " 6 0 6 0 CLOC<2ISE DAT STE A A B A P 1 2 1 Kh 6 6 0 6 5h 8 0 6 6 !h , 0 6 0 0h " 6 0 0

B2 0 0 6 6

DAT A 0h !h 5h Kh

044<ESS 4E;D4INB LDBI;2

6,!

The 5"6,8 hip is used for generating the address de oding logi to generate the de&i e sele t pulses' ;S6 C ;S8 for sele ting the I; 5"655%The 5"655 lat hes the data bus to the stepper motor dri&ing ir uitry% Stepper -otor re(uires logi signals of relati&ely high po+er% Therefore' the interfa e ir uitry that generates the dri&ing pulses use sili on darlington pair transistors% The inputs for the interfa e ir uit are TTL pulses generated under soft+are ontrol using the -i ro ontroller #it% The TTL le&els of pulse se(uen e from the data bus is translated to high &oltage output pulses using a buffer 5"05 +ith open olle tor%

6,5

PROGRAM : A**r #-"600 OPCOD Label ES D<B ST0< -D* T2 "600h 4PT<' TT0$LE Load the start address of s+it hing s heme data T0$LE into 4ata Pointer =4PT<> Load the ount in <0 Load the number in T0$LE into 0 Push 4PT< &alue to Sta k Load the -otor port address into 4PT< Send the &alue in 0 to stepper -otor port address 4elay loop to ause a spe ifi amount of time delay before ne3t data item is sent to the -otor ;omments

"60, "605 "60! "608 "600 "604

-D* LDDP -D* 2 I

<0' T0" 0' U4PT<

P1S. 4P. P1S. 4PL -D* 4PT<' T0AA;0h -D* I -D* 4EL0 -D* E2 4EL0 4JN7 E62 4JN7 PDP U4PT<' 0

"60E "660 "668 "66" "66!

<"' T0AAh <5' T0AAh <5' 4EL0E6 <"' 4EL0E 4PL

6,8

"668 "660

PDP IN;

4P. 4PT<

"66$ "664

4JN7 <0' LDDP SJ-P ST0<T

"66A

T0$L 4$ E2

0K 05 0! 00h

PDP ba k 4PT< &alue from Sta k In rement 4PT< to point to ne3t item in the table 4e rement <0' if not /ero repeat the loop Short Oump to Start of the program to make the motor rotate ontinuously *alues as per t+o-phase s+it hing s heme

PROCEDURE: Enter the abo&e program starting from lo ation "600%and e3e ute the same% The stepper motor rotates% *arying the ount at <" and <5 an &ary the speed% Entering the data in the look-up T0$LE in the re&erse order an &ary dire tion of rotation% RESULT: Thus a stepper motor +as interfa ed +ith 8056 and run in for+ard and re&erse dire tions at &arious speeds%

6,K