PulkoMandy | 355605a | 2014-06-28 23:20:12 +0200 | [diff] [blame] | 1 | ;; File: crt0-prg.s |
kthacker | 62e146c | 2006-04-17 15:11:35 +0000 | [diff] [blame] | 2 | |
| 3 | .module crt0 |
| 4 | .area _HEADER (ABS) |
| 5 | .area _HOME (REL) |
| 6 | .area _CODE (REL) |
PulkoMandy | 91577e1 | 2014-06-29 10:38:36 +0200 | [diff] [blame^] | 7 | .dw 0 ; Will be replaced with the address of the reloc. table by the linker. |
| 8 | .area _INITIALIZER (REL) |
| 9 | izr:: |
PulkoMandy | 355605a | 2014-06-28 23:20:12 +0200 | [diff] [blame] | 10 | .area _GSINIT (REL) |
| 11 | .area _GSFINAL (REL) |
PulkoMandy | 91577e1 | 2014-06-29 10:38:36 +0200 | [diff] [blame^] | 12 | ;; relocation data will be inserted here. It is used at loading time, |
| 13 | ; then overriden by the initialization of the data area below. |
PulkoMandy | 355605a | 2014-06-28 23:20:12 +0200 | [diff] [blame] | 14 | |
PulkoMandy | 91577e1 | 2014-06-29 10:38:36 +0200 | [diff] [blame^] | 15 | .area _INITIALIZED (REL) |
| 16 | izd:: |
PulkoMandy | 355605a | 2014-06-28 23:20:12 +0200 | [diff] [blame] | 17 | .area _DATA (REL) |
PulkoMandy | 91577e1 | 2014-06-29 10:38:36 +0200 | [diff] [blame^] | 18 | dat:: |
PulkoMandy | 355605a | 2014-06-28 23:20:12 +0200 | [diff] [blame] | 19 | .area _BSEG |
kthacker | 62e146c | 2006-04-17 15:11:35 +0000 | [diff] [blame] | 20 | .area _BSS (REL) |
| 21 | .area _HEAP (REL) |
| 22 | |
| 23 | .area _GSINIT (REL) |
| 24 | gsinit:: |
PulkoMandy | 355605a | 2014-06-28 23:20:12 +0200 | [diff] [blame] | 25 | ld bc, #l__INITIALIZER |
| 26 | ld a, b |
| 27 | or a, c |
| 28 | jr Z, gsinit_next |
PulkoMandy | 91577e1 | 2014-06-29 10:38:36 +0200 | [diff] [blame^] | 29 | ld hl, #izr |
| 30 | ld de, #izd |
PulkoMandy | 355605a | 2014-06-28 23:20:12 +0200 | [diff] [blame] | 31 | ldir |
| 32 | gsinit_next: |
| 33 | ; Clear BSS sections |
PulkoMandy | 91577e1 | 2014-06-29 10:38:36 +0200 | [diff] [blame^] | 34 | ld hl,#dat |
PulkoMandy | 355605a | 2014-06-28 23:20:12 +0200 | [diff] [blame] | 35 | ld (hl),#0 |
PulkoMandy | 91577e1 | 2014-06-29 10:38:36 +0200 | [diff] [blame^] | 36 | ld de,#dat |
PulkoMandy | 355605a | 2014-06-28 23:20:12 +0200 | [diff] [blame] | 37 | inc de |
| 38 | ld bc,#l__DATA |
| 39 | ldir |
| 40 | |
| 41 | |
kthacker | 62e146c | 2006-04-17 15:11:35 +0000 | [diff] [blame] | 42 | .area _GSFINAL (REL) |
| 43 | ret |