Home arrow Support arrow Forums

Luminary Micro Forums

<< Start < Prev 1 2 Next > End >>

rocksoft

Expert Boarder
Click here to see the profile of this user

2008/07/24 10:19

For sharing: Memory copy routine

Hi,

I recently finished a "memcpy" replacement and thought it might be useful for others...

I've put some instructions and the code here:

http://www.rock-software.net/downloads/memcpy/

Hope it works for you as well as it did for me.

Liam.

login or register to reply

jrmymllr

Platinum Boarder
Click here to see the profile of this user

2008/08/11 13:36

Re:For sharing: Memory copy routine

rocksoft wrote:
Hi,

I recently finished a "memcpy" replacement and thought it might be useful for others...

I've put some instructions and the code here:

http://www.rock-software.net/downloads/memcpy/

Hope it works for you as well as it did for me.

Liam.


Thank you for sharing this. I'm going to try it since my project uses a lot of memcpy and I'm suspecting I can save some CPU cycles with a better implementation. Question though, since I am pretty clueless on including assembly into C source. I added your .s file into my makefile; I had to change the comment characters (from // to @) otherwise my compiler seems to like it. I'm using CodeSourcery GCC. I extern'ed MEM_DataCopy(int, int, int), and made a call to the function in my code which I thought might work but didn't. I get an "undefined reference to MEM_DataCopy". Any tips on getting this to work?

Thanks again for sharing this.

login or register to reply

rocksoft

Expert Boarder
Click here to see the profile of this user

2008/08/11 16:12

Re:For sharing: Memory copy routine

Hi,

The ".global" at the top should make it visible to the linker, however if you're compiling as C++ you might need to check the name mangling.

The ".extern" assembler directive tells the assembler a symbol is elsewhere, ".global" says it's in the assembly file and should be exposed.

My project is pure 'C' so if you are using C++ this might be where the difference is. You could check the map file to see if it thinks it's called something else. Perhaps some underscores are required etc...

The other thing to check is that the linker can see that it is used, it's unlikely but it might be being optimised away! If you're into linker scripts you can force it to keep it using the KEEP directive.

I use an "old-ish" version of the CodeSourcery GCC too, supplied with the Rowley tool chain, and the file assembles and links OK with that so I guess you're not too far off getting it going.

Hope this helps.

Liam.

PS: this is the command line the Rowley build system produces for my file (path names removed for brevity!)...

"as" --traditional-format -mcpu=cortex-m3 -mthumb -mthumb-interwork -EL -mfpu=vfp -mfloat-abi=soft "<source file>" -o "<object_file>"

Post edited by: rocksoft, at: 2008/08/11 16:18

login or register to reply

jrmymllr

Platinum Boarder
Click here to see the profile of this user

2008/08/12 05:49

Re:For sharing: Memory copy routine

It seems I made a dumb error; I didn't include memcpy.o into the list of files to be linked. Now it compiles....later I'll be testing it against GCC. I'll report here what my results are.

login or register to reply

rocksoft

Expert Boarder
Click here to see the profile of this user

2008/08/12 06:03

Re:For sharing: Memory copy routine

Easily done! I will be interested to see the results.

Regards,

Liam.

login or register to reply

jrmymllr

Platinum Boarder
Click here to see the profile of this user

2008/08/12 16:05

Re:For sharing: Memory copy routine

I'm copying 1400 bytes in a TCP/IP app. I did both memcpy and your routine one after the other, copying the same data. I toggled an output and connected a scope to that to do timing. 232uS vs. 36uS, a reduction by over 6 times! That is really cool.

login or register to reply
<< Start < Prev 1 2 Next > End >>