Mail Archives: djgpp/2004/08/08/23:15:36
On Sun, 8 Aug 2004 22:53:04 +0200 in comp.os.msdos.djgpp, Werner
Schönenberger <werner DOT schoenenberger AT gmx DOT ch> wrote:
>> If the application uses C code and normal C startup code, allocating
>> those variables as if they were C extern in the BSS segment will cause
>> them to be zeroed at program initialization.
>> Alternatively, look at how GCC handles BSS zeroing, for an example of
>> how to do it properly, by arranging symbols with the linker.
>thank you for the information. Unfortunately almost all code is written
>in assembler which also doesn't make it easy to understand and to find
>all the traps. But nevertheless to check out GCC might help to find a
>solution.
If you define a file globals.c (below), provide a(n alias for the
entry point) symbol in your program called _main (or main if in C
code), compile it (with gcc option -fno-leading-underscore) and link
it with gcc to your other code, you should find that the symbols are
defined in order in memory and initialized to all bytes zero when your
code is called, and the names should not be prefixed by the normal _.
You might also have to change the current name of the entry point
symbol in your program to _main if it conflicts with the C startup
code: file crt0.S symbol start for gcc IIRC.
globals.c:
short A;
short b;
long c;
short d;
double e;
short f;
short Z;
--
Thanks. Take care, Brian Inglis Calgary, Alberta, Canada
Brian DOT Inglis AT CSi DOT com (Brian dot Inglis at SystematicSw dot ab dot ca)
fake address use address above to reply
- Raw text -