Memcpy in ARM Assembly
Write an optimised memcpy in ARM assembly that copies word-at-a-time when both pointers are aligned and falls back to bytes otherwise.
Constraints
- Signature: void *memcpy(void *dst, const void *src, size_t n) with AAPCS registers.
- Copy words when both pointers are 4-byte aligned and at least 4 bytes remain.
- Handle the leading and trailing unaligned bytes.
- Must return the original destination pointer.
- Do not use LDM/STM with more than 4 registers.
- Preserve r4 and above if used.
1.global memcpy2.type memcpy, %function3memcpy:4 @ r0 = dst, r1 = src, r2 = n5 @ TODO6 bx lr