This is the mail archive of the
newlib@sourceware.org
mailing list for the newlib project.
Bug in m68k memcpy/memcmp
- From: Eric Norum <norume at aps dot anl dot gov>
- To: kazu at codesourcery dot com
- Cc: newlib at sources dot redhat dot com
- Date: Fri, 27 Apr 2007 15:39:26 -0500
- Subject: Bug in m68k memcpy/memcmp
The proposed patch to the M68k versions of memcpy/memset has a nasty
bug:
+.Lcopy:
+#if !defined (__mcoldfire__)
+ dbra %d0,1b
+#else
+ subq.l #1,%d0
+ bpl 1b
+#endif
The non-ColdFire version uses dbra -- which uses only the lower 16-
bits of the counter register.
The above code will fail for transfers greater than 16*65535 bytes.
There needs to be another decrement of the most-significant 16-bits
of the count register and another conditional branch and conditional
branch added to all the 'dbra' loop tests.
Off the top of my head, I think that there needs to be something like:
+.Lcopy:
+#if !defined (__mcoldfire__)
+ dbra %d0,1b
+ subl #0x10000,d0
+ bpl 1b
+#else
+ subq.l #1,%d0
+ bpl 1b
+#endif
--
Eric Norum <norume@aps.anl.gov>
Advanced Photon Source
Argonne National Laboratory
(630) 252-4793