Set up the target platform in a consistent state. For example
setting up appropriate exception vectors.

Initialize the stack and frame pointers

Invoke the C constructor initialization and ensure destructors
are called on exit.

Carry out any further platform specific initialization.

Call the C main function.

Exit with the return code supplied if the C
main function ever terminates.

The code is invariably assembler, although it may call out to C
functions, and is best illustrated by example from the OpenRISC 1000 . This
is a BSP designed for use with a fast architectural simulator. It
comes in two variants, one providing just standard output to the
console, the other implementing a simulated UART with both
standard input and standard output. The crt0.0
is common to both BSPs and found in crt0.S.