home *** CD-ROM | disk | FTP | other *** search
- A few months ago, when I was doing some serious debugging, I accidentally
- discovered that the Lattice C functions memcpy, memcmp, and memset, as
- well as the Aztec C functions movmem and setmem, all deal with data one byte
- at a time. With a 68000 processor, this doesn't matter much, especially if
- you take advantage of Lattice C's capability to deal with these functions
- as "built-in". However, Amigas with 68020 and 68030 processors, and 32-bit
- wide memory, are starting to proliferate. With this sort of hardware, you
- can definitely improve performance by processing data a long word at a time,
- instead of a byte at a time.
-
- The three functions in this package, memcpy(), memcmp(), and memset(), are
- "plug-compatible" replacements for the Lattice functions of the same name.
-
- char *memcpy(),*memset(),*to,*from,*s1,*s2,*toaddr,ch;
- long int memcmp(),count;
-
- toaddr = memcpy(to, from, count);
-
- from = pointer to data to be copied
- to = pointer to area that data is to be copied to
- count = number of bytes to be copied
- toaddr = pointer to area that data was copied to
-
- x = memcmp(s1, s2, count);
-
- s1, s2 = pointers to data to be compared
- count = number of bytes to be compared
- x = 0 if s1 and s2 are identical; Contains a negative value if
- s1 < s2, or a positive value if s1 > s2
-
- toaddr = memset(to, ch, count);
-
- to = pointer to area that is to be set
- ch = value to set area to
- count = number of bytes to set
- toaddr = pointer to area that was set
-
- Note that with Aztec C, the "count" parameter must be "long".
-
- Two libraries are provided, memorya.lib, the Aztec version (sorry, 3.6a),
- and memoryl.lib, the Lattice version. When linking, this file must be
- included before the normal library (c.lib for Aztec, lc.lib for Lattice).
- If you are using Lattice C, "#include string.h" statements should be
- removed or commented out.
-
- Using these routines with Aztec C should never cause a performance
- penalty, even with a 68000 processor, unless you call them a
- disproportionately large number of times with parameters that are not
- word-aligned. With Lattice C, you may find a degradation in performance
- if most of your calls to the functions have a value of less than 8 for
- "count". This is because using the built-in versions of the functions
- means less overhead entering and exiting the functions.
-
- This software is public-domain.
-
- Robert Broughton
- 328-1027 Davie St.
- Vancouver, BC V6E 4L2
- Canada
- USENet: a1040@mindlink.UUCP
-