Thread: Startup Code

    #1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2012
    Posts
    21
    Rep Power
    0

    Startup Code


    Well, the last time I touched assembly was when I was in college and just a little for a 8086 processor as far as I remember..

    Anyway, many years later I have been asked to touch again assembly code for a SuperH processor.

    I ve reading books to refresh my assembly and to understand the code that I have been handed and all is fine but I have a question on startup codes. In other words what happens when I turn on the processor?

    That is something that in all my years programming I have never even thought about...I always assumed everything started at the main() function!

    Then I received a code in C and assembly that doesnt even have a main function!

    In the books I am reading they talk about memory, exceptions, devices etc, but they barely mention this

    what happens when I turn on the processor?

    Michael Barr in his book "Programmin Embedded Systems in C++" mentions that (pag 62) you go from reset: to hw_init: (hardware initialization) to startup and then to main()

    Do any of you guys have a good resource, or examples in which I can learn about this?

    Sorry for the long post , your help will be appreciated!
  2. #2
  3. No Profile Picture
    Lost in code
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 2004
    Posts
    8,317
    Rep Power
    7170
    When you turn on the processor it begins executing code from a memory location that's permanently built into the hardware. Generally this memory location is ROM containing a BIOS, but I don't know anything specifically about the SuperH processor; it might just start executing from the first block of program memory.

    If you just received a chunk of assembly code it's likely that the code starts executing at the beginning. The main() method only has significance because when the C compiler is compiling your C code it puts the code from the main() method into the memory location that is executed first.

    Depending on what compiler you're using, it's possible that they have a different name for the "main" method. Or perhaps the assembly code you received is where the program starts and the C files are just used by that assembly code.
    PHP FAQ

    Originally Posted by Spad
    Ah USB, the only rectangular connector where you have to make 3 attempts before you get it the right way around

IMN logo majestic logo threadwatch logo seochat tools logo