ARM Technical Support Knowledge Articles

EXTERNAL MEMORY ACCESSED FOR DATA MEMORY POINTER

Applies to: C51 C Compiler

Answer


Information in this article applies to:


QUESTION

The following line of code generates the wrong instructions:

void main(void)
{
  i= *( char data *)(0x70+i);
}

External memory is accessed instead of internal for

*(0x70+i);

(listing file contains wrong mnemonic in place of actually generated instruction MOVX A,@R1).

ANSWER

This is a bug in the C51 compiler and it will be fixed in a future version. The following is a workaround and the only difference is that 'i' is explicitly cast to an unsigned char:

void main(void)
{
  i= *( char data *)(0x70+((unsigned char)i));
}

Article last edited on: 2004-06-15 14:43:58

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