MRM_CRT0
- define .data
- define __unhandled_exception et al.
- define .text
- set things up so the application will run. This *must* be called start
- if the user provided us with flags (symbol name 'crt0_flags') for the startup code, load them now. If not, use defaults.
- if user provided an initialization list, process it now this is typically used to set up hardware that is critical to system operation,
for example chip selects, watchdog timers, etc.
- See if user supplied their own stack (__stack != 0). If not, then leave it as set by the ROM monitor/exception vector. [note: stack is provided]
- if the user provided a hardware init function, call it now. this is done first so that hardware is all set up for the rest of crt0 [NOTE: no hook provided]
- If bit 0 of crt0_flags is set, then do a jump to the init routine with the return address in D0; otherwise do a normal jsr. [NOTE: bit not set]
- If bit 1 of crt0_flags is clear, then zero out the bss section. [NOTE: bit IS clear]
- copy .data image, if there is one, from ROM to RAM.
- if ADD_DTORS defined then put __do_global_dtors in the atexit list so the destructors get run.
- call the main routine from the application to get it going. applications executes, and terminates somehow
- drop down into exit incase the user doesn't. This should drop control back to the ROM monitor, if there is one. This calls the
exit() from the C library so the C++ tables get cleaned up properly.
- Lastly, we define a default handler for exceptions not otherwise handled in the application code.