memcpy()
written in ARM Cortex-M Assembly. Designed for Cortex-M4 and M0+ cores. Probably works on other ARMv6-M and ARMv7-M architectures.
Does everything I need it to. Will fix bugs as I come across them.
- Copy
mmemcpy.s
from the common/src folder into your project - Add a function declaration for
memcpy_()
somewhere in your project. The function declaration should look something likeextern void* memcpy_(void *destination, const void *source, size_t num);
. - Use
memcpy_()
just like you would the normalmemcpy()
function. - Done!
- copy these files into an embedded project.
- compile the project.
- measure the size of the
mmemcpy.o
object file usingsize -A
. - the total size is found from summing all relevant sections together.
Compiles down to 132 bytes on arm-none-eabi-gcc
. mmemcpy.s is about 80 lines of code (per David A. Wheeler's SLOCCount
).
In my testing, memcpy_()
is always faster than the standard memcpy()
used on the Cortex-M0+ core. It is slower than the memcpy()
used on the Cortex-M4, primarily because my implemention doesn't perform unaligned memory access.
This repo is designed to run on an STM32WLxx microcontroller. It uses the cycle counter of the Cortex-M4 microcontroller to profile the functions during testing.
Note: the environment this repo was developed in is only important to know if you want to test the memcpy_()
function like I did. If you just want to use it, follow the instructions in How to use this in an embedded project.
I also included testing using Greatest from https://github.com/silentbicycle/greatest. There's a number of tests that compare memcpy_()
against the standard memcpy()
.