initial commit
[megatris] / src / startup.s
1 | vi:filetype=gas68k:
2         .text
3         .extern main
4
5         .global start
6         .global halt_cpu
7 start:
8         jsr disable_intr
9
10         | write SEGA to 0xa14000 to convience the TMSS to run us
11         move.l 0x100, %d0
12         move.l %d0, 0xa14000
13
14         | copy .data section from ROM to RAM
15         move.l #_data_lma, %a0
16         move.l #_data_start, %a1
17         move.l #_data_end, %a2
18         cmp.l %a1, %a2
19         beq.s 1f        | skip data copy if the section is empty
20 0:      move.l (%a0)+, (%a1)+
21         cmp.l %a1, %a2
22         bne.s 0b
23 1:
24
25         | zero the .bss section
26         move.l #_bss_start, %a0
27         move.l #_bss_end, %a1
28         cmp.l %a0, %a1
29         beq.s 1f        | skip bss zeroing if the section is empty
30 0:      clr.l (%a0)+
31         cmp.l %a0, %a1
32         bne.s 0b
33 1:
34
35         | setup the stack pointer stack
36         move.l #_stacktop, %sp
37         | now that we have a stack, we can enable interrupts
38         jsr enable_intr
39
40         jsr main
41 halt_cpu:
42         stop #0x2700