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

Startup code

Hello All:

How can I reference the start address of the startup code in start167.a66 in a C file? The only thing I can think of doing is

extern void C_STARTUP(void);
but that does not seem to work. As a work around I am pointing to the reset vector address which jumps to the startup code but I like to call it directly if possible.

Thanks,
Walt

  • Seems likes I've found the way. In your startup.a66 find the following:

    ?C_RESET        PROC TASK C_STARTUP INTNO RESET = 0
    ?C_STARTUP:     LABEL   Model
    
    ...
    
    ?C_RESET        ENDP
    ?C_STARTUP_CODE ENDS
    
    and change it to:
    C_RESET        PROC TASK C_STARTUP INTNO RESET = 0
    PUBLIC C_RESET
    ?C_STARTUP:     LABEL   Model
    
    ...
    
    C_RESET        ENDP
    ?C_STARTUP_CODE ENDS
    
    Now in your C modules you can use the declaration:
    extern void C_RESET(void);
    
    There is an application note on similar subject, but it wasn't of much help here:
    http://www.keil.com/appnotes/docs/apnt_142.asp

    Regards,
    - Mike

  • Cool! Thanks Mike, I'll give that a try

    -Walt

  • I must say, I've never understood the use of ? instead _ in the assy. files. Since ? is an illegal C start char for a label means we can never extern these labels. Most implementations use a leading underscore. I see your fix should work but does it have any other implications?

    - Mark

  • I must say, I've never understood the use of ? instead _ in the assy. files. Since ? is an illegal C start char for a label means we can never extern these labels. Most implementations use a leading underscore. I see your fix should work but does it have any other implications?<br>
    <br>
    - Mark

  • It did it again :-((
    - second try -
    I thought that was the whole idea of using '?': the user should not have access to such sort of things, although it's nice to have it sometimes. A bit more flexibility would not hurt since we are already allowed to edit startup.a66.
    As for unexpected implications, I don't think there are any. ?C_RESET is a local symbol, so no side effects outside startup.a66. None inside also, at least it seems so.

  • As for unexpected implications, I don't think there are any. ?C_RESET is a local symbol, so no side effects outside startup.a66. None inside also, at least it seems so.

    Oh. Okay, then maybe the correct method should be to define a global label in the file for use by C functions that is set equal to the ?C_RESET label?

    - Mark

  • That was my initial idea, but I didn't want to work through the assembler manual to find out how it's done. Defining an independent global label seen by C mudules would be a safer way.