22638570 Microprocessor Micro Controller Program

download 22638570 Microprocessor Micro Controller Program

of 81

  • date post

    28-Aug-2014
  • Category

    Documents

  • view

    69
  • download

    4

Embed Size (px)

Transcript of 22638570 Microprocessor Micro Controller Program

INDEX1. BLOCK TRANSFER AND BLOCK EXCHANGE OF DATA BYTES 2. ARRANGING ELEMENTS OF A BLOCK OF DATA IN ASCENDING AND DESCENDING ORDER.3. MULTIPLICATION OF TWO 8-BIT NUMBERS USING THE

METHOD OF SUCCESSIVE ADDITION AND SHIFT AND ADD. 4. CONVERTING TWO DIGIT NUMBER TO THEIR EQUIVALENTS 5. GENERATION OF FIBONACCI SERIES 6. INTERFACING DAC 08087. INTERFACING OF THUMBWHEEL SWITCH. 8. ARRANGING BLOCK IN DESCENDING AND ASCENDING

9. 8051 TIMER BASED EXPERIMENT. 10. INTERFACING OF DOT MATRIX DISPLAY USING 8051

EXPERIMENT NO 1 BLOCK TRANSFER AND BLOCK EXCHANGE OF DATA BYTES

BLOCK TRANSFER AND BLOCK EXCHANGE OF DATA BYTESProgram Statement:Write a program to transfer block of bytes from location 2040 to 2050. Then exchange block of data at 2040 and 2050. Block length is stored at 203F.

Apparatus:8085 based single chip Microprocessor kit (VINYTICS VMC-8501), Scratch Pad RAM used from 2000h to 2770h.

Learning Objective:1. How transfer byte from one location to other? 2. Use of indirect addressing mode. 3. Exchange of data between two memory locations.

Logic:BLOCK TRANSFER: Block length is copied from location 203F and is used as counter. Data from memory location 2040 is copied to accumulator and from accumulator to 2050.After data is copied pointers for source and destination block is incremented by one and counter is decremented. Procedure is repeated till counter is not zero. BLOCK EXCHANGE: Content of memory location pointed by HL pair is copied to register B and from location pointed by DE pair to accumulator. Then data from accumulator is copied to location pointed by HL pair and from Reg. B to location pointed by DE pair and thus exchange is carried out. HL and DE pair is incremented counter is decremented . Exchange is carried out till counter is not zero.

ALGORITHM:BLOCK TRANSFER: 1. Start 2. Copy length of block 3. Initialize memory pointer of source block 4. Initialize memory pointer of destination block 5. Copy content of memory location from source block to accumulator 6. Copy content of memory location from accumulator to destination block 7. Increment both pointers 8. Decrement counter 9. If counter is not zero go to step 5 10. Stop

Stop

Copy length of block Initialize source block pointer Initialize destination block pointer Copy content from source memory location

Copy content to destination memory location Increment both pointers

Decrement counter

No

Is counter =0?

Yes

Stop

BLOCK EXCHANGEStop

Copy length of block

Initialize source block pointer

Initialize destination block pointer

Exchange content of source and destination memory location

Increment both pointers

Decrement counter

No

Is counter =0?

Yes

Stop

BLOCK TRANSFER OF DATA BYTESMemory Address 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 200A 200B 200C 200D 200E 200F 2010 OP CODE 21 3F 20 4E 23 11 50 20 7E 12 23 13 0D C2 08 20 EF Label Mnemonic LXI H, 203F MOV C, M INX H LXI D,2050 BACK: MOV A,M STAX D INX H INX D DCR C JNZ BACK RST 5 Comment Point where length Is stored Copy length Initialize destination pointer

Increment source pointerIncrement destination pointer

Check counter is zero or not?

BLOCK EXCHANGE OF DATA BYTESMemory Address 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 200A 200B 200C 200D 200E 200F 2010 2011 2012 2013 OP CODE 21 3F 20 4E 23 11 50 20 46 1A 77 78 12 23 13 0D C2 08 20 EF Label Mnemonic LXI H, 203F MOV C,M INX H LXI D,2050 BACK: MOV B,M LDAX D MOV M,A MOV A,B STAX D INX H INX D DCR C JNZ BACK RST 5 Comment Point where length Is stored Copy count value Initialize pointer

Increment pointer

Result: Block transfer:Memory Data Address 2040 11 2041 22 2042 55 2043 78 2044 63 2045 48 2046 54 Exchange Data 2047 87 Bytes: 2048 23 2049 65 Memory Data Address 2040 11 2041 22 2042 55 2043 78 2044 63 Memory Data 2045 48 Address 2046 54 2040 87 2047 87 2041 78 2048 23 2042 65 2049 65 2043 63 2044 55 2045 54 2046 48 2047 23 2048 22 2049 11 Memory Data Address 2050 11 2051 22 2052 55 2053 78 2054 63 2055 48 2056 54 2057 87 2058 23 2059 65 Memory Data Address 2050 87 2051 78 2052 65 2053 63 2054 55 Memory Data 2055 54 Address 2056 48 2050 11 2057 23 2051 22 2058 22 2052 55 2059 11 2053 78 2054 63 2055 48 2056 54 2057 87 2058 23 2059 65

EXPERIMENT NO 2 ARRANGING ELEMENTS OF BLOCK IN ASCENDING AND DESCENDING ORDER

ARRANGING BLOCK OF DATA IN ASCENDING AND DESCENDING ORDERProgram Statement:Write a program to arrange given block of data starting from 2051h in ascending order and descending order. Store result from 2070 for ascending order and from 2080 for descending order. Length of data is stored in memory location 2050h.

Apparatus:8085 based single chip Microprocessor kit (VINYTICS VMC-8501), Scratch Pad RAM used from 2000h to 2770h.

Learning Objective:1. How to arrange block in ascending and descending order? 2. Why to use two counters? 3. Use of compare instruction.

4. Effect of compare instruction on flag.

Logic: Ascending Order:Technique to arrange data bytes in ascending order is to compare two bytes at a time and arrange them at same time. Two counters are used for arranging data in ascending order. Two Numbers at successive memory locations are compared. Smaller number is stored at first memory location and larger number stored at next memory location. First counter is decremented by one and when first counter is zero then second counter is decremented by one and first counter is loaded again. So when second counter is also zero block is arranged in ascending order.

Descending Order:Technique to arrange data bytes in descending order is to compare two bytes at a time and arrange them at same time. Two counters are used for arranging data in descending order. Two Numbers at successive memory locations are compared. Larger number is stored at first memory location and smaller number at next memory location. First counter is decremented by one and when first counter is zero then second counter is decremented by one and first counter is loaded again. So when second counter is also zero block is arranged in descending order.

Algorithm: Ascending Order:1. Start 2. Copy length of block 3. Initialize outer counter 4. Initialize inner counter 5. Initialize memory pointer 6. Compare two numbers

7. If carry flag is set go to step 9 8. If carry flag is not set exchange numbers 9. Decrement inner counter 10. If counter is not zero increment memory pointer go to step 6 11. If counter is zero decrement outer counter 12. If counter is not zero go to step 4 13. Stop

Descending Order:1. Start 2. Copy length of block 3. Initialize outer counter 4. Initialize inner counter 5. Initialize memory pointer

6. Compare two numbers 7. If carry flag is reset go to step 9 8. If carry flag is set exchange numbers 9. Decrement inner counter 10. If counter is not zero increment memory pointer go to step 6 11. If counter is zero decrement outer counter 12. If counter is not zero go to step 4 13. Stop

SORTING IN ASCENDING ORDERStart

Copy length of block Initialize outer counter

Initialize inner counter Initialize memory pointers

Compare two numbers Increment memory pointers

Is carry flag set? Yes

No

Exchange two numbers

Decrement inner counter

No

Is counter Yes =0? Yes Decrement outer counter

No

Is counter = 0 Yes ? Yes

Stop

SORTING IN DESCENDING ORDERStart

Copy length of block Initialize outer counter

Initialize inner counter Initialize memory pointers

Compare two numbers Increment memory pointers

Is carry flag reset? Yes

No

Exchange two numbers

Decrement inner counter

No

Is counter Yes =0? Yes Decrement outer counter

No

Is counter = 0 Yes ? Yes

Stop

SORTING IN ASCENDING ORDERMemory Address 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 200A 200B 200C 200D 200E 200F 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 201A 201B OP CODE 21 4F 20 46 35 5E 4B 21 51 20 BE DA 13 20 56 77 2B 72 23 0D C2 08 20 05 C2 06 20 EF Label Mnemonic LXI H, 204F MOV B, M DCR M MOV E, M LOOP2: MOV C, E LXI H, 2051 LOOP1: MOV A, M INX H CMP M JC NEXT MOV D, M MOV M, A DCX H MOV M, D INX H NEXT: DCR C JNZ LOOP1 DCR B JNZ LOOP2 RST 5 Comment Point where length Is stored Copy length Initialize inner counter

Compare two numbers

Exchange if carry is Not created

Decrement inner counter

Decrement outer counter

SORTING IN DESCENDING ORDERMemory Address 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 200A 200B 200C 200D 200E 200F 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 201A 201B OP CODE 21 50 20 46 35 5E 4B 21 50 20 BE DA 13 20 56 77 2B 72 23 0D C2 08 20 05 C2 06 20 EF Label Mnemonic LXI H, 2050 MOV B, M DCR M MOV E, M LOOP2: MOV C, E LXI H, 2050 LOOP1: MOV A, M INX H CMP M JNC NEXT MOV D, M MOV M, A DCX H MOV M, D INX H NEXT: DCR C JNZ LOOP1 DCR B JNZ LOOP2 RST 5 Comment Point where length Is stored Copy length Initialize inner counter

Compare two numbers

Exchange if carry is created

Decrement inner counter

Decrement outer counter

Result: Ascending order:Before sorting Memory Data Address 2051 11 2052 22 2053 55 2054 78 2055 63 2056 48 2057 54 2058 87 2059 23 Memory Data 205A 65 Address 2051 11 2052 22 2053 55 2054 78 2055 63 2056 48 2057 54 2058 87 2059 23 205A 65 After sorting Memory Data Address 0500 11 0501 22 0502 23 0503 48 0504 54 0505 55 0506 63 0507 65 0508 78 Memory Data 0509 87 Address 0500 87 0501 78 0502 65 0503 63 0504 55 0505 54 0506 48 0507 23 0508 22 0509 11

Descending order:Before sorting After sorting

Que