I add and call 2 assembler routines defined in C as void rtn (void) to a C program After being surprised I rewrite the assembler routines as rtn: ret I get the following linker error: *** ERROR 107: ADDRESS SPACE OVERFLOW SPACE: DATA SEGMENT: _DATA_GROUP_ LENGTH: 002AH I know what the message means and can possibly salvage some data space elsewhere BUT: what are those data segment bytes and is there any way to get rid of this (non)use of valuable space ? Erik Malund
what are those data segment bytes... Check the following knowledgebase article. http://www.keil.com/support/docs/1242.htm Jon
What version are you using? I found a bug in C51.exe v6.20, which could generate a spurious empty data segment; I know that's not what you're seeing, but maybe related? Keil fixed it in v6.20b. Also, there is a long-standing "feature" of the Global Register Optimisation which can cause the link to fail with ADDRESS SPACE OVERFLOW if your DATA space is very nearly full; eg, I have a project which has only 1 spare byte of DATA space; so long as this has been successfully built at least once before, further builds will work. However, if I completely clean the project directories of all generated files, the link fails with ADDRESS SPACE OVERFLOW! This is due to the project.ORC file, which is not removed by uVision's 'Rebuild All' option. It seems that this file gives the Global Register Optimiser a "head start" without which it can't manage to fit the project!
If a function calls an assembly language routine, the C compiler must assume that all the registers are potentially overwritten. Consequently, in the calling function there will be less fredom to allocate variables to registers - they have to be put into memory instead. That may be why the addition of a zero-functionallity assembler routine causes the overall application to use more data memory that before. If you are using global register optimisation, then I belive that there is a method of telling the compiler about which registers are used by an assembly language routine - see the REGUSE keyword in the A51 Assembler manual. I have never tried this myself.
REGUSE () makes no difference and the assembler code generated by the C compiler is identical, what is going on ? Erik
1) What happens when you replace the assembly with this C code? (I.E. try to remove the assembler from this problem.)
void rtn1 (void) {}; void rtn2 (void) {};