This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Clear Memory section of start166.a66

Hi all,
i am using ST10.
i like to know following thing. if someone having data for it please send.
1) How Clear Memory section logic of start166.a66 works.
2) Who initialized veriable ?C_CLRMEMSECSTART and how it get utilized in all logic?
3) Can i able to set fix address for
?C_CLRMEMSECSTART?

Regards...
Yogesh.

  • 1) I can't remember where but I read something about it. It's a block of memory that contains memory locations and their size that have to be cleared. Same for the INIT section, which also contains the data that it has to be initialized with.

    2) It's used by startup.a66. My startup.a66 contains CLR_MEMORY=1 and INIT_VARS=1 that enable some assembly code that reads the CLRMEMSECSTART and INIT sections to clear or initialize that data/variables.

    This code is essential for your C files that use zero-initialized or pre-initialized code (int i; -> i is cleared to 0 using the CLEAR section ; int i=5; -> i is initialized to 5 using the INIT section). If you use #pragma noinit, the variable is -not- listed in the CLEAR section and does not get initialized to 0.

    3) http://www.keil.com/support/man/docs/l166/l166_cinittab.htm

    or perhaps the SECTIONS directive.

    If you look at the clear and init routines in startup.a66 you might be able to understand what the assembly does, it's not that much code.

    I can't help you with external documentation with more info about the structure of the sections.

    Regards,
    Joost Leeuwesteijn

  • Hi Joost Leeuwesteijn and All,

    Nice feedback. It solved my various problem.

    if i want to remove INITSEC and CLRMEMSEC from start166.a66 and place it in other C file (which i can able to locate at any address), then how i will go for it.

    regards...

    Yogesh.

  • Hi Yogesh,

    if i want to remove INITSEC and CLRMEMSEC from start166.a66 and place it in other C file (which i can able to locate at any address), then how i will go for it.

    Not sure why you would want to remove it from startup.a66. And it's assembly code so why do you want to put it in a C file?

    You can still put the INITSEC and CLRMEMSEC at a different location when they're in startup.a66, or a seperate .a66 file if you really want to.

    It's -really- part of the startup code so if you're absolutly sure you do want to put in a seperate file (for some reason), make sure you call it from startup.a66 and use all the settings (CLRMEM=1, etc.).

    Wait, hang on... Is missed something. There's two things here: the SECTIONS and the assembly code that uses them. You can put the assembly code somewhere else (why?) but the sections are created by the linker, you can't define them somewhere else. The linker collects all the CLEAR and INIT variables and puts them in the INITSEC and CLRMEMSEC structure.

    My startup.a66 contains:

    EXTRN    ?C_CLRMEMSECSTART : WORD
    


    Which is the "link" to the CLRMEM section. This is how startup.a66 uses/knows it. Do a search on "C_CLRMEMSECSTART" in the map file (.m66) and notice that it says "LINKER GENERATED" (at least in my output).

    Take a look again at:
    http://www.keil.com/support/man/docs/l166/l166_cinittab.htm

    Isn't this what you're looking for? We are using a way-old dev kit in our project that doesn't have CINITTAB but I'm still able to use the SECTIONS() linker directive to put the sections where I want them:

    SECTIONS(
        ; must be in ascending order
        ?C_INITSEC(0x030000),
        ?C_CLRMEMSEC
    )
    

    Regards,
    Joost Leeuwesteijn