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

Hi,
I am starting studying 8051 uC and want to learn 8051 embedded programming, I have silabs 8051f340dk to use.
Just want to ask this, why I should use startup.asm? I've seen a lot of program did use this startup.asm, the bootloader has one and the firmware also has startup.asm loaded.
I am just a little confused since my very basic program that don't use startup.asm run smoothly.
How does startup.asm affect my firmware if I'm gonna use it?

thanks
gi

Parents
  • A C program uses variables.

    What would happen if your initialization code requires variables that are stored in RAM and not in registers, and you then tries to initialize all your variables? Wouldn't your initialization code then get into serious troubles?

    What would happen if main() tries to call a function called init(), if you don't already have set up a stack, so the processor knows where to store the return address and where to save any registers that should be retained after the call?

    What would happen if main() would try to call malloc() to allocate some memory, if you hadn't already setup any heep for malloc() to carve memory from?

    How would the processor know where main() is located, if you don't have a startup file that hooks the reset vector and somewhere during the startup performs a jump to main()?

    There are a number of reasons for having a startup file. One of them is that the C language standard requires that some things should have already been fixed before you enter main(). Having all global variables having received an initial value is such a language standard requirement.

Reply
  • A C program uses variables.

    What would happen if your initialization code requires variables that are stored in RAM and not in registers, and you then tries to initialize all your variables? Wouldn't your initialization code then get into serious troubles?

    What would happen if main() tries to call a function called init(), if you don't already have set up a stack, so the processor knows where to store the return address and where to save any registers that should be retained after the call?

    What would happen if main() would try to call malloc() to allocate some memory, if you hadn't already setup any heep for malloc() to carve memory from?

    How would the processor know where main() is located, if you don't have a startup file that hooks the reset vector and somewhere during the startup performs a jump to main()?

    There are a number of reasons for having a startup file. One of them is that the C language standard requires that some things should have already been fixed before you enter main(). Having all global variables having received an initial value is such a language standard requirement.

Children