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

Reply
  • 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.

Children