Sunteți pe pagina 1din 91

DHANALAKSHMI COLLEGE OF ENGINEERING CHENNAI

CS 2252 MICPROCESSOR AND MICROCONTROLLER LABORATORY LABORATORY MANUAL

List of experiments
8085 Experiments
1. Addition of two 8 bit number without carry 2. Addition of two 8 bit number with carry 3. Subtraction of two 8 bit number without borrow . Subtraction of two 8 bit number with borrow 5. !u"tip"ication of two 8 bit numbers #. $i%ision of two 8 bit numbers &. Lar'est number in an array of n numbers 8. Sma""est number in an array of n numbers (. Sortin' of array in ascendin' order 10. Sortin' of array in descendin' order 11. )ro'rammab"e )ara""e" *nterface 8255 with 8085 12. *nterfacin' of 8251 and 8253 with 8085 13. *nterfacin' of &+se'ment disp"ay 82&( with 8085

808# Experiments
1 . Addition of two 1#+bit numbers , $irect Addressin' 15. Addition of two 1#+bit numbers , *ndexed Addressin' 1#. -ount the number of data stored in a strin' 1&. Searchin' a strin' in a 'i%en array 18. !o%in' a strin' from one memory "ocation to another

8051 Experiments
1(. Addition of two 1#+bit numbers 20. !u"tip"ication of two 8+bit numbers 21. $i%ision of two 8+bit numbers 22. Sum of .+E"ements in a 'i%en array 23. /indin' the "ar'est e"ement in an array

8085 EXPERIMENTS 1. ADDITION AND SUBTRACTION OF TWO 8 BIT NUMBERS WITHOUT CARRY AIM: To write an assembly language program to perform addition and subtraction of two 8 bit numbers without carry and to execute it using 8085 microprocessor. ALGORITHM:ADDITION OF TWO 8 BIT NUMBERS Step1:Get the first number in accumulator. Step :Get the second number in a register. Step!:"dd the two numbers. Step#:Store the result in the memory specified FLOWCHART:

PROGRAM: ADDRESS LABEL MNEMONICS OPCODE COMMENT

MANUAL CALCULATION:

OUTPUT:

MEMORY ADDRESS

INPUT ALUES

MEMORY ADDRESS

OUTPUT ALUES

ALGORITHM:SUBTRACTION OF TWO 8 BIT NUMBERS Step1:Get the first number in the accumulator Step :Get the second number in a register Step!:Subtract the two numbers Step#:Store the difference in the memory

FLOWCHART:

PROGRAM: ADDRESS LABEL MNEMONICS OPCODE COMMENT

MANUAL CALCULATION:

OUTPUT:

MEMORY ADDRESS

INPUT ALUES

MEMORY ADDRESS

OUTPUT ALUES

RESULT: Thus an assembly language program to perform 8 $ bit addition and subtraction of two 8 bit numbers %without carry &were written and the outputs were 'erified using 8085 micro processor (it .

2. ADDITION AND SUBTRACTION OF TWO 8 BIT NUMBERS WITH CARRY AIM: To write an assembly language program to perform addition and subtraction of two 8 bit numbers with carry and to execute it using 8085 microprocessor ALGORITHM:ADDITION OF TWO 8 BIT NUMBERS WITH CARRY Step1:Get the first number in the accumulator Step :Get the second number in a register Step!:"dd the two numbers Step#:)hec( for carry Step5:*f carry flag is set go to step + else go to step , Step+:*ncrement the carry Step,:Store the sum in the memory specified Step8:Store the carry in the memory specified FLOW CHART:

PROGRAM: ADDRESS LABEL MNEMONICS OPCODE COMMENTS

10

MANUAL CALCULATION:

OUTPUT:

MEMORY ADDRESS

INPUT ALUES

MEMORY ADDRESS

OUTPUT ALUES

ALGORITHM:SUBTRACTION OF TWO 8 BIT NUMBERS WITH BORROW Step1:Get the first number in the accumulator Step :Get the second number in a register Step!:Subtract the two numbers Step#:)hec( for borrow Step5:*f carry flag is set go to step + else go to step , Step+:*ncrement carry Step,:Store the difference in the memory specified Step8:Store the borrow in the memory specified

11

FLOW CHART:

12

PROGRAM: ADDRESS LABEL MNEMONICS OPCODE COMMENTS

13

MANUAL CALCULATION:

OUTPUT:

MEMORY ADDRESS

INPUT ALUES

MEMORY ADDRESS

OUTPUT ALUES

RESULT: Thus an assembly language program was written to perform addition and subtraction of two 8 bit numbers with carry. *t was executed using 8085 microprocessor and the output was 'erified.

14

!. ADDITION AND SUBTRACTION OF TWO 1" BIT NUMBERS AIM: To write an assembly language program to perform addition and subtraction of two 1+ bit numbers and to execute it using 8085 microprocessor. ALGORITHM:ADDITION OF TWO 1" BIT NUMBERS Step1:Get the first 1+ bit number in a register pair%say -.& Step :/xcahnge the contents of -. pair with 0/ pair Step!:Get the second 1+ bit number Step#:1erform double addition Step5:*f carry flag is set go to step + else go to step , Step+:*ncrement the carry Step,:Store the sum in the memory location specified Step8:Store the carry in the memory specified FLOWCHART:

15

PROGRAM: ADDRESS LABEL MNEMONICS OPCODE COMMENTS

16

MANUAL CALCULATION:

OUTPUT:

MEMORY ADDRESS

INPUT ALUES

MEMORY ADDRESS

OUTPUT ALUES

17

ALGORITHM:SUBTRACTION OF TWO 1" BIT NUMBERS Step1: Get the first 1+ bit number in -. pair Step : /xchange the contents of -. pair with 0/ pair Step!: Get the second number in -. pair Step#: Subtract the lower order bytes of the two register pairs Step5: Subtract the higher order bytes of the two register pairs with borrow Step+: *f borrow is present go to step 8 else go to step , Step,: *ncrement the borrow Step8: Store the difference in the memory specified Step2: Store the borrow in the memory specified FLOW CHART:

18

PROGRAM: ADDRESS LABEL MNEMONICS OPCODE COMMENTS

19

MANUAL CALCULATION:

OUTPUT:

MEMORY ADDRESS

INPUT ALUES

MEMORY ADDRESS

OUTPUT ALUES

RESULT: Thus an assembly language program was written to perform addition and subtraction of two 1+ bit numbers. *t was executed using 8085 microprocessor and the output was 'erified. 20

#. MULTIPLICATION OF TWO 8 BIT NUMBERS AIM: To write an assembly language program to perform multiplication of two 8 bit numbers and to execute it using 8085 microprocessor. ALGORITHM: Step1: *nitialise -l register pair and 3 register Step : Get the multiplicand Step!: Get the multiplier Step#: 1erform double addition of multiplicand and 3 register Step5: 0ecrement the multiplier Step+: *f 4ero flag is set go to step, else go to step # Step,: Store the product in the memory location specified Step8: -alt the program FLOW CHART:

21

PROGRAM: ADDRESS LABEL MNEMONICS OPCODE COMMENTS

22

MANUAL CALCULATION:

OUTPUT:

MEMORY ADDRESS

INPUT ALUES

MEMORY ADDRESS

OUTPUT ALUES

RESULT: Thus an assembly language program was written to perform multiplication of two 8 bit numbers. *t was executed using 8085 processor and the output was 'erified.

23

5. DI ISION OF TWO 8 BIT NUMBERS AIM: To write an assembly language program to perform di'ision of two 8 bit numbers and to execute it using 8085 microprocessor. ALGORITHM: Step1: Get the di'idend in the accumulator Step : Get the di'isor in a register %say 3& Step!: )ompare the di'idend and the di'isor Step#: *f di'idend is less than di'isor go to step , else go to step 5 Step5: Subtract the contents of accumulator and 3 register Step+: *ncrement the 5uotient Step,: Store the reminder in the memory Step8: Store the 5uotient in the memory FLOW CHART:

24

PROGRAM: ADDRESS LABEL MNEMONICS OPCODE COMMENTS

25

MANUAL CALCULATION:

OUTPUT:

MEMORY ADDRESS

INPUT ALUES

MEMORY ADDRESS

OUTPUT ALUES

RESULT: Thus an assembly language program was written to perform di'ision of two 8 bit numbers. *t was executed using 8085 microprocessor and the output was 'erified. 26

". LARGEST OF THE NUMBERS IN AN ARRAY AIM: To write an assembly language program to find the largest of the gi'en numbers and to execute it using 8085 processor. ALGORITHM: Step1: Get the count Step : Get the array of numbers using -. pointer Step!: 6o'e the contents in the memory to the accumulator Step#: 0ecrement the counter Step5: *f 4ero flag is set go to step 10 else go to step + Step+: Get the next data in a register%say 3& Step,: )ompare the contents of accumulator and 3 register Step8: *f carry flag is set go to step 2 else go to step # Step2: Swap the contents of accumulator and 3 register and 7ump to step # Step10: Store the largest number in the memory FLOW CHART:

27

PROGRAM: ADDRESS LABEL MNEMONICS OPCODE COMMENTS

28

MANUAL CALCULATION:

OUTPUT:

MEMORY ADDRESS

INPUT ALUES

MEMORY ADDRESS

OUTPUT ALUES

RESULT: Thus an assembly language program was written to find the largest number from the gi'en numbers .*t was executed using 8085 processor and the output was 'erified. 29

$. SMALLEST OF THE GI EN NUMBERS AIM: To write an assembly language program to find the smallest of the gi'en numbers and to execute it using 8085 processor. ALGORITHM: Step1: Get the count Step : Get the array of numbers using -. pointer Step!: 6o'e the contents in the memory to the accumulator Step#: 0ecrement the counter Step5: *f 4ero flag is set go to step 10 else go to step + Step+: Get the next data in a register%say 3& Step,: )ompare the contents of accumulator and 3 register Step8: *f carry flag is reset go to step 2 else go to step # Step2: Swap the contents of accumulator and 3 register and 7ump to step # Step10: Store the smallest number in the memory FLOW CHART:

30

PROGRAM: ADDRESS LABEL MNEMONICS OPCODE COMMENTS

31

MANUAL CALCULATION:

OUTPUT:

MEMORY ADDRESS

INPUT ALUES

MEMORY ADDRESS

OUTPUT ALUES

RESULT: Thus an assembly language program was written to find the smallest number from the gi'en numbers .*t was executed using 8085 processor and the output was 'erified. 32

8. SORTING OF ARRAY IN ASCENDING ORDER AIM: T% write an assembly language program to sort the gi'en numbers in ascending order and to execute it using 8085 microprocessor ALGORITHM: Step1: Get the count of the outer loop Step : Get the count of the inner loop Step!: *nitialise the memory pointer with t he address of the array Step#: Get the data from the memory Step5: Get the next data Step+: )ompare the two numbers Step,: *f carry flag is reset go to slep 8 else go to step 2 Step8: Swap the contents of consecuti'e memory locations Step2: 0ecrement the inner loop counter Step10: *f 4ero flag is set go to step 11 else go to step 5 Step11: 0ecrement the outer loop counter Step1 : *f 4ero flag is set go to step 1! else go to step Step1!:-alt the program FLOW CHART:

33

PROGRAM: ADDRESS LABEL MNEMONICS OPCODE COMMENTS

34

MANUAL CALCULATION:

OUTPUT:

MEMORY ADDRESS

INPUT ALUES

MEMORY ADDRESS

OUTPUT ALUES

RESULT: Thus an assembly language program was written to sort the gi'en numbers in ascending order. *t was executed using 8085 processor and the output was 'erified. 35

&.SORTING OF ARRAY IN DESCENDING ORDER AIM: To write an assembly language program to sort the gi'en numbers in descending order and to execute it using 8085 microprocessor ALGORITHM: Step1: Get the count of the outer loop Step : Get the count of the inner loop Step!: *nitialise the memory pointer with t he address of the array Step#: Get the data from the memory Step5: Get the next data Step+: )ompare the two numbers Step,: *f carry flag is set go to slep 8 else go to step 2 Step8: Swap the contents of consecuti'e memory locations Step2: 0ecrement the inner loop counter Step10: *f 4ero flag is set go to step 11 else go to step 5 Step11: 0ecrement the outer loop counter Step1 : *f 4ero flag is set go to step 1! else go to step Step1!:-alt the program FLOW CHART:

36

PROGRAM: ADDRESS LABEL MNEMONICS OPCODE COMMENTS

37

MANUAL CALCULATION:

OUTPUT:

MEMORY ADDRESS

INPUT ALUES

MEMORY ADDRESS

OUTPUT ALUES

RESULT: Thus an assembly language program was written to sort the gi'en numbers in descending order. *t was executed using 8085 processor and the output was 'erified. 38

10. E EN NUMBERS AIM: To write an assembly language program to sort the e'en numbers from the gi'en array and to execute it using 8085 microprocessor ALGORITHM: Step1: Get the si4e of the array%say in / register& Step : *nitialise a register pair with the address of the output array Step!: *nitialise a register to count the e'en numbers Step#: *nitialise -. pointer with the address of the input array Step5: 6o'e the number from memory to accumulator Step+: 8ight shift the data in accumulator by 1 Step,: *f carry flag is reset go to step 8 else got to step 1 Step8: *ncrement the count of e'en numbers Step2: 6o'e the data from memory to accumulator Step10: Store the data in register used to store e'en numbers Step11: *ncrement the address location used to store e'en numbers Step1 : Get the next number from the memory Step1!: 0ecrement the / counter Step1#: *f 4ero flag is set go to step 15 else go to step 5 Step15: Store the count of e'en numbers in the memory specified Step1+: -alt the program FLOW CHART:

39

PROGRAM: ADDRESS LABEL MNEMONICS OPCODE COMMENTS

40

MANUAL CALCULATION:

OUTPUT:

MEMORY ADDRESS

INPUT ALUES

MEMORY ADDRESS

OUTPUT ALUES

RESULT: Thus an assembly language program was written to sort the e'en numbers from the gi'en array of numbers. *t was executed using 8085 processor and the output was 'erified. 41

11. ODD NUMBERS

AIM: To write an assembly language program to sort the odd numbers from the gi'en array and to execute it using 8085 microprocessor ALGORITHM: Step1: Get the si4e of the array%say in / register& Step : *nitialise a register pair with the address of the output array Step!: *nitialise a register to count the e'en numbers Step#: *nitialise -. pointer with the address of the input array Step5: 6o'e the number from memory to accumulator Step+: 8ight shift the data in accumulator by 1 Step,: *f carry flag is set go to step 8 else got to step 1 Step8: *ncrement the count of odd numbers Step2: 6o'e the data from memory to accumulator Step10: Store the data in register used to store odd numbers Step11: *ncrement the address location used to store odd numbers Step1 : Get the next number from the memory Step1!: 0ecrement the / counter Step1#: *f 4ero flag is set go to step 15 else go to step 5 Step15: Store the count of odd numbers in the memory specified Step1+: -alt the program FLOW CHART:

42

PROGRAM: ADDRESS LABEL MNEMONICS OPCODE COMMENTS

43

MANUAL CALCULATION:

OUTPUT:

MEMORY ADDRESS

INPUT ALUES

MEMORY ADDRESS

OUTPUT ALUES

RESULT: Thus an assembly language program was written to sort the odd numbers from the gi'en array of numbers. *t was executed using 8085 processor and the output was 'erified. 44

12. TRANSFER OF BLOCK OF DATA AIM: To write an assembly language program to transfer a bloc( of data from one memory location to another and to execute it using 8085 microprocessor . ALGORITHM: Step1: Get the count of the data to be transferred Step : *nitialise -. pointer with the address of the input array Step!: *nitialise a register pair with the address of the output array Step#: Get the first input data Step5: 6o'e the data to accumulator Step5: Store it in the memory specified Step+: Get the next data Step,: *ncrement the output array Step8: 0ecrement the counter Step2: *f 4ero flag is set go to step10 else go to step 5 Step10: -alt the program FLOW CHART:

45

PROGRAM: ADDRESS LABEL MNEMONICS OPCODE COMMENTS

46

MANUAL CALCULATION:

OUTPUT:

MEMORY ADDRESS

INPUT ALUES

MEMORY ADDRESS

OUTPUT ALUES

RESULT: Thus an assembly language program was written to transfer a bloc( of data from one memory to another. *t was executed using 8085 processor and the output was 'erified. 47

INTERFACING 8255 ' PROGRAMMABLE PARALLEL INTERFACE (PPI) TO 8085 MICROPROCESSOR AIM: To write assembly language programs to interface 8 55 with 8085 microprocessor by configuring it three different modes %mode09 mode19 mode &. M%*+0: ALGORITHM: Step1: Start Step : *nitiali4e the control register for mode0 configuration. Step!: Send the analog data to the memory. Step#: Send the con'erted data to the display and sa'e the data in memory. Step5: Stop.
)0120A!!A3LE )A0ALLEL *.4E0/A-E 5))*6+ 8255 Table 1: Table !:

ADDRESS #100 #101 #10 #10! #10# #105 #10+ #10, #108

OPCODE !/ 20 0! )+ 03 )0 0! ) ,+

MNEUMONICS 6:* "920 ;<T )+ => )0 ;<T ) -.T

ADDRESS #100 #101 #10 #10! #10# #105 #10+ #10, #108

OPCODE !/ 80 0! )+ !/ 55 0! ) ,+

MNEUMONICS 6:* "980 ;<T )+ 6:* "955 ;<T ) -.T

ADDRESS #100 #101 #10 #10! #10# #105 #10+ #10, #108 #102

OPCODE !/ 20 0! )+ 03 )0 ! 00 #! ,+

MNEUMONICS 6:* "920 ;<T )+ => )0 ST" #!00

48
-.T

ADDRESS #100 #101 #10 #10! #10# #105 #10+ #10, #108 #102 #10" #103 Table 2:

OPCODE !/ 20 0! )+ 03 )0 ! 00 #! 0! ) ,+

MNEUMONICS 6:* "920 ;<T )+ => )0 ST" #!00

;<T ) -.T

49

Fig 1: Block Diagram of 8255A Programmable Parallel !"erface #PP $

Fig 2: 8255 %o&e Defi!i"io! Forma" 50

Fig 3: Bi" 'e" ( )e*e" +o!"rol ,or& forma" of 8255 MODE 0 OPERATION: SIMPLE I,O TRANSFER ADDRESS #100 #10 #10# #10+ #108 OPCODE !/9 20 0!9 )+ 039 )0 0!9 ) ,+ MNEUMONICS COMMENTS 6:* "920 6o'e control word to accumulator ;<T )+ .oad control word to control register of 8 55 *> )0 Gi'e input to 1ort ) ;<T ) Send it to 1ort " -.T Stop the process

MODE 0 OPERATION: STORE ALUE TO PROCESSOR MEMORY ADDRESS OPCODE MNEUMONICS COMMENTS #100 !/9 20 6:* "920 6o'e control word to accumulator #10 0!9 )+ ;<T )+ .oad control word to control register of 8 55 #10# 039 )0 *> )0 Gi'e input to 1ort ) #10+ ! 9 009 #! ST" #!00 Store to memory location #!00 #102 ,+ -.T Stop the process MODE 0 OPERATION: LOAD ALUE FROM PROCESSOR MEMORY ADDRESS OPCODE MNEUMONICS COMMENTS #100 !/9 80 6:* "980 6o'e control word to accumulator #10 0!9 )+ ;<T )+ .oad control word to control register of 8 55 #10# !/9 55 6:* "955 .oad input from processor 51

#10+ #108

0!9 ) ,+

;<T ) -.T

memory Send it to 1ort " Stop the process

MODE 0 OPERATION: STORE ALUE TO PROCESSOR MEMORY ADDRES OPCODE MNEUMONICS COMMENTS S #100 !/9 20 6:* "920 6o'e control word to accumulator #10 0!9 )+ ;<T )+ .oad control word to control register of 8 55 #10# 039 )0 *> )0 Gi'e input to 1ort ) #10+ ! 9 009 ST" #!00 Store to memory location #!00 #! #102 0!9 ) ;<T ) Send it to 1ort " #103 ,+ -.T Stop the process

52

R+-./0: Thus the program for programmable parallel interface %11*& to 8085 microprocessor was executed and 'erified

53

INTERFACING 825! ' TIMER, COUNTER AND 8251 ' USART TO 8085 MICROPROCESSOR AIM To write assembly language program to interface 8 51 and 8 5! with 8085 6icroprocessor and to transmit and recei'e data serially through 8 51. ALGORITHM 1. . !. #. 5. +. ,. 8. To Transmit 0ata serially9 initiali4e a counter. .oad the 1+?bit count in the counter. .oad the control word in 8 51. Send the data to 8 51. -alt. To recei'e data serially9 get the data from 8 51. Sa'e the data in memory. -alt

INTERFACING 8251 USART

/i'. 1 3"oc7 $ia'ram of 8251

54

55

INTERFACING 825! TIMER, COUNTER

56

B/%12 *345647 %8 825! PROGRAM T649-7300+6 S3*+ MEMORY OPCODE MNEMONICS COMMENTS #100 !/9 !+ 6:* "9!+)onfigure 8 5! to count binary9mode!9 read @ load .S3 first then 6S39 counter 0 #10 0!9 )/ ;<T )/ .oad control word to control register of 8 5! #10# !/9 0" 6:* "9 0"6o'e lower 8 bit count 'alue to accumulator #10+ 0!9 )8 ;<T )8.oad count to channel 0 of 8 5! #108 !/9 00 6:* "9006o'e upper 8 bit count 'alue to accumulator #10" 0!9)8 ;<T )8.oad count to counter 0 of 8 5! #10) !/9 #/ 6:* "9 #/ )onfigure mode instruction of 8 51 #10/ 0!9) ;<T ) .oad control word to control register of 8 51 #110 !/9 !, 6:* "9!, )onfigure command instruction of 8 51 #11 0!9) ;<T ) .oad control word to control register of 8 51 #11# !/9#1 6:* "9#16o'e serial data to be transmitted #11+ 0!9)0 ;<T )0.oad the serial data to data register #118 ,+ -.T Stop the process

57

R+1+3:+6 S3*+ MEMORY # 00 # 0 # 05 O.0;.0 M+7%6< 4**6+-I9;.0 :4/.+ M+7%6< 4**6+-O.0;.0 :4/.+ OPCODE 039)0 ! 9 509#1 ,+ MNEMONICS *> )0 ST" #150 -.T COMMENTS Get the serial data from data register Store in #150 memory location of 8085 Stop the process

RESULT Thus the "ssembly language programs to interface 8 51 and 8 5! with 8085 were written and the data was transmitted and recei'ed serially using 8 51.They were executed and the output was 'erified.

58

. INTERFACING 82$& KEYBOARD , DISPLAY CONTROLLER WITH 8085 MICROPROCESSOR AIM: To write an assembly language program to interface 8 ,2 to 8085 microprocessor. ALGORITHM: Step1: Start Step : *nitiali4e the accumulator. Step!: .oad the appropriate command words in control register. Step#: .oad the appropriate words for the characters to be the accumulator in analog form. Step5: Send the con'erted data to 8 ,2 display. Step+: Stop. FLOW CHART:

displayed9 in

59

PROGRAM: MEMORY #100 #10! #105 #10, #102 #103 #100 #10B #111 #11 #11# #11, #118 #112 #11) #11B #1 1 #1 ! #1 # #1 , #1 8 #1 3 OPCODE MNEMONICS 19 )9 #1 .A* -9 #1 ) 1+9 0B 6:* 090B !/9 10 0!9) !/9 )) 0!9) !/9 20 0!9) ,/ 0!9 )0 )09 1B9 #1 ! 15 6:* "910 ;<T ) 6*: "9)) ;<T ) 6:* "920 ;<T ) 6;: "96 ;<T )0 )".. #11B *>A 0)8 0 COMMENTS .oad pointer address to -. register 6o'e loo( up table count 'alue to 0 register Set display mode to right entry .oad control word into control register )lear 0isplay 8"6 .oad control word into control register 8ead data to display memory .oad control word into control register 6o'e -. memory content to accumulator 6o'e to ./0 segment register 6o'e program control to #11B?delay loop *ncrement -. by one memory location 0ecrement count 'alue of loo( up table =ump to #111 till count 'alue reaches 4ero 0isplay the loo( up table 'alues continually .oad outer delay count 'alue to 3 register .oad inner delay count 'alue to ) resister 0ecrement ) register content =ump to #1 ! till count 'alue reaches 4ero 0ecrement 3 register content =ump to #1 1 till count 'alue reaches 4ero 8eturn to main program

) 9 119 #1 =>C #111 )!9 009 #1 =61 #100 0+9 "0 0/9 BB 6:* 39 0" 6:* )9BB

00 0)8 ) ) 9 !9 #1 =>C #1 ! 05 0)8 3 ) 9 19 #1 =>C #1 1 )2 8/T

60

LOOK UP TABLE: 6/6;8D #1 ) #1 0 #1 / #1 B #1!0 #1!1 #1! #1!! *>1<T BB BB BB BB BB BB BB BB 6/6;8D #1!# #1!5 #1!+ #1!, #1!8 #1!2 #1!" #1!3 *>1<T BB 28 +8 ,) )8 BB BB BB

RESULT: Thus an assembly language program was written to interface 8 ,2 with 8085 microprocessor. *t was executed and the output was 'erified

61

INTERFACING STEPPER MOTOR WITH 8085 AIM: To write on "ssembly .anguage 1rogram to interface a stepper motor with 8085 6icroprocessor. ALGORITHM: 1. Get the dri'e se5uence using -. pointer. . *nitiali4e a counter for appropriate number of steps. !. Get the dri'e Se5uence from memory to accumulator. #. Send the data to stepper motor. 5. )all 0elay. +. Get the next se5uence to accumulator. ,. 0ecrement the counter. 8. )hec( 4ero flag. 2. *f 4ero flag is reset go to step! else go to step10. 10. =ump to step 1. FLOW CHART:

62

PROGRAM: "ddress #100 .abel Start 6nemonics .A* -9 # 00;pcode 19009# )omments .oad the immediate data # 00h to -. pointer. 6o'e the immediate data 0#h to ) register. 6o'e the contents of 6 register to accumulator ;ut the data to the port with address )0h. .oad 0/ register pair with immediate data 1010h 0ecrement the contents of 0/ register pair by one. 6o'e the contents of / register to accumulator. ;8 the contents of 0 register with that of accumulator. =ump on no 4ero to the address specified by label E0elayF *ncrement the

#10!

6:* )9 0#-

0/9 0#9

#105

>ext

6;: "9 6

=/

#10+

;<T )0-

0!9 )0

#108

.A* 09 1010-

119 109 10

#103

0elay

0)A 0

13

#10)

6;: "9 /

,3

#100

;8" 0

#10/

=>C 0elay

) 9 039 #1

#111

*>A -

63

#11

0)8 )

00

#11!

=>C >ext

) 9 059 #1

#11+

=61 Start

)!9 009 #1

contents of -. pointer by one. 0ecrement the contents of ) register by one. =ump on no 4ero to the address specified by label to E>extF. =ump unconditionally to the address specified by the label EStartF

RESULT: Thus an assembly language program to interface stepper motor with 8085 processor was written. *t was executed and the output was 'erified.

64

808" EXPERIMENTS
ADDITION OF TWO 1" BIT NUMBERS IMMEDIATE ADDRESSING AIM: To write an assembly language program to perform addition of two 1+ bit numbers with immediate addressing and to execute it using 808+ microprocessor. ALGORITHM:ADDITION OF TWO 8 BIT NUMBERS Step1: Get the first number in accumulator. Step : Get the second number in a register. Step!: "dd the two numbers. Step#: Store the result in the memory specified Step5: Terminate the program execution FLOW CHART:

65

PROGRAM: ADDRESS OPCODE MNEMONICS COMMENTS

66

MANUAL CALCULATION:

OUTPUT:

MEMORY ADDRESS

INPUT ALUES

MEMORY ADDRESS

OUTPUT ALUES

RESULT: Thus an assembly language program was written to perform addition of two 1+ bit numbers by using immediate addressing mode. *t was executed using 808+ processor and the output was 'erified.

67

ADDITION OF TWO 1" BIT NUMBERS DIRECT ADDRESSING AIM: To write an assembly language program to perform addition of two 1+ bit numbers with direct addressing and to execute it using 808+ microprocessor . ALGORITHM:ADDITION OF TWO 8 BIT NUMBERS Step1: Get the first number in accumulator. Step : Get the second number in a register. Step!: "dd the two numbers. Step#: Store the result in the memory specified Step5: Terminate the program execution FLOW CHART:

68

PROGRAM: ADDRESS OPCODE MNEMONICS COMMENTS

69

MANUAL CALCULATION:

OUTPUT:

MEMORY ADDRESS

INPUT ALUES

MEMORY ADDRESS

OUTPUT ALUES

RESULT: Thus an assembly language program was written to perform addition of two 1+ bit numbers by using immediate addressing mode. *t was executed using 808+ processor and the output was 'erified.

70

ADDITION OF TWO 1" BIT NUMBERS INDEXED ADDRESSING AIM: To write an assembly language program to perform addition of two 1+ bit numbers with indexed addressing and to execute it using 808+ microprocessor. ALGORITHM:ADDITION OF TWO 8 BIT NUMBERS Step1: Get the first number in a register. Step : Get the second number in accumulator. Step!: "dd the two numbers. Step#: Store the result in the memory specified Step5: Terminate the program execution FLOW CHART:

71

PROGRAM: ADDRESS OPCODE MNEMONICS COMMENTS

72

MANUAL CALCULATION:

OUTPUT:

MEMORY ADDRESS

INPUT ALUES

MEMORY ADDRESS

OUTPUT ALUES

RESULT: Thus an assembly language program was written to perform addition of two 1+ bit numbers by using indexed addressing mode. *t was executed using 808+ processor and the output was 'erified.

73

COUNT THE NUMBER OF DATA IN A STRING AIM: To write an assembly language program to count the number of data in a string and to execute it using 808+ microprocessor. ALGORITHM:ADDITION OF TWO 8 BIT NUMBERS 1. . !. #. 5. +. ,. 8. *nitiali4e the memory location in to source register .oad BBBB- to 0A register Get the count 'alue in to accumulator *ncrement the 0A register content by one 6o'e the content of S* in to ". register )ompare ". with "h register =ump on no 4ero9 go to location specified in the instruction store the result in to memory location

FLOW CHART:

74

PROGRAM: MEMORY ADDRESS 1000 100! 100+ 1008 1002 1003 100) 100/ 1010 101# OPCODE 3/9 009 1 3"9 BB9 BB 3#9 BB # 8"9 0# #+ !89 )# ,59 B8 829 1+9 009 11 )) MNEMONICS 6;: S*9 1 00 6;: 0A9 BBBB 6;: "-9 BB *>) 0A 6;: ".9 GS*H *>) S* )61 "-9 ". =>C 1008 6;: G1100H9 0A *>T! COMMENTS .oad memory location 1 00- to S* .oad 'alue BBBB- to 0A register .oad 'alue BB- that specifies end of count *ncrement 0A to reset its 'alue 6o'e data pointed by S* register to ". *ncrement S* register content )ompare ". with "- register content =ump on no 4ero to location ????????? 6o'e the count 'alue in 0A to location 1100)all 3rea( 1oint interrupt

MANUAL CALCULATION:

75

OUTPUT:

MEMORY ADDRESS

INPUT ALUES

MEMORY ADDRESS

OUTPUT ALUES

RESULT: Thus an assembly language program was written to perform count the number of data in a string. *t was executed using 808+ processor and the output was 'erified. . SEARCHING A STRING IN A GI EN ARRAY

76

AIM: To write an assembly language program to searching a string in a gi'en array and to execute it using 808+ microprocessor . ALGORITHM:ADDITION OF TWO 8 BIT NUMBERS 1. *nitiali4e the memory location in to source register . *nitiali4e the memory location in to destination register !. Get the count 'alue in to ). and 0. #. )ompare 0. with ". register 5. =ump on 4ero9 go to location specified in the instruction +. 0ecrement the ). register ,. *ncrement the 0A register content by one 8. =ump on no 4ero9 go to location specified in the instruction 2. 6o'e the content of "l in to 0* register 10. store the result in to memory location FLOW CHART:

77

PROGRAM: MEMORY ADDRESS 1500 150! 150+ 1508 150" 1503 1500 150B 1511 151! 1515 151+ 1518 1512 1513 151) 151/ OPCODE MNEMONICS 3B9 009 1! 3/9 009 1 319 10 3 9 01 ") !89 ) ,#9 05 B/9 )2 ,59 B, 889 05 #/ 829 B! #, 889 10 #, 889 !0 )) 6;: 0*9 1!00 6;: S*9 1 00 6;: ).9 10 6;: 0.9 01 .;0S3 )61 0.9 ". =C 151! 0/) ). =>C 150" 6;: G0*H9 ". 0/) S* 6;: 3A9 S* *>) 0* 6;: G0*H9 3. *>) 0* 6;: G0*H9 3*>T! COMMENTS .oad memory location 1!00- to 0* for result .oad memory location 1 00- to S* for storing data .oad count 'alue 10- to ). register .oad the string 01 to be searched into 0. .oads byte at address 0S:%/&S* into ". )ompares the contents of ". with 01*f 4ero flag is set 7ump to location 151! 0ecrement ). register content =ump to location 150" till count 'alue is non 4ero Store the searched string 01- in ". to 0* pointed location 1!000ecrement memory location in S* 6o'e location of occurrence of string to 3A register *ncrement 0* register 'alue to 1!01 6o'e lower byte of location to 0* *ncrement 0* register 'alue to 1!0 6o'e upper byte of location to 0* )all 3rea( 1oint interrupt

MANUAL CALCULATION:

78

OUTPUT:

MEMORY ADDRESS

INPUT ALUES

MEMORY ADDRESS

OUTPUT ALUES

RESULT: Thus an assembly language program was written to perform searching a string in a gi'en array. *t was executed using 808+ processor and the output was 'erified. MO E THE BLOCK OF DATA FROM ONE MEMORY LOCATION TO ANOTHER

79

AIM: To write an assembly language program to mo'e the bloc( of data from one memory location to another and to execute it using 808+ microprocessor. PROGRAM MEMORY ADDRESS 1000 100 1005 1008 1002 1003 100) 100/ 1010 OPCODE MNEMONICS 319 08 3/9 009 1# 3B9 509 1# ") 889 05 #, B/9 )2 ,59 B8 )) 6;: ).9 08 6;: S*9 1 00 6;: 0*9 1!00 .;0S3 6;: G0*H9 ". *>) 0* 0/) ). =>C 1008 *>T! COMMENTS .oad number of bytes to be mo'ed to ). .oad address in S* for storing data .oad address in 0* for storing result .oads byte at address 0S:%/&S* into ". Store the result in specified location *ncrement pointer location to 1!01 0ecrement count 'alue loaded in ). =ump to location 1008 till count 'alue is non 4ero )all 3rea( 1oint interrupt

MANUAL CALCULATION:

80

OUTPUT:

MEMORY ADDRESS

INPUT ALUES

MEMORY ADDRESS

OUTPUT ALUES

RESULT: Thus an assembly language program was written mo'e the bloc( of data from one memory location to another. *t was executed using 808+ processor and the output was 'erified.

81

8051 EXPERIMENTS
ADDITION OF TWO 1" BIT NUMBERS AIM: To write an assembly language program to add two 1+ bit numbers and to execute it using 8051 microprocessor PROGRAM: MEMORY ADDRESS #100 #101 #10! #105 #108 #102 #10" #10) OPCODE )! ,#9!# #9,8 209#1950 B0 "! ,#91 !#95+ LABEL MNEMONICS ).8 ) 6;: "9 I!# COMMENTS

#10/

B0

#10B

809B/

-/8/

)lear )arry flag ) .oad lower byte first operant to " "00 "9I,8 "dd the lower byte second operant with " content 6;: 01T89I#150 .oad data pointer register %01T8& with address #150 6;: J01T89" 6o'e the content of " to address pointed by 01T8 *>) 01T8 *ncrement 01T8 content 6;: "9I1 .oad higher byte first operant to " "00) "9I5+ "dd the higher byte second operant to content of " register with carry 6;: J01T89" 6o'e " register content to the address pointed by 01T8 register S=61 -/8/ Stop the execution

82

MANUAL CALCULATION:

OUTPUT:

MEMORY ADDRESS

INPUT ALUES

MEMORY ADDRESS

OUTPUT ALUES

RESULT: Thus an assembly language program was written for addition of two 1+? bit numbers was executed using 8051 processor and the output was 'erified

83

. MULTIPLICATION OF TWO 8 BIT NUMBERS AIM: To write an assembly language program to multiply two 8 bit numbers and to execute it using 8051 microprocessor PROGRAM: MEMORY OPCODE ADDRESS #100 ,#908 #10 #105 ,59B090# "# LABEL MNEMONICS 6;: "9I08 6;: 39 I0# 6<. "93 COMMENTS .oad immediate 'alue to "ccumulator .oad immediate 'alue to 3 register 6ultiples the "ccumulator by the 3 register. The least significant byte of the result is in "ccumulator and the most?significant? byte is in 3 register .oad memory location #500 to 01T8 register "ccumulator is mo'ed to the 1+?bit /xternal 6emory address indicated by 01T8 *ncrement 01T8 content 6o'e most significant byte of result to "ccumulator "ccumulator is mo'ed to the 1+?bit /xternal 6emory address indicated by 01T8 Stop the execution

#10+ #102

209#5900 B0

6;: 01T89I#500 6;:A J01T89"

#10" #103 #100

"! /59B0 B0

*>) 01T8 6;: "93 6;:A J01T89"

#10/

809B/

-/8/

S=61 -/8/

84

MANUAL CALCULATION:

OUTPUT:

MEMORY ADDRESS

INPUT ALUES

MEMORY ADDRESS

OUTPUT ALUES

RESULT: Thus an assembly language program was written for multiplication of two 8?bit numbers was executed using 8051 processor and the output was 'erified.

85

DI ISION OF TWO 8 BIT NUMBERS AIM: To write an assembly language program to 0i'ide two 8 bit numbers and to execute it using 8051 microprocessor. PROGRAM: MEMORY ADDRES S #100 #10 #105 OPCOD E ,#908 ,59B090# 20 LABEL MNEMONICS 6;: "9I08 6;: 39 I0# 0*: "93 COMMENTS .oad immediate 'alue to "ccumulator .oad immediate 'alue to 3 register 0i'ides the "ccumulator by the 3 register. The resulting 5uotient is in "ccumulator and the remainder in 3 register .oad memory location #500 to 01T8 register "ccumulator is mo'ed to the 1+?bit /xternal 6emory address indicated by 01T8 *ncrement 01T8 content 6o'e the remainder to "ccumulator "ccumulator is mo'ed to the 1+?bit /xternal 6emory address indicated by 01T8 Stop the execution

#10+ #102

209#5900 B0

6;: 01T89I#500 6;:A J01T89"

#10" #103 #100

"! /59B0 B0

*>) 01T8 6;: "93 6;:A J01T89"

#10/

809B/

-/8/

S=61 -/8/

MANUAL CALCULATION:

86

OUTPUT:

MEMORY ADDRESS

INPUT ALUES

MEMORY ADDRESS

OUTPUT ALUES

RESULT: Thus an assembly language program was written for di'ision of two 8?bit numbers was executed using 8051 processor and the output was 'erified.

SUM OF N ELEMENTS IN AN ARRAY

87

AIM: To write an assembly language program to find sum of >?elements in an array and to execute it using 8051 microprocessor. PROGRAM: MEMORY ADDRESS #100 #10! #10# #105 #108 #10" #103 #10) #10/ #10B #11 #11! #11# #11+ #112 #11" #113 #11) #11/ #11B OPCODE LABEL 209# 900 /0 B8 ,59B0900 "29B0 )! /0 /59B0 B5 B0950901 02 "! 089B# 209#5900 /2 B0 "! /59B0 B0 809B/ -/8/ >) "00 MNEMONICS 6;: 01T89I# 00 6;: "9J01T8 6;: 809" 6;: 39I0 6;: 8193 ).8 ) 6;: "9J01T8 "00 "93 6;: 39" =>) >) *>) 81 *>) 01T8 0=>C 809"00 6;: 01T89 I#500 6;: "981 6;:A J01T89" *>) 01T8 6;: "93 6;:A J01T89" S=61 -/8/ COMMENTS .oad location #500 to 01T8 .oad 01T8 content to " 6o'e "ccumulator to 80 .oad 3 register with 4ero 6o'e 3 register content to 81 )lear )arry flag ) 6o'e content of 01T8 to " "dd "ccumulator to 3 register 6o'e "ccumulator to 3 register =ump to #11# if )arry is not set *ncrement 81 register content *ncrement 01T8 content 0ecrement 8egister 80 and =ump if >ot Cero to "00 .oad 01T8 with location #500 6o'e 81 content to " "ccumulator is mo'ed to the 1+?bit /xternal 6emory address indicated by 01T8 *ncrement 01T8 content 6o'e "ccumulator to 3 register "ccumulator is mo'ed to the 1+?bit /xternal 6emory address indicated by 01T8 Stop the execution

MANUAL CALCULATION: 88

OUTPUT:

MEMORY ADDRESS

INPUT ALUES

MEMORY ADDRESS

OUTPUT ALUES

RESULT: Thus an assembly language program was written for Sum of >?elements in an array was executed using 8051 processor and the output was 'erified. LARGEST ELEMENT IN AN ARRAY

89

AIM: To write an assembly language program to find the largest element in an array and to execute it using 8051 microprocessor. PROGRAM: MEMORY ADDRES S #100 #10! #10+ #105 #108 OPCODE 209# 900 ,59#0900 ,090" ,59B0900 /0 LABEL MNEMONICS 6;: 01T89I# 00 6;: #09I00 6;: 859" 6;: 39I0 6;:A "9J01T8 COMMENTS .oad location # 00 to 01T8 .oad 4ero to memory #06o'e "ccumulator to 85 .oad 4ero to 3 register "ccumulator is mo'ed to1+ bit /xternal 6emory address indicated by 01T8 )ompare " with contents of location #0- and =ump if >ot /5ual to .;;11 *ncrement 01T8 content 0ecrement 8egister 85 and =ump if >ot Cero to .;;1 6o'e 'alue in location #0- to "ccumulator "ccumulator is mo'ed to1+ bit /xternal 6emory address indicated by 01T8 Stop the execution =ump if )arry Set to .;;1! 6o'e " to location #01erform short 7ump to location .;;1

.;;1

#102 #10) #100 #10B #111

359#091# "! 009B2 /59#0 B0 .;;1!

)=>/ "9#0 .;;11 *>) 01T8 0=>C 859.;;1 6;: "9#0 6;:A J01T89"

#11 #11# #11+ #118

809B/ #09B+ B59#0 B

-.T .;;11

S=61 -.T =) .;;1! 6;: #09" S=61 .;;1

MANUAL CALCULATION: 90

OUTPUT:

MEMORY ADDRESS

INPUT ALUES

MEMORY ADDRESS

OUTPUT ALUES

RESULT: Thus an assembly language program was written for the largest element in an array was executed using 8051 processor and the output was 'erified.

91