Re:For sharing: Memory copy routine
That's a nice bit of code, which should be useful to most readers.
I always recommend that it's worthwhile to spend some time optimizing block copy code in the library - it's particularly important on the ARM where you have load and store multiple instructions available. The ARM tools have similar routines in the library already.
People might also want to look at zero-initialization routines like memset() in the same way - no point spending thousands of cycles writing zeroes to memory using LDRB and STRB when you can write 40+ bytes with a single STM instruction.
Also, if memcpy() performance is important in your system, it's a good idea to understand the bus interface of the memory you're dealing with. Rocksoft's code copies in blocks of 40 bytes (10 words). If your flash or SDRAM plays nicely with lines of 32 bytes (8 words) starting on an 8 word boundary, for example, you may find you get better results by modifying memcpy() to do the same.
login or register to reply
|