David Jones wrote:
On May 25, 2004 09:38 am, Paul Nevai wrote:
[Note: I filled in the attribution here. Do not attribute posts to "you",
as this is a mailing list/newsgroup, not a one-on-one e-mail.]
In terms of efficiency and speed, are there any pros and contras in using
MemMove() vs StrCopy(), StrCat(), etc.?
And how do they compare against just coding the functions yourself?
L1: MOVE.B (A0)+,(A1)+; DBRA D0,L1 is pretty tight. You can likely code basic
versions of all of these in under 100 bytes of memory.
But memmove is much more complicated than that; it handles overlapping
regions of memory, which that won't, and it is (hopefully) faster than that
implementation. If you don't have to calculate the length, you can gain a
speed improvement of a factor of 5 or so by working in long mode and
partially unrolling the loop, and even more by using the movem instruction.
Generally speaking, memmove/memcpy are NOT functions you want to write
yourself unless you are very intimately familiar with the target processor.
That said: MemMove should be optimized to heck for moving huge blocks of
memory really fricken fast. StrCopy and StrCat, probably not so optimized,
as they're for strings and will presumably never be used on anything big.
But it doesn't matter because StrCopy and StrCat are for null-terminated
strings only, while MemMove is for binary data and not very useful for
null-terminated strings. So they're never in competition.
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/support/forums/