April 9th, 2012, 11:15 PM
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!
April 10th, 2012, 10:34 PM
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.