Arm/memmove

From ASMBits

arm/fib3Previous

Write a function that copies a block of memory from the source location to the destination location. The source and destination arrays may overlap, and the copy must still work correctly (contrast memmove with arm/memcpy). The source and destination are byte-aligned, and length can be any number of bytes.

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

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

Expected solution length: Around 25 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 memmove
13
    1: b 1b    // Done
14
15
.global memmove
16
memmove:
17
    
18
    
Upload a source file...