ARM Technical Support Knowledge Articles

USING 24-BIT MATH WITH FAR POINTERS

Applies to: CX51 C Compiler

Answer


Information in this article applies to:


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

Article last edited on: 2008-01-28 00:34:23

Rate this article

[Bad]
|
|
[Good]
Disagree? Move your mouse over the bar and click

Did you find this article helpful? Yes No

How can we improve this article?

Link to this article
Copyright © 2011 ARM Limited. All rights reserved. External (Open), Non-Confidential