.globwrite directive is greater than 65535

If you have a simple question and just want an answer.
Post Reply
martinh
Member++
Posts: 19
Joined: Thu Oct 01, 2015 10:55 am

.globwrite directive is greater than 65535

Post by martinh »

Hello,
 
the instruction
     ValTable[117000] = 0;
causes this error:
     ...\cco7daaa.s:201: Error: A00041 Offset argument of ..globwrite directive is greater than 65535.
 
How would I modify .globwrite to accept higher indexes?
 
Thank you.
Regards,
Martin H.


richard
Respected Member
Posts: 318
Joined: Tue Dec 15, 2009 12:46 am

Post by richard »

The mechanism the tools use to check for parallel usage errors in xC limits the maximum constant index you can use to access a global array to 2^16. A simple example which errors is as follows:

char a[0x10001];

int main() {
  a[0x10000] = 0;
  return 0;
}

One way to workaround this limitation is to access the array using an index that is not a constant expression:

int main() {
  int i = 0x10000;
  a = 0;
  return 0;
}

Alternatively you could take a pointer to the array and access the elements indirectly via the pointer:

int main() {
  char *p = a;
  p[0x10000] = 0;
  return 0;
}

martinh
Member++
Posts: 19
Joined: Thu Oct 01, 2015 10:55 am

Post by martinh »

Good to know. Thank you very much.

Post Reply