On 15/10/11 8:56 PM, Chuck Guzis wrote:
On 15 Oct 2011 at 17:57, Dave McGuire wrote:
That said, also, some strcpy() and memcpy()
implementations do deal
with overlapping source/target regions just fine. They're slower,
though...once again spending cycles to compensate for the shortcomings
of programmers who would be better suited to flipping burgers than
writing software.
And sometimes there are functions that are guaranteed to work, no
matter the overlap (e.g. memmove() vs. memcpy() ).
But what kind of person would use the given sample loop, rather than
a library routine?
Similar loops, with one or two increments or decrements, are a common
idiom, with pointers to a variety of types. Stepping through memory with
a fixed quantum is not that crazy, though of course a length condition
might be used, per Josh's concern.
When working with C on an unfamiliar platform, I study the generated
code both to get a handle on how the compiler handles code generation
for the platform. I realize that this is probably considered to be
"old fashioned" however.
C was a great assembler for the PDP-11, but for other platforms,
maybe not so much. How, for example, do you implement byte
pointers on hardware that only addresses words? (e.g. Cray 1).
See my other response. It was certainly done.
--Toby
Most 8080 Cs were perfectly dreadful--and I've been surprised to see
C implementations on 8-bit PIC hardware.
--Chuck