TIP: Click on subject to list as thread! ANSI
echo: public_domain
to: Frank Malcolm
from: Paul Edwards
date: 1996-01-12 09:45:48
subject: memcpy

PE> PE> memcpy is designed to copy from a buffer to another buffer, for
PE> PE> a length of whatever.  No overrun allowed.  Destination to be
PE> PE> returned to caller.  Parameter order is dest, source, length...

PE> FM> You should also mention that it returns *dest (if I've read that 'C'
PE> FM> code properly).

PE> It returns dest, not *dest.

FM> Can you explain that to me in non-'C' terms? Like on say the '86
FM> platform, what would be returned in some registers in each case.

char *ret;
char dest[500];
char source[500];

ret = memcpy(dest, source, 500);

Let's say "dest" is location 0x1111 in memory, and "source" is
location 0x2222 in memory, and source is full of the letter 'A',
ie 0x41.

If memcpy was spec'd to return dest (it is), then it would return
0x1111 in AX.

If memcpy was spec'd to return *dest (it isn't), then it would
return 0x0041 in AX.

Is that what you wanted?  Actually, the assembler code I posted
would basically have told you that.

BFN.  Paul.
@EOT:

---
* Origin: X (3:711/934.9)

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.