Hi
In banked and small memory models all data assumed being near, so memcpy works only for near data (CPU 16bit address space). In large memory model all data is far and memcpy would work for you.
Your copy code should be pretty fast. The only major overhead is compiler generated code to set up GPAGE register on each loop iteration. But you most likely can't remove it from the loop without reworking your copy routine in assembler.
This memcpy should work copying data to and from far data:
void farmemcpy(void * far dest, const void * far src, size_t len)
{
char * far d = dest;
const char * far s = src;
while(len--)
{
*d++ = *s++;
}
}
For more speed in C you can do separate routines for copy to and from far memory. Removing "far" from src or dest should speed up copying a bit.
void toGmemcpy(void * far dest, const void * src, size_t len)
{
char * far d = dest;
const char * s = src;
while(len--)
{
*d++ = *s++;
}
}
void fromGmemcpy(void * dest, const void * far src, size_t len)
{
char * d = dest;
const char * far s = src;
while(len--)
{
*d++ = *s++;
}
}