Keil Logo

CX51: USING 24-BIT MATH WITH FAR POINTERS


Information in this article applies to:

  • C51 Version 6.23

QUESTION

Is 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?

ANSWER

Yes. 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 ALSO

FORUM THREADS

The following Discussion Forum threads may provide information related to this topic.

Last Reviewed: Monday, January 28, 2008


Did this article provide the answer you needed?
 
Yes
No
Not Sure
 
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.