# Runtime (crt0) By default, when using my link scripts, the standard runtime is initialised by crt0 as follows: | Address | Size | Variable Name |Comment | | ------- | ------- | ------- | ------- | | `0x03fffe` | ~256k | `_STACK_SIZE` |Stack (SSP). Grows towards 0. At round about 0x0000400 it would start stomping all over the memory area used by the monitor | | `0x040000` | n/a | `_RUN_ADDRESS` | Start of user program (.text), followed by initialised data (.data) and then unititialised data (.bss). | You can override the values at link time by using the linker option: ``` --defsym=<Variable Name>=<value> ``` You can use this option as many times as needed. ## Before calling main() ### Banner Message If the code is running in ROM, a banner message will be printed, similar to the following: ``` Mega-680x0 Computer System Code is running in ROM 68030 Processor running at ~40MHz ``` ### Heap All free memory from the end of the .bss area to the end of ram to the heap (malloc/free). ### Global Variables crt0 sets the following global variables: | Variable | Comment | | ------- | ------- | | **uint8_t cpu_speed_mhz**. | This uses the counter in the PI/T to figure out roughly how fast the CPU is being clocked at. Within a MHz or so. | | **uint8_t cpu_type**. | Figures out what CPU is installed: 0 - 68000/68008, 1 - 68010, 2 - 68020, 3 - 68030 | | **uint8_t running_in_rom**. | When non-zero, indicates that the code is running in ROM. 0 indicates it's running in RAM. | To access any of these variables, simply ```#include <machine.h.>``` ### On Exit When `main()` returns or when `exit()` is called, a non-zero exit code will be displayed as follows: ``` exited with status: <value> ``` No message is printed if the exit code was zero. Control will then be passed back to the monitor