This is a generic question that equally applies to all versions of SYS/BIOS. I believe I know he answer after debugging an issue but I want to get confirmation from the SYS/BIOS experts.
So a SYS/BIOS program eventually gets to main() and eventually main() calls BIOS_start() which never returns back to main. What surprised me was that any stack variables declared inside of main get clobbered after calling BIOS_start() and the threads take off running. I understand that we have a system stack and interrupts for the most part use the system stack. I was also under the impression that main used the system stack. Calling a function from main normally doesn't impact main()'s stack but apparently when you call BIOS_start(), main()'s stack is lost. It's as if the system stack reuses the same stack storage as main and overwrites anything main had on there.
Can somebody confirm this theory?
The moral of the story is, do not rely on stack variables in main() to persist once BIOS_start() is called.
Thanks