megadrive_test2
annotate src/startup.s @ 12:54caa2b214ca
TMSS code
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Wed, 26 Dec 2018 04:39:09 +0200 |
parents | 72ab63f262bf |
children |
rev | line source |
---|---|
nuclear@4 | 1 | vi:filetype=gas68k: |
nuclear@0 | 2 .text |
nuclear@0 | 3 .extern main |
nuclear@0 | 4 |
nuclear@0 | 5 .global start |
nuclear@0 | 6 .global halt_cpu |
nuclear@0 | 7 start: |
nuclear@1 | 8 jsr disable_intr |
nuclear@0 | 9 |
nuclear@12 | 10 | write SEGA to 0xa14000 to convience the TMSS to run us |
nuclear@12 | 11 move.l 0x100, %d0 |
nuclear@12 | 12 move.l %d0, 0xa14000 |
nuclear@12 | 13 |
nuclear@0 | 14 | copy .data section from ROM to RAM |
nuclear@0 | 15 move.l #_data_lma, %a0 |
nuclear@0 | 16 move.l #_data_start, %a1 |
nuclear@0 | 17 move.l #_data_end, %a2 |
nuclear@0 | 18 cmp.l %a1, %a2 |
nuclear@0 | 19 beq.s 1f | skip data copy if the section is empty |
nuclear@0 | 20 0: move.l (%a0)+, (%a1)+ |
nuclear@0 | 21 cmp.l %a1, %a2 |
nuclear@0 | 22 bne.s 0b |
nuclear@0 | 23 1: |
nuclear@0 | 24 |
nuclear@0 | 25 | zero the .bss section |
nuclear@0 | 26 move.l #_bss_start, %a0 |
nuclear@0 | 27 move.l #_bss_end, %a1 |
nuclear@0 | 28 cmp.l %a0, %a1 |
nuclear@0 | 29 beq.s 1f | skip bss zeroing if the section is empty |
nuclear@0 | 30 0: clr.l (%a0)+ |
nuclear@0 | 31 cmp.l %a0, %a1 |
nuclear@0 | 32 bne.s 0b |
nuclear@0 | 33 1: |
nuclear@0 | 34 |
nuclear@0 | 35 | setup the stack pointer stack |
nuclear@0 | 36 move.l #_stacktop, %sp |
nuclear@0 | 37 | now that we have a stack, we can enable interrupts |
nuclear@1 | 38 jsr enable_intr |
nuclear@0 | 39 |
nuclear@0 | 40 jsr main |
nuclear@0 | 41 halt_cpu: |
nuclear@0 | 42 stop #0x2700 |