New Mp Manual

Embed Size (px)

Citation preview

  • 7/27/2019 New Mp Manual

    1/40

    PROGRAM FOR 16 BIT ARITHMATIC OPERATION USING 808616 BIT ADDITION

    AIM:To write an ALP to perform the arithmetic operations using 8086 microprocessor kit.

    Apparatus required:

    1.

    8086 Microprocessor kit2. Keyboard and power supply

    Algorithm:ADDITION:

    1. Move the 16 bit data directly to the AX register(AX 1234(1 st data))

    2. Move the 16 bit data immediately to the BX register (BX 5678(2 nd data))

    3. Clear the DX register to Store the Carry (DX 0000)

    4. Add the AX register content and BX register content. The sum value is stored in the AXregister(AX+BX AX)

    5. Check for carry if carry arises increment the carry register(DX)

    6. If no carry define the destination index as 2300(STA 40F3put Address)

    7. Then move the sum value present in the AX register to the destination index(AX 2300)

    8. Increment the destination index twice to attain the next address(2302)

    9. Move the carry value present in the DX register to the present DI address(DX 2302)

    10. Stop the execution.

    SUBTRACTION:1. Move the 16 bit data directly to the AX register(AX 5678 (1 st data))

    2. Move the 16 bit data immediately to the BX register (BX 1234(2 nd data))

    3. Clear the DX register to Store the borrow (DX 0000)

    4. Subtract the AX register content and BX register content. The sum value is stored inthe AX register(AX-BX AX)

    5. Check for carry if carry arises increment the carry register(DX)

    6. If no carry define the destination index as 2300(STA 40F3put Address)

    7. Then move the difference value present in the AX register to the destinationindex(AX 2300)

    8. Increment the destination index twice to attain the next address(2302)

  • 7/27/2019 New Mp Manual

    2/40

    9. Move the borrow value present in the DX register to the present DIaddress(DX 2302)

    10. Stop the execution.

    MULTIPLICATION:1. Define the Source index as 2200(SI 2200(Input address))

    2. Define the destination index as 2300(DI 2300(STA 40F3put address))

    3. Clear the DX register to store the carry value.

    4. Move the source index content(1 st data) to AX register(SI(2200) AX)

    5. Increment the source index twice to Access the next data(INC SI)

    6. Now move the SI content(2 nd data) to BX register(SI(2202) BX)

    7. Multiply the AX content and BX content by using IMUL instruction(AX*BX AX,DX)

    8. AX product value

    9. DX Carry value

    10. Move the AX register content(product) to the Destination index(2300)(AX 2300)

    11. Increment the DI twice to obtain the Next address location(2302)

    12. Move the DX register(carry) content to the DI(DX 2302(DI))

    13. Stop the execution.

    DIVISION:1. Define the Source index as 2200(SI 2200(Input address))

    2. Define the destination index as 2300(DI 2300(STA 40F3put address))

    3. Clear the DX register to store the carry value.

    4. Move the source index content(1 st data) to AX register(SI(2200) AX)

    5. Increment the source index twice to Access the next data(INC SI)

    6. Now move the SI content(2 nd data) to BX register(SI(2202) BX)

    7. Multiply the AX content and BX content by using IMUL instruction(AX/BX AX,DX)

    8. AX Quotient value

    9. DX Reminder value

    10. Move the AX register content(Quotient) to the Destination index(2300)(AX 2300)

  • 7/27/2019 New Mp Manual

    3/40

    11. Increment the DI twice to obtain the Next address location(2302)

    12. Move the DX register(Reminder) content to the DI(DX 2302(DI))

    13. Stop the execution

    ADDITIONADDRESS LABEL MNEMONICS COMMENTS2000 MOV AX,1234 Move the data 1234 to AX2003 MOV BX,5678 Move the data 5678 to BX2006 MOV DX,0000 Move the data 0000 to DX2009 ADD AX,BX Add AX and BX register 200B JNC L1 Jump if no carry to loop1200D INC DX Increment DX register 200E L1 MOV DI,2300 Move the data in 2300 to DI2011 MOV [DI],AX Move the AX reg to DI reg2013 INC DI Increment DI reg2014 INC DI Increment DI reg2015 MOV [DI],DX Move the DX to DI reg2017 INT 03 Stop the program

    SUBTRACTIONADDRESS LABEL MNEMONICS COMMENTS2000 MOV AX,5678 Move the data 5678 to AX2003 MOV BX,1234 Move the data 1234 to BX2006 MOV DX,0000 Move the data 0000 to DX2009 SUB AX,BX subtract AX and BX register 200B JNC L1 Jump if no carry to loop1200D INC DX Increment DX register 200E L1 MOV DI,2300 Move the data in 2300 to DI2011 MOV [DI],AX Move the AX reg to DI reg2013 INC DI Increment DI reg2014 INC DI Increment DI reg2015 MOV [DI],DX Move the DX to DI reg2017 INT 03 Stop the program

    MULTIPLICATION

    ADDRESS LABEL MNEMONICS COMMENTS2000 MOV SI,2200 Move 2200 to SI reg2003 MOV DI,2300 Move 2300 to DI reg2006 MOV DX,0000 Move 0000 to DX reg2009 MOV AX,(SI) Move (SI) to AX reg200B INC SI Increment SI by 1200C INC SI Increment SI by 1200D MOV BX,(SI) Move (SI) to BX reg

  • 7/27/2019 New Mp Manual

    4/40

    200F IMUL BX Multiply BX with accumulator 2010 MOV (DI),AX Move AX to DI reg2013 INC DI Increment DI by 12014 INC DI Increment DI by 12015 MOV (DI),DX Move DX to DI reg

    2017 INT 03 End of the program

    DIVISIONADDRESS LABEL MNEMONIC COMMENTS2000 MOV SI,2200 Move 2200 to SI reg2003 MOV DI,2300 Move 2300 to DI reg2006 MOV DX,0000 Move 0000 to DX reg2009 MOV AX,(SI) Move (SI) to AX reg200B INC SI Increment SI by 1200C INC SI Increment SI by 1200D MOV BL,(SI) Move (SI) to BL reg200F IDIV BL Divide accumulator with BL2010 MOV (DI),AX Move AX to DI reg2013 INC DI Increment DI by 12014 INC DI Increment DI by 12015 MOV (DI),DX Move DX to DI reg2017 INT 03 End of the program

    Addition:Input STA 40F3putAddress Data Address Data

    Subtraction Input STA 40F3putAddress Data Address Data

  • 7/27/2019 New Mp Manual

    5/40

  • 7/27/2019 New Mp Manual

    6/40

    8.PROGRAM FOR SORTING USING 8086

    AIM: To write a program to perform a sorting (ascending and descending ) using 8086Apparatus required:

    1. 8086 microprocessor kit

    2. Powersupply and keyboard

    Algorithm:1. Start the program

    2. Get the count value in CL

    3. Set the SI to 2200

    4. Get the count value in CH (No of individual comparisons)

    5. Get the data to AX from SI

    6. Increment the SI twice to get the next address

    7. Get the data to BX from SI

    8. Compare AX and BX values

    9. Check for carry If carry arises decrement the CH value

    10. If no carry arises move the AX content to SI

    11. Decrement the SI value twice to get the previous address

    12. Move the BX content to the SI

    13. Increment the SI twice

    14. Decrement the CH value

    15. Check if CH=0 or not

    16. If CH not equal to zero Move the SI content to AX and repeat the comparison process assaid earlier until the CH becomes zero

    17. If CH=0 Decrement the CL value

    18. Check CL=0 or not

    19. If CL not equal to zero repeat the process from earlier (Set the SI to 2200)

  • 7/27/2019 New Mp Manual

    7/40

    20. If CL=0 stop the execution.

    DESCENDING ORDER

    21. Start the program

    22. Get the count value in CL

    23. Set the SI to 2200

    24. Get the count value in CH (No of individual comparisons)

    25. Get the data to AX from SI

    26. Increment the SI twice to get the next address

    27. Get the data to BX from SI

    28. Compare AX and BX values

    29. Check for carry If carry arises decrement the CH value

    30. If no carry arises move the AX content to SI

    31. Decrement the SI value twice to get the previous address

    32. Move the BX content to the SI

    33. Increment the SI twice

    34. Decrement the CH value

    35. Check if CH=0 or not

    36. If CH not equal to zero Move the SI content to AX and repeat the comparison process assaid earlier until the CH becomes zero

    37. If CH=0 Decrement the CL value

    38. Check CL=0 or not

    39. If CL not equal to zero repeat the process from earlier (Set the SI to 2200)

    40. If CL=0 stop the execution.

    ASCENDING ORDER:

    ADDRESS LABEL MNEMONICS COMMENTS2000 MOV CL,04 Move the content of data to CL2002 L3 MOV SI,2200 Move the content of address to source index2005 MOV CH,04 Move the data 04 to CH2007 L2 MOV AX,(SI) Move the content of source index to accumulator

  • 7/27/2019 New Mp Manual

    8/40

    2009 INC SI Increment source index200A INC SI Increment source index200B MOV BX,(SI) Move the content of SI to B reg200D CMP AX,BX Compare accumulator with B register 200F JC L1 If carry is set jump to loop1

    2011 MOV (SI),AX Move the content of accumulator to source index2013 DEC SI Decrement source index2014 DEC SI Decrement source index2015 MOV (SI),BX Move the content of B reg to SI2017 INC SI Increment source index2018 INC SI Increment source index2019 L1 DEC CH Decrement CH201B JNZ L2 Jump if no zero to loop2201D DEC CL Decrement CL201E JNZ L3 Jump if no zero to loop32021 INT 03 End of the programDESCENDING ORDER ADDRESS LABEL MNEMONICS COMMENTS2000 MOV CL,04 Move the content of data to CL2002 L3 MOV SI,2200 Move the content of address to source index2005 MOV CH,04 Move the data 04 to CH2007 L2 MOV AX,(SI) Move the content of source index to accumulator 2009 INC SI Increment source index200A INC SI Increment source index200B MOV BX,(SI) Move the content of SI to B reg200D CMP AX,BX Compare accumulator with B register 200F JNC L1 If carry is not set jump to loop12011 MOV (SI),AX Move the content of accumulator to source index2013 DEC SI Decrement source index2014 DEC SI Decrement source index2015 MOV (SI),BX Move the content of B reg to SI2017 INC SI Increment source index2018 INC SI Increment source index2019 L1 DEC CH Decrement CH201B JNZ L2 Jump if no zero to loop2201D DEC CL Decrement CL201E JNZ L3 Jump if no zero to loop3

    2021 INT 03 End of the program

  • 7/27/2019 New Mp Manual

    9/40

    Ascending order:Input STA 40F3putAddress Data Address Data

    Descending order:Input STA 40F3put

    Address Data Address Data

    Result:Thus the program for sorting (ascending and descending order) was executed and verifiedsuccessfully.

  • 7/27/2019 New Mp Manual

    10/40

    9.PROGRAM FOR SEARCHING USING 8086

    Aim:To write a program to perform a searching (largest and smallest number) using 8086

    Apparatus required:1. 8086 microprocessor kit

    2. Power supply and keyboard

    Algorithm:LARGEST NUMBER:

    1. Start the program

    2. Set SI to 2200

    3. Set DI to 2300

    4. Get the count value in CL(No of inputs)

    5. Get the data to AX from SI

    6. Decrement the Count value(CL CL-01)

    7. Increment the SI twice to get the next address

    8. Get the data to BX from SI

    9. Compare AX and BX value

    10. If carry arises move the BX value to AX and decrement the CL

    11. If no carry decrement the CL

    12. Check if CL=0 or not

    13. If CL not equal to zero Increment the SI twice to obtain the next value

    14. The value is moved to BX and the comparison operation is repeated until CL=0

    15. If CL=0 move the AX(Largest number) content to DI

    16. Stop the execution

    SMALLEST NUMBER:17. Start the program

    18. Set SI to 2200

    19. Set DI to 2300

    20. Get the count value in CL(No of inputs)

  • 7/27/2019 New Mp Manual

    11/40

    21. Get the data to AX from SI

    22. Decrement the Count value(CL CL-01)

    23. Increment the SI twice to get the next address

    24. Get the data to BX from SI25. Compare AX and BX value

    26. If carry arises move the BX value to AX and decrement the CL

    27. If no carry decrement the CL

    28. Check if CL=0 or not

    29. If CL not equal to zero Increment the SI twice to obtain the next value

    30. The value is moved to BX and the comparison operation is repeated until CL=0

    31. If CL=0 move the AX(Largest number) content to DI

    32. Stop the execution

    LARGEST NUMBER:ADDRESS LABEL MNEMONICS COMMENTS2000 MOV SI,2200 Move the content of address to source index2003 MOV DI,2300 Move the address to destination index2006 MOV CL,05 Move the content of data to CL2008 MOV AX,(SI) Move the content of SI to accumulator 200A DEC CL Decrement the CL value200C L1 INC SI Increment the source index200D INC SI Increment the source index200E MOV BX,(SI) Move the source index content to SI2010 CMP AX,BX Compare accumulator with B reg2012 JNC L1 Jump if no carry then go to loop12014 MOV AX,BX Move the content of B reg to accumulator 2016 L1 DEC CL Decrement CL value2018 JNZ L2 Jump if no zero then go to loop2201A MOV (DI),AX Move the content of accumulator to DI201C INT 03 End of the program

    SMALLEST NUMBER:ADDRESS LABEL MNEMONICS COMMENTS2000 MOV SI,2200 Move the content of address to source index2003 MOV DI,2300 Move the address to destination index2006 MOV CL,05 Move the content of data to CL2008 MOV AX,(SI) Move the content of SI to accumulator 200A DEC CL Decrement the CL value200C INC SI Increment the source index

  • 7/27/2019 New Mp Manual

    12/40

    200D INC SI Increment the source index200E L2 MOV BX,(SI) Move the source index content to SI2010 CMP AX,BX Compare accumulator with B reg2012 JC L1 Jump if carry is set then go to loop12014 MOV AX,BX Move the content of B reg to accumulator

    2016 L1 DEC CL Decrement CL value2018 JNZ L2 Jump if no zero then go to loop2201A MOV (DI),AX Move the content of accumulator to DI201C INT 03 End of the programLargest:Input STA 40F3putAddress Data Address Data

    Smallest:Input STA 40F3putAddress Data Address Data

    Result:Thus the program of searching (largest and smallest number) was executed and verified.

  • 7/27/2019 New Mp Manual

    13/40

    10.PROGRAM FOR STRING MANIPULATION

    Aim:To write a program to perform string manipulation (moving a block of data and find&

    replace the data) using 8086.

    Apparatus required:1. 8086 microprocessor kit

    2. Powersupply

    3. Keyboard

    Algorithm:Moving a block of data:

    1. Define source index as 2200(I/P address)

    2. Define Destination index as 2300 (O/P address)

    3. Get the count value in CL register (No of inputs)

    4. Move the source index data to AX register(SI(2200) AX)

    5. Move the AX register content to the Destination index (AX DI(2300))

    6. Increment the Destination index twice to attain the next address(2302)

    7. Increment the source index twice to attain the next address(2202)

    8. Decrement the CL register value by one (CL=CL-1)

    9. Check whether the Value in CL register is zero or not

    10. If zero flag in set terminate the loop

    11. If zero flag is not set repeat the transformation(SI AX & AX DI) of data until CL=00

    12. If CL=00 Stop the program.

    Find and replace the data:1. Move the data to be replaced in DX register

    2. Define source index address as 2200

    3. Define destination index address as 23004. Get the count value in CL register (No of inputs)

    5. Move 0003 to BX register (Data to be find)

    6. Move the data present in the source index to AX register

    7. Compare AX & BX register

  • 7/27/2019 New Mp Manual

    14/40

    8. If the zero flag is set interchange the AX register content with DX register content

    9. Otherwise move the AX register value to the Destination index

    10. Increment the source index twice to attain the next address (2202)

    11. Increment the Destination index twice to attain the next address (2302)12. Decrement the count value.(CL=CL-1)

    13. Check if CL=00 or not. If CL=00 terminate the loop.

    14. Otherwise repeat the comparison and replace process until the CL reg value becomesZero.

    15. If CL=00 stop the program.

    MOVING A BLOCK OF DATA:ADDRESS LABEL MNEMONICS COMMENTS2000 MOV SI,2200 Move the content of address to source index2003 MOV DI,2300 Move the data to destination index2006 MOV CL,05 Move the content of data to CL2008 L1 MOV AX,(SI) Move the SI register in accumulator 200A MOV (DI),AX Move the accumulator to DI200C INC DI Increment the destination index200D INC DI Increment the destination index200E INC SI Increment the source index200F INC SI Increment the source index2010 DEC CL Decrement the CL value

    2012 JNZ L1 Jump if no zero go to loop12014 INT 03 End the program

    FIND AND REPLACE THE DATA:ADDRESS LABEL MNEMONICS COMMENTS2000 MOV DX,0007 Move the content of data to D register 2003 MOV SI,2200 Move the content of data to source index2006 MOV DI,2300 Move the content of data to destination index2009 MOV CL,04 Move the content of data to CL200B MOV BX,0003 Move the content of data to B reg200E L2 MOV AX,(SI) Move the source index to accumulator

    2010 CMP AX,BX Compare accumulator with B reg2012 JNZ L1 Jump if no zero then go to loop12014 MOV AX,DX Move the content of D reg to accumulator 2016 L1 MOV (DI),AX Move the accumulator to destination index2018 INC SI Increment source index2019 INC SI Increment source index201A INC DI Increment destination index201B INC DI Increment destination index

  • 7/27/2019 New Mp Manual

    15/40

    201C DEC CL Decrement the CL value201E JNZ L2 Jump if no zero then go to loop22020 INT 03 Stop the program

    Moving a block of data:

    Input STA 40F3putAddress Data Address Data

    Find and replace the data:Input STA 40F3putAddress Data Address Data

    Result:Thus the program of string manipulation (moving a block of data and find & replace the

    data) was executed and verified successfully.

  • 7/27/2019 New Mp Manual

    16/40

    11.PROGRAMMING WITH 8051 ARITHMETIC OPERATIONSAIM:

    To write an ALP that perform arithmetic operations using 8051.APPARATUS REQUIRED:

    1. 8051 Micro Controller kit2. Power supply and KeyboardALGORITHM:ADDITION:

    1. Initialize the register R0 (carry register)2. Set DataPointer(DPTR) as 8300 (STA 40F3put address)3. Move first data to the register R14. Move the content in R1 to A register 5. Move the 2 nd data to the register R26. Add the A reg content and R2 reg content (A A+R2)7. Check if carry is present or not

    8.

    If carry is present increment the carry register(R0)9. Other wise move the content of A register(Sum) to the DPTR(8300)10. Move the carry register(R0) content to A register 11. Increment the DPTR (DPTR=8301)12. Move the content of A register to DPTR(carry 8301)13. Stop the execution

    SUBTRACTION:14. Initialize the register R0 (borrow register)15. Set DataPointer(DPTR) as 8300 (STA 40F3put address)16. Move first data to the register R117. Move the content in R1 to A register 18. Move the 2 nd data to the register R219. Subtract the R2 reg content from A reg content (A A-R2)20. Check if carry is present or not21. If carry is present increment the carry register(R0)22. Other wise move the content of A register(Sum) to the DPTR(8300)23. Move the borrow register(R0) content to A register 24. Increment the DPTR (DPTR=8301)25. Move the content of A register to DPTR(borrow 8301)26. Stop the execution

    MULTIPLICATION:26. Initialize the register R0 (carry register)27. Set DataPointer (DPTR) as 8300 (STA 40F3put address)28. Move first data to the register R129. Move the content in R1 to A register 30. Move the 2 nd data to the register R231. Move R2 register content to F0(B)32. Multiply the A reg content and B(F0) reg content(A,R0 A*B)33. Move the content of A register(Product) to the DPTR(8300)34. Move the carry register(R0) content to A register

  • 7/27/2019 New Mp Manual

    17/40

    35. Increment the DPTR (DPTR=8301)36. Move the content of A register to DPTR(carry 8301)37. Stop the execution

    DIVISION:38. Initialize the register R0 (reminder register)

    39. Set DataPointer (DPTR) as 8300 (STA 40F3put address)40. Move first data to the register R1

    41. Move the content in R1 to A register 42. Move the 2 nd data to the register R243. Move R2 register content to F0(B)44. Divide the A reg content and B(F0) reg content(A,R0 A/B)45. Move the content of A register(Quotient) to the DPTR(8300)46. Move the reminder register(R0) content to A register 47. Increment the DPTR (DPTR=8301)48. Move the content of A register to DPTR(reminder 8301)49. Stop the execution.

    ADDITION:ADDRESS LABEL MNEMONICS COMMENTS8000 CLR C Clear the content8001 MOV R0,#00 Move 00 to R0 register 8003 MOV DPTR,#8300 Move 8300 to DPTR 8006 MOV R1,#FF Move data1 (FF) to R18008 MOV A,R1 Move it to accumulator 8009 MOV R2,#10 Move data2 (10) to R2800B ADD A,R2 Add content of A with reg2800C JNC 800F If no carry, go to label L1800E INC R0 If carry exists, increment R0

    800F L1 MOVX @DPTR,A Move A to DPTR 8011 MOV A,R0 Move R0(cy) to A8012 INC DPTR Increment DPTR 8013 MOVX @DPTR,A Move A to DPTR 8014 LJMP 00 Long jumpSUBTRACTION:ADDRESS LABEL MNEMONICS COMMENTS8000 CLR C Clear the content8001 MOV R0,#00 Move 00 to R0 register 8003 MOV DPTR,#8300 Move 8300 to DPTR 8006 MOV R1,#FF Move data1 (FF) to R18008 MOV A,R1 Move it to accumulator 8009 MOV R2,#10 Move data2 (10) to R2800B ADD A,R2 Add content of A with reg2800C JNC 800F If no carry, go to label L1800E INC R0 If carry exists, increment R0800F L1 MOVX @DPTR,A Move A to DPTR 8011 MOV A,R0 Move R0(cy) to A

  • 7/27/2019 New Mp Manual

    18/40

    MULTIPLICATION:ADDRESS LABEL MNEMONICS COMMENTS8000 MOV R0,#00 Move 00 to R0 register 8002 MOV DPTR,#8300 Move 8300 to DPTR 8005 MOV R1,#05 Move data1 (05) to R18007 MOV A,R1 Move it to accumulator 8008 MOV R2,#07 Move data2 (07) to R2

    800A MOV F0,R2 Move it to F0800C MUL AB Multiply content A with reg2800D MOVX @DPTR,A Move A to DPTR 800E MOV A,R0 Move R0(cy) to A8010 INC DPTR Increment DPTR 8011 MOVX @DPTR,A Move A to DPTR 8012 LJMP 00 Long jumpDIVISION:ADDRESS LABEL MNEMONICS COMMENTS8000 MOV DPTR,#8300 Move 8300 to DPTR 8003 MOV R1,#06 Move data1 (06) to R18005 MOV A,R1 Move it to accumulator 8006 MOV R2,#03 Move data2 (03) to R28008 MOV F0,R2 Move it to F0800A DIV AB Divide content of A with reg2800B MOVX @DPTR,A Move A to DPTR 800C INC DPTR Increment DPTR 800D MOV A,F0 Move the content of F0 to A800F MOVX @DPTR,A Move A to DPTR 8010 LJMP 00 Long jump

    8012 INC DPTR Increment DPTR

    8013 MOVX @DPTR,A Move A to DPTR

    8014 LJMP 00 Long jump

  • 7/27/2019 New Mp Manual

    19/40

    Addition:Input STA 40F3putAddress Data Address Data

    Subtraction:Input STA 40F3putAddress Data Address Data

    Multipication:Input STA 40F3putAddress Data Address Data

    Division:Input STA 40F3putAddress Data Address Data

    RESULT:

    Thus the ALP that performs arithmetic operations (Addition, Subtraction,Multiplication, Division) using 8051 were written and executed successfully.

  • 7/27/2019 New Mp Manual

    20/40

    12.PROGRAMMING WITH 8051 LOGICAL OPERATIONS

    AIM:To write an ALP to perform logical operations using 8051

    APPARATUS REQUIRED:

    1.

    8051 Micro controller kit.2. Power supply And Keyboard.ALGORTIHM:

    SETTING A BIT:1. Move an immediate data to accumulator.2. Perform OR operations between immediate data to accumulator.3. Set DPTR as 8500.4. Move the contents of accumulator to DPTR(8500).

    MASKING A BIT:1. Move an immediate data to accumulator.2. Perform AND operations between immediate data to accumulator.

    3. Set DPTR as 8500.4. Move the contents of accumulator to DPTR(8500).SETTING A BIT:ADDRESS LABEL MNEMONICS OPCODE COMMENTS8000 MOV A,#2F 74,2F Move 2F to accumulator 8002 ORL A,#45 44,45 Perform OR operation b/w 45

    and accumulator 8004 MOV DPTR,#8500 90,85,0 Move 4500 to DPTR 8007 MOVX @DPTR,A F0 Move the contents of

    accumulator to DPTR address8008 L1 SJMP 8508(L1) 80,FE Short jump to L1

    MASKING A BIT:ADDRESS LABEL MNEMONICS OPCODE COMMENT8000 MOV A,#87 74,87 Move 87 to accumulator 8002 ANL A,#7E 54,7E Perform AND operation

    between 7E and accumulator 8004 MOV DPTR,#8500 90,85,00 Move 4500 to DPTR 8007 MOVX @DPTR,A F0 Move the content of

    accumulator to DPTR address8008 L1 SJMP L1 80,FE Short jump to L1Setting a bit:Input STA 40F3put

    Address Data Address Data

  • 7/27/2019 New Mp Manual

    21/40

    Masking a bit:Input STA 40F3putAddress Data Address Data

    RESULT:

    Thus the ALP that performs logical operations using 8051 was written and executedsuccessfully

  • 7/27/2019 New Mp Manual

    22/40

    INTERFACING PRGRAMMABLE KEYBOARD AND DISPLAY

    CONTROLLER- 8279

    AIM : To display the rolling message by using interfacing with 8085 to 8279

    APPARATUS REQUIRED: 8085 Microprocessor kit, Power supply

    ALGORITHM : Display of rolling message HELP US

    1. Initialize the counter

    2.

    Set 8279 for 8 digit character display, right entry3. Set 8279 for clearing the display4. Write the command to display5. Load the character into accumulator and display it6. Introduce the delay7. Repeat from step 1.

    1. Display Mode Setup: Control word-10 H

    0 0 0 1 0 0 0 0

    0 0 0 D D K K K DD

    00- 8Bit character display left entry01- 16Bit character display left entry10- 8Bit character display right entry11- 16Bit character display right entry

    KKK- Key Board Mode000-2Key lockout.

    2.Clear Display: Control word-DC H

    1 1 0 1 1 1 0 01 1 0 CD CD CD CF CA

    11 A0-3; B0-3 =FF

    1-Enables Clear display0-Contents of RAM will be displayed

    1-FIFO Status is cleared

  • 7/27/2019 New Mp Manual

    23/40

    3. Write Display: Control word-90H

    1 0 0 1 0 0 0 01 0 0

    AI A A A A

    FLOWCHART:

    Selects one of the 16 rows of display.

    Auto increment = 1, the row address selected will be incremented after each of read andwrite operation of the display RAM.

    SET UP

    INITIALIZE THE COUNTER

    SET 8279 FOR 8-DIGIT CHARACTER DISPLAY

    SET 8279 FOR CLEARING THEDISPLAY

    WRITE THE COMMAND TO DISPLAY

    LOAD THE CHARACTER INTOACCUMULATOR AND DISPLAY

    DELAY

  • 7/27/2019 New Mp Manual

    24/40

    PROGRAM TABLE

    PROGRAM COMMENTS

    START : MOV SI,1200H Initialize array

    MOV CX,000FH Initialize array size

    MOV AL,10 Store the control word for display mode

    OUT C2,AL Send through output port

    MOV AL,CC Store the control word to clear display

    OUT C2,AL Send through output portMOV AL,90 Store the control word to write display

    OUT C2,AL Send through output port

    L1 : MOV AL,[SI] Get the first data

    OUT C0,AL Send through output port

    CALL DELAY Give delay

    INC SI Go & get next data

    LOOP L1 Loop until all the datas have been taken

    JMP START Go to starting locationDELAY : MOV DX,0A0FFH Store 16bit count value

    LOOP1 : DEC DX Decrement count value

    JNZ LOOP1 Loop until count values becomes zero

    RET Return to main program

    LOOK-UP TABLE:

    1200 98 68 7C C81204 FF 1C 29 FF

    RESULT:

    MEMORYLOCATION

    7-SEGMENT LED FORMAT HEX DATAd c b a dp e g f

    1200H 1 0 0 1 1 0 0 0 981201H 0 1 1 0 1 0 0 0 681202H 0 1 1 1 1 1 0 0 7C

  • 7/27/2019 New Mp Manual

    25/40

    1203H 1 1 0 0 1 0 0 0 C81204H 1 1 1 1 1 1 1 1 FF1205H 0 0 0 0 1 1 0 0 1C1206H 0 0 1 0 1 0 0 1 291207H 1 1 1 1 1 1 1 1 FF

    Thus the rolling message HELP US is displayed using 8279 interface kit.

  • 7/27/2019 New Mp Manual

    26/40

    EXP. NO: INTERFACING PROGRAMMABLE TIMER-8253 DATE:

    AIM :To study different modes of operation of programmable timer 8253

    APPARATUS REQUIRED:

    SL.NO ITEM SPECIFICATION QUANTITY

    1. Microprocessor kit 8086 Vi Microsystems 12. Power Supply +5V dc 13. 8253 interfacing kit - 14. CRO - 1

    THEORY:

    The main features of the timer are,i. Three independent 16-bit countersii. Input clock from DC to 2 MHziii. Programmable counter modesiv. Count binary or BCD

    The control signals with which the 8253 interfaces with the CPU are CS, RD,WR, A1, A2.The basic operations performed by 8253 are determined by thesecontrol signals. It has six different modes of operation, viz, mode 0 to mode 5.

    M ODE 2 RATE GENERATOR It is a simple divide - by N counter. The output will be low for one input clock period.

    The period from one output pulse to the next equals the number of input counts in the countregister. If the count register is reloaded between output pulses, the present period will not beaffected, but the subsequent period will reflect the new value.

    M ODE 3 SQUARE WAVE GENERATOR It is similar to mode 2, except that the output will remain high until one half for even

    number count, If the count is odd, the output will be high for (count+1)/2 counts and low for (count-1)/2 counts

    ALGORITHM:

    Mode 2-1. Initialize channel 0 in mode 22. Initialize the LSB of the count.3. Initialize the MSB of the count.4. Trigger the count

  • 7/27/2019 New Mp Manual

    27/40

    5. Read the corresponding output in CRO.

    Mode 3-

    1.

    Initialize channel 0 in mode 32. Initialize the LSB of the count.3. Initialize the MSB of the count.4. Trigger the count5. Read the corresponding output in CRO.

    PORT ADDRESS :1. CONTROL REGISTER 2. COUNTER OF CHANNEL 0 -3. COUNTER OF CHANNEL 1 -4. COUNTER OF CHANNEL 2 -

    5.

    O/P PORT OF CHANNEL 0 -6. O/P PORT OF CHANNEL 1 -7. O/P PORT OF CHANNEL 2 -

    CONTROL WORD FORMAT:

    D7 D6 D5 D4 D3 D2 D1 D0SC1 SC0 RL1 RL0 M2 M1 M0 BCD

    0 0 1 1 0 1 0 0

    0 0 1 1 0 1 1 0

    SC1 SC0 CHANNEL SELECT RL1 RL0 READ/LOAD

    0 0 CHANNEL 0 0 0 LATCH0 1 CHANNEL 1 0 1 LSB1 0 CHANNEL 2 1 0 MSB1 1 ----- 1 1 LSB FIRST, MSB NEXTBCD --0 BINARY COUNTER 1 --BCD COUNTER

    M2 M1 M0 MODE

    0 0 0 MODE 00 0 1 MODE 10 1 0 MODE 20 1 1 MODE 31 0 0 MODE 41 0 1 MODE 5

    =

    Mode 3 = 36 H

  • 7/27/2019 New Mp Manual

    28/40

    PORT PIN ARRANGEMENT DEBOUNCE CIRCUIT CONNECTION

    M ODE 2 RATE GENERATOR:

    PROGRAM COMMENTS

    MOV AL, 34H Store the control word in accumulator OUT 0BH Send through output port

    MOV AL, 0AH Copy lower order count value in accumulator

    OUT 08H Send through output port

    MOV AL, 00H Copy higher order count value in accumulator

    OUT 08H Send through output port

    HLT Stop

    M ODE 3 SQUARE WAVE GENERATOR:

    PROGRAM COMMENTS

    MOV AL, 36H Store the control word in accumulator

    OUT 0BH Send through output port

    MOV AL, 0AH Copy lower order count value in accumulator

    OUT 08H Send through output port

    1 CLK 0

    2 CLK 1

    3 CLK 2

    4 OUT 0

    5 OUT 1

    6 OUT 2

    7 GATE 0

    8 GATE 1

    9 GATE 2

    10 GND

    * * *

  • 7/27/2019 New Mp Manual

    29/40

    MOV AL, 00H Copy higher order count value in accumulator

    OUT 08H Send through output port

    HLT Stop

  • 7/27/2019 New Mp Manual

    30/40

    MODEL GRAPH:

    RATE GENERATOR SQUARE WAVE GENERATOR

    FLOW CHART

    RESULT: Thus an ALP for rate generator and square wave generator are written and executed.

    START

    INITIALIZE ACCUMULATOR WITH MODE SET WORD

    INITIALIZE LSB OF COUNT

    STOP

    TRIGGER THE COUNT

    INITIALIZE MSB OF COUNT

  • 7/27/2019 New Mp Manual

    31/40

    EXP. NO: INTERFACING USART 8251 DATE:

    AIM:To study interfacing technique of 8251 (USART) with microprocessor 8086 and write

    an 8086 ALP to transmit and receive data between two serial ports with RS232 cable.

    APPARATUS REQUIRED:8086 kit (2 Nos), RS232 cable.

    THEORY:The 8251 is used as a peripheral device for serial communication and is programmed

    by the CPU to operate using virtually any serial data transmission technique. The USARTaccepts data characters from the CPU in parallel format and then converts them into a continuousserial data stream for transmission. Simultaneously, it can receive serial data streams and convertthem into parallel data characters for the CPU. The CPU can read the status of the USART at anytime. These include data transmission errors and control signals. The control signals define thecomplete functional definition of the 8251. Control words should be written into the control

    register of 8251.These control words are split into two formats: 1) Mode instruction word & 2)Command instruction word. Status word format is used to examine the error during functionaloperation.

    1...transmit enable1...data terminal ready

    1... receive enable1... send break character

    1.... reset error flags (pe,oe,fe)1..... request to send (rts)

    1...... internal reset1....... enter hunt mode (enable search for sync characters)

    1 ransmitter ready1. receiver ready

    1.. transmitter empty1... parity error (pe)

    1.... overrun error (oe)1..... framing error (fe), async only

  • 7/27/2019 New Mp Manual

    32/40

    1...... sync detect, sync only1....... data set ready (dsr)

    ALGORITHM:

    1. Initialize 8253 and 8251 to check the transmission and reception of a character 2. Initialize8253 to give an output of 150Khz at channel 0 which will give a 9600 baud rate of 8251.3. The command word and mode word is written to the 8251 to set up for subsequent operations4. The status word is read from the 8251 on completion of a serial I/O operation, or when thehost CPU is checking the status of the device before starting the next I/O operationFLOW CHART:

    START

    Check TX/RX Ready

    Is it High

    No

    Yes

  • 7/27/2019 New Mp Manual

    33/40

    Write Data into data register

    STOP

  • 7/27/2019 New Mp Manual

    34/40

    PROGRAM: TRANSMITTER ENDPROGRAM COMMENTS

    MOV AL,36 Initialize 8253 in mode 3 square wave generator OUT CE,AL Send through port addressMOV AL,10 Initialize AL with lower value of count (clock frequency 150KHz)OUT C8,AL Send through port addressMOV AL,00 Initialize AL with higher value of countOUT C8,AL Send through port addressMOV AL,4E Set mode for 8251(8bit data, No parity, baud rate factor 16x & 1 stop bit)OUT C2,AL Send through port addressMOV AL,37 Set command instruction(enables transmit enable & receive enable bits)OUT C2,AL Send through port addressL1:IN AL,C2 Read status wordAND AL,04 Check whether transmitter ready

    JZ L1 If not wait until transmitter becomes readyMOV AL,41 Set the data as 41OUT C0,AL Send through port addressINT 2 Restart the system

    RECEIVER ENDPROGRAM COMMENTS

    MOV AL,36 Initialize 8253 in mode 3 square wave generator OUT CE,AL Send through port addressMOV AL,10 Initialize AL with lower value of count (clock frequency 150KHz)OUT C8,AL Send through port addressMOV AL,00 Initialize AL with higher value of countOUT C8,AL Send through port addressMOV AL,4E Set mode for 8251(8bit data, No parity, baud rate factor 16x & 1 stop bit)OUT C2,AL Send through port addressMOV AL,37 Set command instruction(enables transmit enable & receive enable bits)OUT C2,AL Send through port addressL1:IN AL,C2 Read status wordAND AL,02 Check whether receiver ready

    JZ L1 If not wait until receiver becomes readyIN AL,C0 If it is ready, get the dataMOV BX,1500 Initialize BX register with memory location to store the dataMOV [BX],AL Store the data in the memory locationINT 2 Restart the system

  • 7/27/2019 New Mp Manual

    35/40

    RESULT:

    Thus ALP for serial data communication using USART 8251 is written and the equivalent ASCII41 for character A is been transmitted & received.

  • 7/27/2019 New Mp Manual

    36/40

    EXP. NO: INTERFACING PPI 8255 DATE:

    AIM:To write ALP by interfacing 8255 with 8086 in mode 0, mode 1 and mode 2

    APPARATUS REQUIRED:8086 kit, 8255 interface kit.

    ALGORITHM:Mode 01. Initialize accumulator to hold control word2. store control word in control word register 3. Read data port A.4. Store data from port A in memory5. Place contents in port BMode 1 & Mode 2

    1.

    Initialize accumulator to hold control word (for port A)2. Store control word in control word register 3. Initialize accumulator to hold control word (for port B)4. Place contents in control word register.5. Disable all maskable interrupts, enable RST 5.56. send interrupt mask for RST 6.5 & 7.57. Enable interrupt flag8. Read data from port A, place contents in port B

    FLOWCHARTMode 0 Mode 1 & 2

    Store control word incontrol register

    Input to be read from port A

    Store into accumulator

    Store control word in control register

    Disable all interrupts except RST

    6.5

    STARTSTART

    Output written on port B

    Input to be read from port A

    Store output to port B

    STOP

  • 7/27/2019 New Mp Manual

    37/40

  • 7/27/2019 New Mp Manual

    38/40

    M ODE 0

    PROGRAM COMMENTS

    MOV AL,90H Set the control word

    OUT C6,AL Send it to control port

    IN AL,C0 Get the contents of port A in ALOUT C2,AL Send the contents of port B to port address

    HLT Stop

    M ODE 1

    PROGRAM COMMENTS

    MOV AL,0B0H Set the control word for mode 1

    OUT C6,AL Send it to control port

    MOV AL,09H Control for BSR mode

    OUT C6,AL Send it to control port

    MOV AL,13H Interrupt generation

    OUT 30,AL

    MOV AL,0AH Through 8259

    OUT 32,AL

    MOV AL,0FH Using IR2 interrupt(lower order count)

    OUT 32,AL

    MOV AL,00H Higher order count

    OUT 32,ALSTI Set trap flag

    HLT Stop

    ISR: Subroutine

    IN AL,C0 Read from Port A

    OUT C2,AL Send it to Port B

    HLT StopM ODE 2

    PROGRAM COMMENTS

    MOV AL,0C0H Set the control word for mode 2

    OUT C6,AL Send it to control port

    MOV AL,09H Control for BSR mode

    OUT C6,AL Send it to control port

    MOV AL,13H Interrupt generation

    OUT 30,AL

  • 7/27/2019 New Mp Manual

    39/40

    MOV AL,0AH Through 8259

    OUT 32,AL

    MOV AL,0FH Using IR2 interrupt(lower order count)

    OUT 32,AL

    MOV AL,00H Higher order countOUT 32,AL

    STI Set trap flag

    HLT Stop

    ISR: Subroutine

    IN AL,C0 Read from Port A

    OUT C2,AL Send it to Port B

    HLT StopBSR modeBit set/reset, applicable to PC only. One bit is S/R at a time. Control word:D7 D6 D5 D4 D3 D2 D1 D0

    0 (0=BSR) X X X B2 B1 B0 S/R (1=S,0=R)Bit select: (Taking Don't care's as 0)

    B2 B1 B0 PC bit Control word (Set) Control word (reset)

    0 0 0 0 0000 0001 = 01h 0000 0000 = 00h

    0 0 1 1 0000 0011 = 03h 0000 0010 = 02h

    0 1 0 2 0000 0101 = 05h 0000 0100 = 04h

    0 1 1 3 0000 0111 = 07h 0000 0110 = 06h

    1 0 0 4 0000 1001 = 09h 0000 1000 = 08h1 0 1 5 0000 1011 = 0Bh 0000 1010 = 0Ah

    1 1 0 6 0000 1101 = 0Dh 0000 1100 = 0Ch

    1 1 1 7 0000 1111 = 0Fh 0000 1110 = 0Eh

    I/O modeD7 D6 D5 D4 D3 D2 D1 D0

    1 (1=I/O) GA mode select PA PCU GB mode select PB PCL

    D6, D5: GA mode select:o 00 = mode0o 01 = mode1o 1X = mode2

    D4(PA), D3(PCU): 1=input 0=output D2: GB mode select: 0=mode0, 1=mode1 D1(PB), D0(PCL): 1=input 0=output

    Result:

  • 7/27/2019 New Mp Manual

    40/40

    Mode 0 Mode 1 Mode 2Input Output Input Output Input Output

    The programs for interfacing 8255 with 8085 are executed & the output is obtained for modes

    0,1 & 2