Hi,
I want to display a char[] from a banked page without using the -CpPPAGE=RUNTIME compiler option.
I think I can use the lower 2 bytes of the address of the char[] since I will display the data from the same page.
So my goal is to convert a char *far to a char *near.
*far is on 3 bytes : Page, High address, Low address
*near is on 2 byers : High address, Low address.
The code below works but I have a compiler warning. What is exact way to convert a *far to a *near without a compiler warning.
Note : The data and the code are in page 3D.
Thanks..
#pragma CONST_SEG __PPAGE_SEG BANKED_DATA_3D
static const char my_string[] = "This is a string"; // Located in page 3D
#pragma CODE_SEG ROM_3D
#pragma CONST_SEG CONST_3D
void far_pstr(const sc *far ptr)
{
while (*ptr) { putchar(*ptr++); }
}
void near_pstr(const sc *ptr)
{
while (*ptr) { putchar(*ptr++); }
}
void print_test(void)
{
char *ptr = my_string; // This gives : Warning : C1860: Pointer conversion: possible loss of data
char *near ptr2 = (char *near) my_string; // This gives : Warning : C1860: Pointer conversion: possible loss of data
near_pstr(my_string); // This gives : Warning : C1860: Pointer conversion: possible loss of data
far_pstr(my_string); // This gives : Warning : C12002: Use DPAGE, PPAGE, EPAGE to specify the page register. Assumed DPAGE
}