mp+lab_new[1]

download mp+lab_new[1]

of 91

Transcript of mp+lab_new[1]

  • 8/13/2019 mp+lab_new[1]

    1/91

    DHANALAKSHMI COLLEGE OF ENGINEERINGCHENNAI

    CS 2252 MICPROCESSOR ANDMICROCONTROLLER LABORATORY

    LABORATORY MANUAL

    1

  • 8/13/2019 mp+lab_new[1]

    2/91

    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 numbers8. 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

    2

  • 8/13/2019 mp+lab_new[1]

    3/91

    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

    3

  • 8/13/2019 mp+lab_new[1]

    4/91

    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 oftwo 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:

    4

  • 8/13/2019 mp+lab_new[1]

    5/91

    PROGRAM:

    ADDRESS LABEL MNEMONICS OPCODE COMMENT

    MANUAL CALCULATION:

    5

  • 8/13/2019 mp+lab_new[1]

    6/91

    OUTPUT:

    ALGORITHM:SUBTRACTION OF TWO 8 BIT NUMBERSStep1:Get the first number in the accumulatorStep:Get the second number in a registerStep!:Subtract the two numbersStep#:Store the difference in the memory

    FLOWCHART:

    6

    MEMORYADDRESS

    INPUT ALUES MEMORYADDRESS

    OUTPUT ALUES

  • 8/13/2019 mp+lab_new[1]

    7/91

    PROGRAM:

    ADDRESS LABEL MNEMONICS OPCODE COMMENT

    7

  • 8/13/2019 mp+lab_new[1]

    8/91

    MANUAL CALCULATION:

    OUTPUT:

    RESULT:

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

    8

    MEMORYADDRESS

    INPUT ALUES MEMORYADDRESS

    OUTPUT ALUES

  • 8/13/2019 mp+lab_new[1]

    9/91

    2. ADDITION AND SUBTRACTION OF TWO 8 BIT NUMBERS WITH CARRY

    AIM:

    To write an assembly language program to perform addition and subtraction oftwo 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 accumulatorStep:Get the second number in a registerStep!:"dd the two numbersStep#:)hec( for carryStep5:*f carry flag is set go to step + else go to step ,Step+:*ncrement the carryStep,:Store the sum in the memory specifiedStep8:Store the carry in the memory specified

    FLOW CHART:

    9

  • 8/13/2019 mp+lab_new[1]

    10/91

    PROGRAM:

    ADDRESS LABEL MNEMONICS OPCODE COMMENTS

    10

  • 8/13/2019 mp+lab_new[1]

    11/91

    MANUAL CALCULATION:

    OUTPUT:

    ALGORITHM:SUBTRACTION OF TWO 8 BIT NUMBERS WITH BORROWStep1:Get the first number in the accumulatorStep:Get the second number in a registerStep!:Subtract the two numbersStep#:)hec( for borrowStep5:*f carry flag is set go to step + else go to step ,Step+:*ncrement carryStep,:Store the difference in the memory specifiedStep8:Store the borrow in the memory specified

    11

    MEMORYADDRESS

    INPUT ALUES MEMORYADDRESS

    OUTPUT ALUES

  • 8/13/2019 mp+lab_new[1]

    12/91

    FLOW CHART:

    12

  • 8/13/2019 mp+lab_new[1]

    13/91

    PROGRAM:

    ADDRESS LABEL MNEMONICS OPCODE COMMENTS

    13

  • 8/13/2019 mp+lab_new[1]

    14/91

    MANUAL CALCULATION:

    OUTPUT:

    RESULT:

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

    14

    MEMORYADDRESS

    INPUT ALUES MEMORYADDRESS

    OUTPUT ALUES

  • 8/13/2019 mp+lab_new[1]

    15/91

    !. ADDITION AND SUBTRACTION OF TWO 1" BIT NUMBERS

    AIM:To write an assembly language program to perform addition and subtraction oftwo 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 / pairStep!:Get the second 1+ bit numberStep#:erform double additionStep5:*f carry flag is set go to step + else go to step ,Step+:*ncrement the carryStep,:Store the sum in the memory location specifiedStep8:Store the carry in the memory specified

    FLOWCHART:

    15

  • 8/13/2019 mp+lab_new[1]

    16/91

    PROGRAM:

    ADDRESS LABEL MNEMONICS OPCODE COMMENTS

    16

  • 8/13/2019 mp+lab_new[1]

    17/91

    MANUAL CALCULATION:

    OUTPUT:

    17

    MEMORYADDRESS

    INPUT ALUES MEMORYADDRESS

    OUTPUT ALUES

  • 8/13/2019 mp+lab_new[1]

    18/91

    ALGORITHM:SUBTRACTION OF TWO 1" BIT NUMBERS

    Step1: Get the first 1+ bit number in - pairStep: /xchange the contents of - pair with / pairStep!: Get the second number in - pairStep#: Subtract the lower order bytes of the two register pairsStep5: Subtract the higher order bytes of the two register pairs with borrowStep+: *f borrow is present go to step 8 else go to step ,Step,: *ncrement the borrowStep8: Store the difference in the memory specifiedStep2: Store the borrow in the memory specified

    FLOW CHART:

    18

  • 8/13/2019 mp+lab_new[1]

    19/91

    PROGRAM:

    ADDRESS LABEL MNEMONICS OPCODE COMMENTS

    19

  • 8/13/2019 mp+lab_new[1]

    20/91

    MANUAL CALCULATION:

    OUTPUT:

    RESULT:

    Thus an assembly language program was written to perform addition andsubtraction of two 1+ bit numbers. *t was executed using 8085 microprocessorand the output was 'erified.

    20

    MEMORYADDRESS

    INPUT ALUES MEMORYADDRESS

    OUTPUT ALUES

  • 8/13/2019 mp+lab_new[1]

    21/91

    #. MULTIPLICATION OF TWO 8 BIT NUMBERS

    AIM:

    To write an assembly language program to perform multiplication of two 8bit numbers and to execute it using 8085 microprocessor.

    ALGORITHM:

    Step1: *nitialise -l register pair and 3 registerStep: Get the multiplicandStep!: Get the multiplierStep#: erform double addition of multiplicand and 3 registerStep5: ecrement the multiplierStep+: *f 4ero flag is set go to step, else go to step #Step,: Store the product in the memory location specifiedStep8: -alt the program

    FLOW CHART:

    21

  • 8/13/2019 mp+lab_new[1]

    22/91

  • 8/13/2019 mp+lab_new[1]

    23/91

    MANUAL CALCULATION:

    OUTPUT:

    RESULT:

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

    23

    MEMORYADDRESS

    INPUT ALUES MEMORYADDRESS

    OUTPUT ALUES

  • 8/13/2019 mp+lab_new[1]

    24/91

    5. DIISION OF TWO 8 BIT NUMBERS

    AIM:

    To write an assembly language program to perform di'ision of two 8 bitnumbers and to execute it using 8085 microprocessor.

    ALGORITHM:

    Step1: Get the di'idend in the accumulatorStep: Get the di'isor in a register %say 3&Step!: )ompare the di'idend and the di'isorStep#: *f di'idend is less than di'isor go to step , else go to step 5Step5: Subtract the contents of accumulator and 3 registerStep+: *ncrement the uotientStep,: Store the reminder in the memoryStep8: Store the uotient in the memory

    FLOW CHART:

    24

  • 8/13/2019 mp+lab_new[1]

    25/91

    PROGRAM:

    ADDRESS LABEL MNEMONICS OPCODE COMMENTS

    25

  • 8/13/2019 mp+lab_new[1]

    26/91

  • 8/13/2019 mp+lab_new[1]

    27/91

    ". LARGEST OF THE NUMBERS IN AN ARRAY

    AIM:

    To write an assembly language program to find the largest of the gi'ennumbers and to execute it using 8085 processor.

    ALGORITHM:

    Step1: Get the countStep: Get the array of numbers using - pointerStep!: 6o'e the contents in the memory to the accumulatorStep#: ecrement the counterStep5: *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 registerStep8: *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

  • 8/13/2019 mp+lab_new[1]

    28/91

    PROGRAM:

    ADDRESS LABEL MNEMONICS OPCODE COMMENTS

    28

  • 8/13/2019 mp+lab_new[1]

    29/91

    MANUAL CALCULATION:

    OUTPUT:

    RESULT:

    Thus an assembly language program was written to find the largestnumber from the gi'en numbers .*t was executed using 8085 processor and theoutput was 'erified.

    29

    MEMORYADDRESS

    INPUT ALUES MEMORYADDRESS

    OUTPUT ALUES

  • 8/13/2019 mp+lab_new[1]

    30/91

    $. SMALLEST OF THE GIEN NUMBERS

    AIM:To write an assembly language program to find the smallest of the gi'ennumbers and to execute it using 8085 processor.

    ALGORITHM:Step1: Get the countStep: Get the array of numbers using - pointerStep!: 6o'e the contents in the memory to the accumulatorStep#: ecrement the counterStep5: *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 registerStep8: *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

  • 8/13/2019 mp+lab_new[1]

    31/91

    PROGRAM:

    ADDRESS LABEL MNEMONICS OPCODE COMMENTS

    31

  • 8/13/2019 mp+lab_new[1]

    32/91

    MANUAL CALCULATION:

    OUTPUT:

    RESULT:

    Thus an assembly language program was written to find the smallestnumber from the gi'en numbers .*t was executed using 8085 processor and theoutput was 'erified.

    32

    MEMORYADDRESS

    INPUT ALUES MEMORYADDRESS

    OUTPUT ALUES

  • 8/13/2019 mp+lab_new[1]

    33/91

    8. SORTING OF ARRAY IN ASCENDING ORDER

    AIM:

    T% write an assembly language program to sort the gi'en numbers in ascendingorder and to execute it using 8085 microprocessor

    ALGORITHM:

    Step1: Get the count of the outer loopStep: Get the count of the inner loopStep!: *nitialise the memory pointer with t he address of the arrayStep#: Get the data from the memoryStep5: Get the next dataStep+: )ompare the two numbersStep,: *f carry flag is reset go to slep 8 else go to step 2Step8: Swap the contents of consecuti'e memory locationsStep2: ecrement the inner loop counter

    Step10: *f 4ero flag is set go to step 11 else go to step 5Step11: ecrement the outer loop counterStep1: *f 4ero flag is set go to step 1! else go to step Step1!:-alt the program

    FLOW CHART:

    33

  • 8/13/2019 mp+lab_new[1]

    34/91

    PROGRAM:

    ADDRESS LABEL MNEMONICS OPCODE COMMENTS

    34

  • 8/13/2019 mp+lab_new[1]

    35/91

    MANUAL CALCULATION:

    OUTPUT:

    RESULT:

    Thus an assembly language program was written to sort the gi'ennumbers in ascending order. *t was executed using 8085 processor and theoutput was 'erified.

    35

    MEMORYADDRESS

    INPUT ALUES MEMORYADDRESS

    OUTPUT ALUES

  • 8/13/2019 mp+lab_new[1]

    36/91

    &.SORTING OF ARRAY IN DESCENDING ORDER

    AIM:

    To write an assembly language program to sort the gi'en numbers indescending order and to execute it using 8085 microprocessor

    ALGORITHM:

    Step1: Get the count of the outer loopStep: Get the count of the inner loopStep!: *nitialise the memory pointer with t he address of the arrayStep#: Get the data from the memoryStep5: Get the next data

    Step+: )ompare the two numbersStep,: *f carry flag is set go to slep 8 else go to step 2Step8: Swap the contents of consecuti'e memory locationsStep2: ecrement the inner loop counterStep10: *f 4ero flag is set go to step 11 else go to step 5Step11: ecrement the outer loop counterStep1: *f 4ero flag is set go to step 1! else go to step Step1!:-alt the program

    FLOW CHART:

    36

  • 8/13/2019 mp+lab_new[1]

    37/91

    PROGRAM:

    ADDRESS LABEL MNEMONICS OPCODE COMMENTS

    37

  • 8/13/2019 mp+lab_new[1]

    38/91

    MANUAL CALCULATION:

    OUTPUT:

    RESULT:

    Thus an assembly language program was written to sort the gi'ennumbers in descending order. *t was executed using 8085 processor and theoutput was 'erified.

    38

    MEMORYADDRESS

    INPUT ALUES MEMORYADDRESS

    OUTPUT ALUES

  • 8/13/2019 mp+lab_new[1]

    39/91

  • 8/13/2019 mp+lab_new[1]

    40/91

    PROGRAM:

    ADDRESS LABEL MNEMONICS OPCODE COMMENTS

    40

  • 8/13/2019 mp+lab_new[1]

    41/91

    MANUAL CALCULATION:

    OUTPUT:

    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 processorand the output was 'erified.

    41

    MEMORYADDRESS

    INPUT ALUES MEMORYADDRESS

    OUTPUT ALUES

  • 8/13/2019 mp+lab_new[1]

    42/91

    11. ODD NUMBERS

    AIM:

    To write an assembly language program to sort the odd numbers from thegi'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 arrayStep!: *nitialise a register to count the e'en numbersStep#: *nitialise - pointer with the address of the input arrayStep5: 6o'e the number from memory to accumulatorStep+: ight shift the data in accumulator by 1

    Step,: *f carry flag is set go to step 8 else got to step 1Step8: *ncrement the count of odd numbersStep2: 6o'e the data from memory to accumulatorStep10: Store the data in register used to store odd numbersStep11: *ncrement the address location used to store odd numbersStep1: Get the next number from the memoryStep1!: ecrement the / counterStep1#: *f 4ero flag is set go to step 15 else go to step 5Step15: Store the count of odd numbers in the memory specifiedStep1+: -alt the program

    FLOW CHART:

    42

  • 8/13/2019 mp+lab_new[1]

    43/91

    PROGRAM:

    ADDRESS LABEL MNEMONICS OPCODE COMMENTS

    43

  • 8/13/2019 mp+lab_new[1]

    44/91

    MANUAL CALCULATION:

    OUTPUT:

    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 theoutput was 'erified.

    44

    MEMORYADDRESS

    INPUT ALUES MEMORYADDRESS

    OUTPUT ALUES

  • 8/13/2019 mp+lab_new[1]

    45/91

    12. TRANSFER OF BLOCK OF DATA

    AIM:

    To write an assembly language program to transfer a bloc( of data fromone memory location to another and to execute it using 8085 microprocessor.

    ALGORITHM:

    Step1: Get the count of the data to be transferredStep: *nitialise - pointer with the address of the input arrayStep!: *nitialise a register pair with the address of the output arrayStep#: Get the first input dataStep5: 6o'e the data to accumulatorStep5: Store it in the memory specifiedStep+: Get the next dataStep,: *ncrement the output arrayStep8: ecrement the counterStep2: *f 4ero flag is set go to step10 else go to step 5

    Step10: -alt the program

    FLOW CHART:

    45

  • 8/13/2019 mp+lab_new[1]

    46/91

    PROGRAM:

    ADDRESS LABEL MNEMONICS OPCODE COMMENTS

    46

  • 8/13/2019 mp+lab_new[1]

    47/91

    MANUAL CALCULATION:

    OUTPUT:

    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 theoutput was 'erified.

    47

    MEMORYADDRESS

    INPUT ALUES MEMORYADDRESS

    OUTPUT ALUES

  • 8/13/2019 mp+lab_new[1]

    48/91

    INTERFACING 8255 ' PROGRAMMABLE PARALLEL INTERFACE (PPI)TO 8085 MICROPROCESSOR

    AIM:

    To write assembly language programs to interface 855 with 8085microprocessor by configuring it three different modes %mode09 mode19 mode&.

    M%*+0:ALGORITHM:

    Step1: StartStep: *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.

    )A!!ALE )AALLEL *4E/A-E ))*6+ 8255

    Table 1: Table !:

    48

    ADDRESS OPCODE MNEUMONICS

    #100 !/ 6* "980

    #101 80

    #10 ! ;

  • 8/13/2019 mp+lab_new[1]

    49/91

    Table 2:

    49

    ADDRESS OPCODE MNEUMONICS

    #100 !/ 6* "920

    #101 20

    #10 ! ; )0

    #105 )0

    #10+ ! ST" #!00

    #10, 00

    #108 #!

    #102 ! ;

  • 8/13/2019 mp+lab_new[1]

    50/91

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

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

    50

  • 8/13/2019 mp+lab_new[1]

    51/91

    Fig 3: Bi" 'e" ( )e*e" +o!"rol ,or& forma" of 8255

    MODE 0 OPERATION: SIMPLE I,O TRANSFER

    ADDRESS OPCODE MNEUMONICS COMMENTS

    #100 !/9 20 6* "920 6o'e control word to accumulator

    #10 !9 )+ ; )0 Gi'e input to ort )

    #10+ !9 ) ;

  • 8/13/2019 mp+lab_new[1]

    52/91

    memory

    #10+ !9 ) ;

  • 8/13/2019 mp+lab_new[1]

    53/91

    R+-/:Thus the program for programmable parallel interface %*& to 8085

    microprocessor was executed and 'erified

    53

  • 8/13/2019 mp+lab_new[1]

    54/91

    INTERFACING 825! ' TIMER, COUNTER AND 8251 ' USART TO 8085MICROPROCESSOR

    AIM

    To write assembly language program to interface 851 and 85! with 80856icroprocessor and to transmit and recei'e data serially through 851.

    ALGORITHM

    1. To Transmit ata serially9 initiali4e a counter.. oad the 1+?bit count in the counter.!. oad the control word in 851.#. Send the data to 851.5. -alt.

    +. To recei'e data serially9 get the data from 851.,. Sa'e the data in memory.8. -alt

    INTERFACING 8251 USART

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

    54

  • 8/13/2019 mp+lab_new[1]

    55/91

    55

  • 8/13/2019 mp+lab_new[1]

    56/91

    INTERFACING 825! TIMER, COUNTER

    56

  • 8/13/2019 mp+lab_new[1]

    57/91

    B/% *34647 % 825!

    PROGRAM

    T649-73+6 S3*+

    MEMORY OPCODE MNEMONICS COMMENTS

    #100 !/9 !+ 6* "9!+- )onfigure 85! to count binary9mode!9read @ load S3 first then 6S39 counter0

    #10 !9 )/ ;

  • 8/13/2019 mp+lab_new[1]

    58/91

    R++3+6 S3*+

    MEMORY OPCODE MNEMONICS COMMENTS

    #00 39)0 *> )0 Get the serial data from data register

    #0 !9 509#1 ST" #150 Store in #150 memory location of 8085

    #05 ,+ -T Stop the process

    O;

    M+7%6

  • 8/13/2019 mp+lab_new[1]

    62/91

  • 8/13/2019 mp+lab_new[1]

    63/91

    PROGRAM:

    "ddress abel 6nemonics ;pcode )omments#100 Start A* -9 #00- 19009# oad theimmediatedata #00h to- pointer.

    #10! 6* )9 0#- 0/9 0#9 6o'e theimmediatedata 0#h to )register.

    #105 >ext 6; "9 6 =/ 6o'e thecontents of 6

    register toaccumulator

    #10+ ;C elay )9 039 #1 =ump on no4ero to theaddressspecified bylabel EelayF

    #111 *>A - ! *ncrement the

    63

  • 8/13/2019 mp+lab_new[1]

    64/91

    contents of -pointer by one.

    #11 ) ) 0 ecrement thecontents of )register by

    one.#11! =>C >ext )9 059 #1 =ump on no

    4ero to theaddressspecified bylabel to E>extF.

    #11+ =6 Start )!9 009 #1 =umpunconditionallyto the addressspecified bythe label

    EStartF

    RESULT:

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

    64

  • 8/13/2019 mp+lab_new[1]

    65/91

    808" EXPERIMENTS

    ADDITION OF TWO 1" BIT NUMBERS IMMEDIATE ADDRESSING

    AIM:

    To write an assembly language program to perform addition of two 1+ bitnumbers 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 specifiedStep5: Terminate the program execution

    FLOW CHART:

    65

  • 8/13/2019 mp+lab_new[1]

    66/91

    PROGRAM:

    ADDRESS OPCODE MNEMONICS COMMENTS

    66

  • 8/13/2019 mp+lab_new[1]

    67/91

    MANUAL CALCULATION:

    OUTPUT:

    RESULT:

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

    MEMORYADDRESS

    INPUT ALUES MEMORYADDRESS

    OUTPUT ALUES

    67

  • 8/13/2019 mp+lab_new[1]

    68/91

    ADDITION OF TWO 1" BIT NUMBERS DIRECT ADDRESSING

    AIM:

    To write an assembly language program to perform addition of two 1+ bitnumbers 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 specifiedStep5: Terminate the program execution

    FLOW CHART:

    68

  • 8/13/2019 mp+lab_new[1]

    69/91

    PROGRAM:

    ADDRESS OPCODE MNEMONICS COMMENTS

    69

  • 8/13/2019 mp+lab_new[1]

    70/91

    MANUAL CALCULATION:

    OUTPUT:

    RESULT:

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

    MEMORYADDRESS

    INPUT ALUES MEMORYADDRESS

    OUTPUT ALUES

    70

  • 8/13/2019 mp+lab_new[1]

    71/91

    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 specifiedStep5: Terminate the program execution

    FLOW CHART:

    71

  • 8/13/2019 mp+lab_new[1]

    72/91

    PROGRAM:

    ADDRESS OPCODE MNEMONICS COMMENTS

    72

  • 8/13/2019 mp+lab_new[1]

    73/91

    MANUAL CALCULATION:

    OUTPUT:

    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.

    MEMORY

    ADDRESS

    INPUT ALUES MEMORY

    ADDRESS

    OUTPUT ALUES

    73

  • 8/13/2019 mp+lab_new[1]

    74/91

    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. *nitiali4e the memory location in to source register. oad BBBB- to A register!. Get the count 'alue in to accumulator#. *ncrement the A register content by one5. 6o'e the content of S* in to " register+. )ompare " with "h register

    ,. =ump on no 4ero9 go to location specified in the instruction8. store the result in to memory location

    FLOW CHART:

    74

  • 8/13/2019 mp+lab_new[1]

    75/91

    PROGRAM:

    MEMORYADDRESS

    OPCODE MNEMONICS COMMENTS

    1000 3/9 009 1 6; S*9 100 oad memory location 100- to S*

    100! 3"9 BB9 BB 6; A9 BBBB oad 'alue BBBB- to A register

    100+ 3#9 BB 6; "-9 BB oad 'alue BB- that specifies endof count

    1008 # *>) A *ncrement A to reset its 'alue

    1002 8"9 0# 6; "9 S*H 6o'e data pointed by S* register to"

    1003 #+ *>) S* *ncrement S* register content

    100) !89 )# )6 "-9 " )ompare " with "- registercontent

    100/ ,59 B8 =>C 1008 =ump on no 4ero to location ?????????

    1010 829 1+9 00911

    6; 1100H9 A 6o'e the count 'alue in A tolocation 1100-

    101# )) *>T! )all 3rea( oint interrupt

    MANUAL CALCULATION:

    75

  • 8/13/2019 mp+lab_new[1]

    76/91

    OUTPUT:

    RESULT:

    Thus an assembly language program was written to perform count thenumber of data in a string. *t was executed using 808+ processor and the outputwas 'erified.

    . SEARCHING A STRING IN A GIEN ARRAY

    MEMORYADDRESS

    INPUT ALUES MEMORYADDRESS

    OUTPUT ALUES

    76

  • 8/13/2019 mp+lab_new[1]

    77/91

    AIM:

    To write an assembly language program to searching a string in a gi'enarray 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 #. )ompare with " register5. =ump on 4ero9 go to location specified in the instruction+. ecrement the ) register,. *ncrement the A register content by one

    8. =ump on no 4ero9 go to location specified in the instruction2. 6o'e the content of "l in to * register10.store the result in to memory location

    FLOW CHART:

    77

  • 8/13/2019 mp+lab_new[1]

    78/91

    PROGRAM:

    MEMORYADDRESS

    OPCODE MNEMONICS COMMENTS

    1500 3B9 009

    1!

    6; *9 1!00 oad memory location 1!00- to *

    for result150! 3/9 009

    16; S*9 100 oad memory location 100- to S*

    for storing data

    150+ 319 10 6; )9 10 oad count 'alue 10- to ) register

    1508 39 01 6; 9 01 oad the string 01 to be searchedinto

    150" ") ;S3 oads byte at address S:%/&S* into"

    1503 !89 ) )6 9 " )ompares the contents of " with01-

    150 ,#9 05 =C 151! *f 4ero flag is set 7ump to location

    151!150B B/9 )2 /) ) ecrement ) register content

    1511 ,59 B, =>C 150" =ump to location 150" till count'alue is non 4ero

    151! 889 05 6; *H9 " Store the searched string 01- in "to * pointed location 1!00-

    1515 #/ /) S* ecrement memory location in S*

    151+ 829 B! 6; 3A9 S* 6o'e location of occurrence of stringto 3A register

    1518 #, *>) * *ncrement * register 'alue to 1!01

    1512 889 1 6; *H9 3 6o'e lower byte of location to *

    1513 #, *>) * *ncrement * register 'alue to 1!0

    151) 889 ! 6; *H9 3- 6o'e upper byte of location to *

    151/ )) *>T! )all 3rea( oint interrupt

    MANUAL CALCULATION:

    78

  • 8/13/2019 mp+lab_new[1]

    79/91

    OUTPUT:

    RESULT:

    Thus an assembly language program was written to perform searching astring in a gi'en array. *t was executed using 808+ processor and the output was'erified.

    MOE THE BLOCK OF DATA FROM ONE MEMORY LOCATION TO ANOTHER

    MEMORYADDRESS

    INPUT ALUES MEMORYADDRESS

    OUTPUT ALUES

    79

  • 8/13/2019 mp+lab_new[1]

    80/91

  • 8/13/2019 mp+lab_new[1]

    81/91

    OUTPUT:

    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 andthe output was 'erified.

    MEMORYADDRESS

    INPUT ALUES MEMORYADDRESS

    OUTPUT ALUES

    81

  • 8/13/2019 mp+lab_new[1]

    82/91

    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:

    MEMORYADDRESS

    OPCODE LABEL MNEMONICS COMMENTS

    #100 )! ) ) )lear )arry flag )

    #101 ,#9!# 6; "9 I!# oad lower byte firstoperant to "

    #10! #9,8 " "9I,8 "dd the lower bytesecond operant with "content

    #105 209#1950 6; T9I#150 oad data pointerregister %T& withaddress #150

    #108 B0 6; JT9" 6o'e the content of "to address pointed byT

    #102 "! *>) T *ncrement Tcontent

    #10" ,#91 6; "9I1 oad higher byte firstoperant to "

    #10) !#95+ ") "9I5+ "dd the higher bytesecond operant tocontent of " registerwith carry

    #10/ B0 6; JT9" 6o'e " registercontent to the addresspointed by Tregister

    #10B 809B/ -// S=6 -// Stop the execution

    82

  • 8/13/2019 mp+lab_new[1]

    83/91

    MANUAL CALCULATION:

    OUTPUT:

    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

    MEMORYADDRESS

    INPUT ALUES MEMORYADDRESS

    OUTPUT ALUES

    83

  • 8/13/2019 mp+lab_new[1]

    84/91

    . MULTIPLICATION OF TWO 8 BIT NUMBERS

    AIM:

    To write an assembly language program to multiply two 8 bit numbersand to execute it using 8051 microprocessorPROGRAM:

    MEMORYADDRESS

    OPCODE LABEL MNEMONICS COMMENTS

    #100 ,#908 6; "9I08 oad immediate 'alue to"ccumulator

    #10 ,59B090# 6; 39 I0# oad immediate 'alue to

    3 register#105 "# 6

  • 8/13/2019 mp+lab_new[1]

    85/91

    MANUAL CALCULATION:

    OUTPUT:

    RESULT:

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

    MEMORYADDRESS

    INPUT ALUES MEMORYADDRESS

    OUTPUT ALUES

    85

  • 8/13/2019 mp+lab_new[1]

    86/91

    DIISION OF TWO 8 BIT NUMBERS

    AIM:

    To write an assembly language program to i'ide two 8 bit numbers andto execute it using 8051 microprocessor.

    PROGRAM:

    MANUAL CALCULATION:

    MEMORYADDRESS

    OPCODE

    LABEL MNEMONICS COMMENTS

    #100 ,#908 6; "9I08 oad immediate 'alueto "ccumulator

    #10 ,59B090# 6; 39 I0# oad immediate 'alueto 3 register

    #105 20 * "93 i'ides the"ccumulator by the 3register. The resultinguotient is in

    "ccumulator and theremainder in 3register

    #10+ 209#5900 6; T9I#500 oad memory location#500 to T register

    #102 B0 6;A JT9" "ccumulator is mo'edto the 1+?bit /xternal6emory addressindicated by T

    #10" "! *>) T *ncrement Tcontent

    #103 /59B0 6; "93 6o'e the remainderto "ccumulator

    #10 B0 6;A JT9" "ccumulator is mo'edto the 1+?bit /xternal6emory addressindicated by T

    #10/ 809B/ -// S=6 -// Stop the execution

    86

  • 8/13/2019 mp+lab_new[1]

    87/91

    OUTPUT:

    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

    MEMORYADDRESS

    INPUT ALUES MEMORYADDRESS

    OUTPUT ALUES

    87

  • 8/13/2019 mp+lab_new[1]

    88/91

    AIM:

    To write an assembly language program to find sum of >?elements in anarray and to execute it using 8051 microprocessor.

    PROGRAM:

    MEMORYADDRESS

    OPCODE LABEL MNEMONICS COMMENTS

    #100 209#900 6;T9I#00

    oad location #500 toT

    #10! /0 6; "9JT oad T content to "

    #10# B8 6; 09" 6o'e "ccumulator to 0

    #105 ,59B0900 6; 39I0 oad 3 register with 4ero

    #108 "29B0 6; 193 6o'e 3 register content to

    1#10" )! " ) ) )lear )arry flag )

    #103 /0 6; "9JT 6o'e content of T to "

    #10) /59B0 " "93 "dd "ccumulator to 3register

    #10/ B5 6; 39" 6o'e "ccumulator to 3register

    #10B B0950901 =>) >) =ump to #11# if )arry is notset

    #11 02 *>) 1 *ncrement 1 registercontent

    #11! "! *>) T *ncrement T content#11# 89B# >) =>C 09" ecrement egister 0

    and =ump if >ot Cero to"

    #11+ 209#5900 6; T9I#500

    oad T with location#500

    #112 /2 6; "91 6o'e 1 content to "

    #11" B0 6;A JT9" "ccumulator is mo'ed tothe 1+?bit /xternal 6emoryaddress indicated by T

    #113 "! *>) T *ncrement T content

    #11) /59B0 6; "93 6o'e "ccumulator to 3register

    #11/ B0 6;A JT9" "ccumulator is mo'ed tothe 1+?bit /xternal 6emoryaddress indicated by T

    #11B 809B/ -// S=6 -// Stop the execution

    MANUAL CALCULATION:

    88

  • 8/13/2019 mp+lab_new[1]

    89/91

    OUTPUT:

    RESULT:

    Thus an assembly language program was written for Sum of >?elementsin an array was executed using 8051 processor and the output was 'erified.

    LARGEST ELEMENT IN AN ARRAY

    MEMORYADDRESS

    INPUT ALUES MEMORYADDRESS

    OUTPUT ALUES

    89

  • 8/13/2019 mp+lab_new[1]

    90/91

    AIM:

    To write an assembly language program to find the largest element in anarray and to execute it using 8051 microprocessor.

    PROGRAM:

    MEMORYADDRESS

    OPCODE LABEL MNEMONICS COMMENTS

    #100 209#900 6;T9I#00

    oad location #00 toT

    #10! ,59#0900 6; #09I00 oad 4ero to memory #0-

    #10+ ,90" 6; 59" 6o'e "ccumulator to 5

    #105 ,59B0900 6; 39I0 oad 4ero to 3 register

    #108 /0 ;; 6;A "9JT "ccumulator is mo'edto1+ bit /xternal 6emoryaddress indicated byT

    #102 359#091# )=>/ "9#0;;1

    )ompare " with contentsof location #0- and =umpif >ot /ual to ;;1

    #10) "! ;;! *>) T *ncrement T content

    #10 9B2 =>C 59;; ecrement egister 5and =ump if >ot Cero to;;

    #10B /59#0 6; "9#0 6o'e 'alue in location#0- to "ccumulator

    #111 B0 6;A JT9" "ccumulator is mo'edto1+ bit /xternal 6emoryaddress indicated byT

    #11 809B/ -T S=6 -T Stop the execution

    #11# #09B+ ;;1 =) ;;! =ump if )arry Set to;;!

    #11+ B59#0 6; #09" 6o'e " to location #0-

    #118 B S=6 ;; erform short 7ump to

    location ;;

    MANUAL CALCULATION:

    90

  • 8/13/2019 mp+lab_new[1]

    91/91