cancel
Showing results for 
Search instead for 
Did you mean: 

__main in startup assembly

Francesco Sfragara
Associate
Posted on June 04, 2018 at 10:30

Hi.

I'm using keil for programming a stm32 board. In the start up file .s there is a call to __main after the call to SystemInit. Where is the definition of __main? What's the difference between main and __main?
1 ACCEPTED SOLUTION

Accepted Solutions
Nesrine M_O
Lead II
Posted on June 04, 2018 at 10:37

Hi

IMPORT __main�?

This line refers to the __main in the C library which eventually calls the main() function defined elsewhere in your project.

-Nesrine-

View solution in original post

3 REPLIES 3
Nesrine M_O
Lead II
Posted on June 04, 2018 at 10:37

Hi

IMPORT __main�?

This line refers to the __main in the C library which eventually calls the main() function defined elsewhere in your project.

-Nesrine-

Artur IWANICKI
ST Employee
Posted on June 04, 2018 at 10:40

Hello,

main is your main procedure form main.c file, once __main is an internal procedure created by Keil toolchain which is calling at the end your main, but before it is initializing all variables (copying variables from FLASH to proper positions in RAM). In gcc it is seen explicitly, in Keil you can see it within debug process.

Best Regards,

Artur

Francesco Sfragara
Associate
Posted on June 04, 2018 at 11:47

Thank you