Tuesday, 18 June 2013

Copy the content of memory location from one place to other (Block copy) in ARM LPC2148


AIM: Copy the content of memory location from one place to other.

THEORY:
This operation is carried out by copying content of 5 memory location. Source memory address is 0x01 and destination memory address is 0x21 by using LDR and STR instructions.


PORCEDURE:
For creating project, we need to take following steps.

1) Create new project
2) Algorithm
3) Simulation of Algorithm
These three steps are involved in procedure.
1) Create new project
1.   Select a new project and give particular name to that project. e.g Block_copy
2.   Select chip NXP (founded by Philips) LPC2148.
3.   For assembly language don’t add startup file.
4.   Select a new editor file, write logic in that file and save it by using .asm extension in assembly language.

2) Algorithm
Algorithm consists of following steps.
Block copy:
1.   Initialize source memory pointer 0x01 to register R0.
2.   Initialize destination memory pointer 0x21 to register R1.
3.   Initialize counter to 4.
4.   By using LDR instruction copy content from 1st memory location and increment address register by one. Post index addressing mode is used here.
5.   By using STR instruction store content to destination memory pointer and increment address register by one. Post index addressing mode is used here.
6.   Decrement counter by one and do this process till it reaches to zero.


3) Simulation of Algorithms
It consists of following steps.
1.   After writing program just build it.
2.   If there are any errors, they will be due to some mistake in typing the program. To locate the error, double click on the first error. Check for the error and remove it. Repeat this till all errors are gone.
3.   Now it’s time to debug. Click on the debug tab and debug program. Check the contents of the registers in assembly language programming and contents of the variables in embedded c programming.

OBSERVATIONS:
Content of the memory locations after copying:
1.   1st memory location : …………………..
2.   2nd memory location : …………………..
3.   3rd memory location : …………………..
4.   4th memory location : …………………..
5.   5th memory location : …………………..

Copy the content of memory location from one place to other in Assembly.
AREA BLOCK_COPY, CODE, READONLY
ENTRY
START
            MOV R0,#04   ; Counter initialization
            MOV R1,#0X01   ; Source address
            MOV R2,#0X21   ; Destination Address
            BL DONE
            SWI 0X11
DONE
            LDR R3,[R1],#1  ; Postindexing mode
            STR R3,[R2],#1   ;Postindexing mode
            SUB R0,R0,#1
            CMP R0,#0
            BNE DONE
            MOV PC,LR
END


No comments:

Post a Comment