Arm/memcpy

From ASMBits

Write a function that copies a block of memory from the source location to the destination location. The source and destination are byte-aligned, and length can be any number of bytes.

The source and destination arrays will not overlap. The source and destination arrays do not wrap around the top of memory space (i.e., 0 <= source, and source+length <= 4GB).

void memcpy (char* destination, char* source, unsigned int length);

Expected solution length: Around 10 lines.

Sample Input

0x9999, 0, 0, 0, 0, 0xaaaa, 1, 2, 3, 4, 0xbbbb
Copy 16 bytes from offset 24 to offset 4 

Sample Output

0x9999, 1, 2, 3, 4, 0xaaaa, 1, 2, 3, 4, 0xbbbb

Write your solution here

x
 
1
.data
2
.word 0x9999
3
Dest: .word 0, 0, 0, 0, 0xaaaa
4
Src: .word 1, 2, 3, 4, 0xbbbb
5
6
.text
7
.global _start
8
_start:
9
    ldr r0, =Dest
10
    ldr r1, =Src
11
    ldr r2, =16
12
    bl memcpy
13
    1: b 1b    // Done
14
15
.global memcpy
16
memcpy:
17
    
18
    
Upload a source file...