home *** CD-ROM | disk | FTP | other *** search
/ The Fred Fish Collection 1.5 / ffcollection-1-5-1992-11.iso / ff_disks / 300-399 / ff362.lzh / MemRoutines / readme < prev    next >
Text File  |  1990-08-11  |  2KB  |  61 lines

  1. A few months ago, when I was doing some serious debugging, I accidentally
  2. discovered that the Lattice C functions memcpy, memcmp, and memset, as
  3. well as the Aztec C functions movmem and setmem, all deal with data one byte
  4. at a time. With a 68000 processor, this doesn't matter much, especially if
  5. you take advantage of Lattice C's capability to deal with these functions
  6. as "built-in". However, Amigas with 68020 and 68030 processors, and 32-bit
  7. wide memory, are starting to proliferate. With this sort of hardware, you
  8. can definitely improve performance by processing data a long word at a time,
  9. instead of a byte at a time.
  10.  
  11. The three functions in this package, memcpy(), memcmp(), and memset(), are
  12. "plug-compatible" replacements for the Lattice functions of the same name.
  13.  
  14. char *memcpy(),*memset(),*to,*from,*s1,*s2,*toaddr,ch;
  15. long int memcmp(),count;
  16.  
  17. toaddr = memcpy(to, from, count);
  18.  
  19.     from = pointer to data to be copied
  20.     to = pointer to area that data is to be copied to
  21.     count = number of bytes to be copied
  22.     toaddr = pointer to area that data was copied to
  23.  
  24. x = memcmp(s1, s2, count);
  25.  
  26.     s1, s2 = pointers to data to be compared
  27.     count = number of bytes to be compared
  28.     x = 0 if s1 and s2 are identical; Contains a negative value if
  29.          s1 < s2, or a positive value if s1 > s2
  30.  
  31. toaddr = memset(to, ch, count);
  32.         
  33.     to = pointer to area that is to be set
  34.     ch = value to set area to
  35.     count = number of bytes to set
  36.     toaddr = pointer to area that was set
  37.  
  38. Note that with Aztec C, the "count" parameter must be "long".
  39.  
  40. Two libraries are provided, memorya.lib, the Aztec version (sorry, 3.6a),
  41. and memoryl.lib, the Lattice version. When linking, this file must be
  42. included before the normal library (c.lib for Aztec, lc.lib for Lattice).
  43. If you are using Lattice C, "#include string.h" statements should be
  44. removed or commented out.
  45.  
  46. Using these routines with Aztec C should never cause a performance
  47. penalty, even with a 68000 processor, unless you call them a
  48. disproportionately large number of times with parameters that are not
  49. word-aligned. With Lattice C, you may find a degradation in performance
  50. if most of your calls to the functions have a value of less than 8 for
  51. "count". This is because using the built-in versions of the functions
  52. means less overhead entering and exiting the functions.
  53.  
  54. This software is public-domain.
  55.  
  56.                     Robert Broughton
  57.                     328-1027 Davie St.
  58.                     Vancouver, BC V6E 4L2
  59.                     Canada
  60.                     USENet: a1040@mindlink.UUCP
  61.