I am still having trouble making this work. I had already tried what you suggested, but I revisited it to make sure...unfortunately, still no go.
I wondered if I needed to explicitly cast the "near" parameter to a far pointer, but even that fails.
One other piece of info I neglected to mention.One of the buffers is set up to be in global memory (making use of GPAGE register as opposed to the RPAGE reg). I do not manipulate the GPAGE register directly, but rely on the compiler to figure this out.
In the prm file, I have the following code:
SEGMENTS
// For bevity I am not showing all the definitions for paged and non-paged RAM, FLASH, EEPROM, etc....
GLOBAL_RAM = READ_WRITE 0x0F0000'G TO 0x0F7FFF'G; // This is the global memory I will use for my buffer.
END
PLACEMENT
// For bevity I am not showing all the various placements...
EXTRA_RAM INTO GLOBAL_RAM; // Put buffer here.
END
In my source code, I tell the compiler to use GPAGE reg for this buffer and its pointer...as shown:
#define MY_GLOB_TEST_SIZE 20
#pragma push
#pragma DATA_SEG __GPAGE_SEG EXTRA_RAM
char myGlobalTest[MY_GLOB_TEST_SIZE];
char * __far myGlobalTestPtr;
#pragma pop
I also have another buffer and accompanying pointer that are NOT in global memory, as shown here (these are file scope variables):
char myDest[MY_GLOB_TEST_SIZE];
char *myDestPtr;
So far so good. Everything seems to work as expected with regards to reading and writing to both of these buffers, except when using the copy routine to copy between them. The copy routine is as you listed it with both arguments specifiying far pointers.
To debug this I print out the pointer values before I call the copy routine, and then inside the copy routine I print the values of the pointers as they are received. Here are the results:
FIRST TEST - I call the copy routine with a source pointer that is a far pointer and a destination pointer that is not.:
debugCnt = CopyString(myGlobalPtr, myDestPtr);
RESULT:
Values of pointers before calling:
myGlobalPtr = 000F0000
myDestPtr = 000031AF
Values of pointers inside CopyString:
ptr1 = 000F0000
ptr2 = 00AF0000 (??? this is no good)
2ND TEST - I call the copy routine with a source pointer that is a far pointer and a dest ptr that is cast to a far ptr:
debugCnt = CopyString(myGlobalPtr, (byte* __far)myDestPtr);
RESULT:
Values of pointers before calling:
myGlobalPtr = 000F0000
myDestPtr = 000031AF
Values of pointers inside CopyString:
ptr1 = 000F0000
ptr2 = 00AF31AF (??? Where did the hex AF come from? I expected the upper byte to be zeroed out)
Any clues as to what I am doing wrong?
Thanks again for your help.
KG