Blame

8c1491 Bob Green 2026-06-02 12:30:13
1
# Runtime (crt0)
19a02c Bob Green 2026-06-02 12:15:40
2
3
By default, when using my link scripts, the standard runtime is initialised by crt0 as follows:
4
048596 Bob Green 2026-06-02 12:29:29
5
| Address | Size | Link Script Variable |Comment |
6
| ------- | ------- | ------- | ------- |
7
| `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 |
8
| `0x040000` | n/a | `_RUN_ADDRESS` | Start of user program (.text), followed by initialised data (.data) and then unititialised data (.bss). The .bss area is initialised to all zeroes before main() is called. |
aa3982 Bob Green 2026-06-02 12:27:17
9
10
**Heap**
e7d651 Bob Green 2026-06-02 12:27:24
11
7b8b28 Bob Green 2026-06-02 12:27:49
12
`crt0` allocates all free memory from the end of the .bss area to the end of ram to the heap (malloc/free).
018e16 Bob Green 2026-06-02 12:44:24
13
14
## Global Variables
15
crt0 sets the following global variables:
16
17
**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.
18
19
**uint8_t cpu_type**. Figures out what CPU is installed: 0 - 68000/68008, 1 - 68010, 2 - 68020, 3 - 68030
20
21
**uint8_t running_in_rom**. When non-zero, indicates that the code is running in ROM. 0 indicates it's running in RAM.
22
23
24
To access any of these variables, simply include machine.h.