Pete C. wrote:
Gernot Frisch wrote:
Hi,
I saw that the PocketHAL library has a faster memcpy for large blocks
on an StrongARM processor. Can anyone give me the source for such a
memcpy?
It's probably in Assembler, but such platform-specific things are off-topic
here. You might try asking Thierry over on the forums for PHAL on
pocketmatrix.com.
- Pete
[Off-Topic]
A faster memcpy involves using conditional execution and
also the block load and store instructions.
Here is a sample:
memcpy_byte
STMFD sp!,{r0-r3} ; Save registers (ARM / 32-bit mode)
ANDS R2, R2, R2 ; Set up condition codes (Z / NZ)
memcpy_loop
LDRNEB R3, [R1], #1 ; if R2 != 0, Load value from source
(and increment).
STRNEB R3, [R0], #1 ; if R2 != 0, Store fill value into
[r0] & incr R0.
SUBNES R2, R2, #1 ; if R2 != 0, decrement R2
LDRNEB R3, [R1], #1 ; if R2 != 0, Load value from source
(and increment).
STRNEB R3, [R0], #1 ; if R2 != 0, Store fill value into
[r0] & incr R0.
SUBNES R2, R2, #1 ; if R2 != 0, decrement R2
LDRNEB R3, [R1], #1 ; if R2 != 0, Load value from source
(and increment).
STRNEB R3, [R0], #1 ; if R2 != 0, Store fill value into
[r0] & incr R0.
SUBNES R2, R2, #1 ; if R2 != 0, decrement R2
LDRNEB R3, [R1], #1 ; if R2 != 0, Load value from source
(and increment).
STRNEB R3, [R0], #1 ; if R2 != 0, Store fill value into
[r0] & incr R0.
SUBNES R2, R2, #1 ; if R2 != 0, decrement R2
BNE memcpy_loop ; loop around if more bytes to process.
LDMFD sp!,{r0-r3} ; Restore registers (ARM / 32-bit mode)
BX R14 ; Return to caller.
--
Thomas Matthews
C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq:
http://www.parashift.com/c++-faq-lite
C Faq:
http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq:
http://www.raos.demon.uk/acllc-c++/faq.html
Other sites:
http://www.josuttis.com -- C++ STL Library book