[gnu.gcc] inline assembly question

sef@kithrup.com (Sean Eric Fagan) (03/02/90)

I would like to write an inline assembly memcpy function
for the i386.  For the lucky uninitiated, the '386 requires
that the source address be in esi, destination address be
in edi, and the number of {bytes,words,long words} to copied
be in ecx.  Now, how do I write a function to do that?

I initially had something like:

	void *memcpy (void *dest, void *src, unsigned int count) {
		void *td, *ts;
		unsigned int len;
		asm ("mov%z1 %0, %1" : "S" (ts) : "g" (src));
		asm ("mov%z1 %0, %1" : "D" (td) : "g" (dest));
		asm ("mov%z1 %0, %1" : "c" (len) : "g" (count));
		asm ("rep ; movsb");
		return (dest);
	}

but this did not quite do what I wanted.  Anybody have any suggestions?

Thanks,

Sean.