Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 11

Microcontroller Lab

Sub Code:06ESL47
1.Data Transfer-Block Move, Exchange,
Sorting, Finding Largest element in an array.
• 1 a) Write an ALP to Move Block of Data
from Source to Destination.
Brief Introduction to 8051
• 8051 Microcontroller has 16 address line
• It can have 216=65536 Memory Locations
• 8051 has 256 locations of Internal Memory
• Each Location is capable of storing ONE
Byte
• i.e. Address of each location can be from
00H to FFH
Brief Introduction to 8051
• We can access memory locations 00H to
7FH directly or indirectly.
• 7FH to FFH can be accessed Indirectly
1 a) Write an ALP to Move Block of Data
from Source to Destination
• Let us assume that the size of the Source Block
is 10 bytes.
• Each byte is stored in successive Memory
Location
• EX: Let
• First byte is stored in Memory Location 50H
• Second byte is stored in Memory Location 51H
• Third byte is stored in Memory Location 52H
Before Execution

Source Destination
50H 11H 60H
51H 22H 61H
52H 33H 62H
53H 44H 63H
54H 55H 64H
55H 66H 65H
56H 77H 66H
57H 88H 67H
58H 99H 68H
After Execution

Source Destination

50H 11H 60H 11H


51H 22H 61H 22H
52H 33H 62H 33H
53H 44H 63H 44H
54H 55H 64H 55H
55H 66H 65H 66H
56H 77H 66H 77H
57H 88H 67H 88H
58H 99H 68H 99H
Soure Destination
A
11h

50H 11H 60H 11


51H 22H 61H
52H 33H 62H
53H 44H 63H
54H 55H 64H
55H 66H 65H
56H 77H 66H
57H 88H 67H
58H 99H 68H
Program(1)
• Let us store the Size of the Block in
Register r2.
• Store the Starting address of Source at
Memory Location 50H.
• Store the Starting address of Source at
Memory Location 60H
Program(2)
• org 0000h
• Mov r2, #0ah
• Mov r0, #50h
• Mov r1, #60h
• Mov a, @r0
• Mov @r1, a
• Inc r0
• Inc r1
• Djnz r2, Loop1
• end
2) Program to Exchange Block of Data
• Org 0000h
• Mov r2,#0ah
• Mov r0,#50h
• Mov r1,#60h
• Mov a, @r0
• Push e0h
• Mov a,@r1
• Mov @r0, a
• Pop e0h
• Mov @r1, a
• Inc r0
• Inc r1
• Djnz r2, Loop
• end

You might also like