; *********************************************************************** ; * * ; * Copy an Array of Words * ; * * ; *********************************************************************** ; Author: John Zaitseff ; Date: 9th September, 2002 ; Version: 1.3 ; This program is, in the main, a demonstration of the ARM "ldr" and "str" ; instructions. Do pay attention, however, at the use of the ".data" ; section, which contains read/write data. .text .global _start .equ num, 20 ; Number of words to be copied _start: ldr r0,=src ; R0 = pointer to source block ldr r1,=dst ; R1 = pointer to destination block mov r2,#num ; R2 = number of words to copy loop: ldr r3,[r0],#4 ; Load a word into R3 and update R0 ; (post-indexed: R0 := R0 + 4) str r3,[r1],#4 ; Store the word and update R1 subs r2,r2,#1 ; Decrement the word counter bne loop ; and repeat loop if not finished exit: swi 0x11 .data ; Read/write data follows .align ; Make sure data is aligned on 32-bit ; boundaries src: .word 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 .word 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 ; The ".data" section can contain pre-initialised variables, as shown ; above dst: .word 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 .word 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ; An alternative to directly including twenty "0"'s for the destination ; variable "dst" would be to use the ".skip" directive: ; ; dst: .skip num * 4 ; Reserve 80 bytes (num 32-bit words) .end