| ||||||||
Technical Support Support Resources Product Information | C51: CONSTANT ARRAYS LARGER THAN 64KBInformation in this article applies to:
QUESTIONI want to create a constant array larger than 64KB using the following construct:
#pragma ROM(D512K)
unsigned char const far array[] = {
1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,
:
}
Since the data is more than 64KB, I receive the error message: *** ERROR C249: 'array': ALLOCATION EXCEEDS 64K Is there a way to create a constant array larger than 64KB? ANSWERYes. You may use an assembly program to define such an large array. Your example would translate into: PUBLIC array ?HC?ARRAY SEGMENT HCONST RSEG ?HC?ARRAY array: DB 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16 : END The AX51 assembler has no limitations on the size of an array. In C51 you may address this array as shown below:
#pragma ROM(D512K)
extern unsigned char const far array[];
unsigned char test (long l) {
unsigned char c;
c = array[l];
return c;
}
Note that the array index l is defined as unsigned long to allow 24-bit address arithmetic. MORE INFORMATION
SEE ALSOFORUM THREADSThe following Discussion Forum threads may provide information related to this topic. Last Reviewed: Monday, October 10, 2005 | |||||||
| ||||||||