| |||||
Technical Support Support Resources
Product Information | CX51: USING 24-BIT MATH WITH FAR POINTERSInformation in this article applies to:
QUESTIONIs there a way to access the linear address space of the Philips 51MX devices using pointers? I've tried the following code and the pointer math is truncated to 16-bits.
void func (void)
{
unsigned char far *ptr;
for (ptr = 0x020000; ptr != 0x080000; ptr++)
{
*ptr = 0xFF;
}
}
Is there a way to do what I want? ANSWERYes. This features is added in C51 Version 7. You may download the latest updates from the Keil Website. For 24-bit pointer arithmetic, you must use long types in your pointer calculations. For example, the following code works:
void func (void)
{
unsigned char far *ptr;
for (ptr = (void far*) 0x020000; ptr != (void far*) 0x080000; ptr+=1UL)
{
*ptr = 0xFF;
}
}
The Keil CX51 C Compiler limits individual objects to 64K in size. So, pointer accesses using normal data objects are restricted to a single segment (64K) and 16-bit math is used. By forcing long pointer arithmetic, you signal the compiler that you want 24-bit address calculations to be performed. MORE INFORMATION
SEE ALSOFORUM THREADSThe following Discussion Forum threads may provide information related to this topic. Last Reviewed: Monday, January 28, 2008 | ||||
| |||||