Discussion Forum

data group use with no reason ?

Next Thread | Thread List | Previous Thread Start a Thread | Settings

DetailsMessage
Read-Only
Author
erik malund
Posted
26-Sep-2001 19:20 GMT
Toolset
C51
New! data group use with no reason ?
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
Read-Only
Author
Jon Ward
Posted
27-Sep-2001 03:30 GMT
Toolset
C51
New! RE: data group use with no reason ?
what are those data segment bytes...

Check the following knowledgebase article.

http://www.keil.com/support/docs/1242.htm

Jon
Read-Only
Author
Andrew Neil
Posted
27-Sep-2001 09:52 GMT
Toolset
C51
New! RE: data group use with no reason ?
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!
Read-Only
Author
Graham Cole
Posted
27-Sep-2001 12:15 GMT
Toolset
C51
New! RE: data group use with no reason ?
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.
Read-Only
Author
erik malund
Posted
27-Sep-2001 13:41 GMT
Toolset
C51
New! RE: data group use with no reason ?
REGUSE () makes no difference and the assembler code generated by the C compiler is identical, what is going on ?

Erik
Read-Only
Author
Jon Young
Posted
27-Sep-2001 14:22 GMT
Toolset
C51
New! RE: data group use with no reason ?
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) {};

2) I am just checking. Do you do realize the Keil compiler is not "Stack based"? So things like parameters, local variables, and compiler temporaries are preallocated in valuable Data segments. Only the return addresses are placed on the stack.

3) Can you post an example that creates an extraneous Data segment. (Otherwise we are just shooting in the dark.)

Next Thread | Thread List | Previous Thread Start a Thread | Settings