 | Discussion Forum |  |
|
|
Wrong mapping with C251 v2 compilerNext Thread | Thread List | Previous Thread Start a Thread | Settings | Details | Message |
|---|
Read-Only Author Jean-Charles SCHINTZIUS Posted 29-Nov-2001 12:33 GMT Toolset C251 |  Wrong mapping with C251 v2 compiler Jean-Charles SCHINTZIUS Hi,
I am trying to recompile a project with C251 v2.This project was originaly compiled with C251 v1.
In one of my C files I use a string table declared like this :
char code *ErrorMess[]={"error1",
"error2",
"error3"};
With C251 v1 compiler, this constant was accurately mapped in CODE area, but with C251 v2, it is mapped in XDATA or EDATA area according the selected memory model.
What am I doing wrong ? | | Read-Only Author tom mazowiesky Posted 29-Nov-2001 14:40 GMT Toolset C251 |  RE: Wrong mapping with C251 v2 compiler tom mazowiesky I tried to compile what you had, and I kept getting an error (*** WARNING 151 IN LINE 2 OF X.C: pointer truncation: 'near const' to 'code')that indicated i couldn't reach it because I had a near pointer to a far object. I changed what you sent to this:
char far *ErrorMess[]={"error1",
"error2",
"error3"};
You should probably add the const as well, so that the compiler has knowledge that these entries are constants. This will help prevent any inadvertant write accesses. Even if the constants are in ROM or EPROM, this will signal a warning from the compiler or a tool such as LINT that there is a problem.
const char far *ErrorMess[]={"error1",
"error2",
"error3"};
The objects will be stored in const, which you can assign to any physical memory space you want using the linker. Hope this is helpful.
In our project, the following is included in a model.h file, which all modules include. Our targets can also be 8051 types, so with these defines, we can cross map the variables without changing the code itself. We then use the more extensive linker controls for the 251 to place the various memory segments properly. You could also switch to a different processor, redefine these objects, and compile your code without extensive re-writing.
#ifdef __C251__
/* Memory segment defines: */
#define HUGE huge /* 16 Meg indirect addressing, full access */
#define FAR far /* 16 Meg indirect addressing, in page */
#define NEAR near /* 64k direct and indirect addressing */
#define DATA near /* On-chip data */
#define XDATA near /* was far */
#define FXDATA xdata /* */
#define PDATA /* Paged xdata */
#define CODE far /* */
#define IDATA idata /* */
#define BDATA bdata /* Bit addressable memory */
#define EBDATA ebdata /* Extended bit addressable memory */
#define SBIT sbit
#define BIT bit
#endif
#ifdef __C51__
/* Memory segment defines: */
#define HUGE
#define FAR xdata
#define NEAR xdata
#define DATA data
#define XDATA xdata
#define FXDATA idata
#define PDATA pdata
#define CODE code
#define IDATA idata
#define BDATA bdata
#define SBIT sbit
#define BIT bit
#endif
| | Read-Only Author Jean-Charles SCHINTZIUS Posted 29-Nov-2001 17:05 GMT Toolset C251 |  RE: Wrong mapping with C251 v2 compiler Jean-Charles SCHINTZIUS Thank you for your answer, but your solution didn't change anything.
There are 59 error messages in my ErrorMess table. When I have a look to the map file, the compiler assigns 118 bytes to this tables.
So it seems as if these are pointers to each text line of the table, whose text is written somewhere else, maybe in code area.
Canthis be right ? If yes, is it possible to force the pointers in the code area ?
Thanks. | | Read-Only Author tom mazowiesky Posted 29-Nov-2001 23:30 GMT Toolset C251 |  RE: Wrong mapping with C251 v2 compiler tom mazowiesky Yes, you can put the pointers in any memory space, such as:
const char far * code ErrorMess[]={"error1",
"error2",
"error3"};
The addition of the "code" between the asterisk and the ErrorMess, tells the compiler that the pointers are to be stored in code space. When you look at the listing, you will see that the messages themselves are in const, but the pointers are in code. Hope you can use this.
| | Read-Only Author Jean-Charles SCHINTZIUS Posted 4-Dec-2001 09:34 GMT Toolset C251 |  RE: Wrong mapping with C251 v2 compiler Jean-Charles SCHINTZIUS Thank you for the tip. It works. | |
Next Thread | Thread List | Previous Thread Start a Thread | Settings |
|