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.a51

Is it always important to include the file "startup.a51"?

Should anything else be included for it to work properly?

Thanks

Parents Reply Children
  • Is there some detailed explanation of startup.a51?

    WHY?. I used Keil for years and hardly knew it existed. Do you have a SPECIFIC reason for your inquiry?

    Erik

  • *Does this mean that iit is not important to use startup.a51?

    If so, then in what cases should it be used?

    *Or does it mean that it is not important to know its details?


    thanks

  • Hi Mohammad,

    I always include startup.a51 in my project. The reasons are:
    1. I am using winbond 78E516, and it has an AUX-RAM on the chip. I have to modify the startup.a51 to init this memory area.
    2. I want to have a full control of my source code. Even if I don't have to change the startup.a51, I'd prefer to have it included in my project, then I can step through the code before it jump to main. It's useful especially when you have a hardware problem (I mean bad mem W/R).

    As to the detail explaination, I think you can read the source code of startup.a51, It's kind of self-explained to me.

    Have a nice day!
    Frank

  • 1)Does this mean that iit is not important to use startup.a51?
    2)Or does it mean that it is not important to know its details?

    1) it is not "important" it is REQUIRED if you have any C code.
    2) I did not know the details for years, never looked.

    Erik

  • Thanks Frank..
    The problem with the file is that i am not that good at assembly.

    I can understand the codes that clear memory, but other parts seem rather ambigous

  • I can understand the codes that clear memory, but other parts seem rather ambigous

    As a public service, here are the parts of the standard Keil-supplied STARTUP.A51 that do not involve clearing memory.

                    CSEG    AT      0
    ?C_STARTUP:     LJMP    STARTUP1
    

    The 8051 always begins execution at address 0, which is also the beginning of the interrupt vector table. This code makes the startup vector jump to the startup code located at STARTUP1.

    (Much memory initialization deleted...)

                    MOV     SP,#?STACK-1
    

    This code initializes the stack pointer to point at the stack segment defined to hold the stack.

    ; This code is required if you use L51_BANK.A51 with Banking Mode 4
    ; EXTRN CODE (?B_SWITCH0)
    ;               CALL    ?B_SWITCH0      ; init bank mechanism to code bank 0
    

    This code is required if you use L51_BANK with banking mode 4 to do bank switching. It initializes the bank switching mechanism to start off in bank 0. If you're not doing this, leave the call commented out.

                    LJMP    ?C_START
    

    This code jumps to the start of your C code -- that is, main().

                    END
    

    And that's it. Not much in there at all.

    You'll often want to modify STARTUP.A51 when you have an 8051 variant with nifty optional features like built-in memories or banking or peripherals that require some initialization of chip-specific registers.

  •                 LJMP    ?C_START
    This code jumps to the start of your C code -- that is, main().

    Not quite.

    C_START is the start of Keil's 'C' runtime startup: this includes, among other things, the code to setup all the values of initialised variables.
    Once this code has completed, it then jumps to main().

    As someone else mentioned earlier, you can step through all this if you want...