megadrive_test2
annotate src/startup.s @ 0:ce1b05082ac4
initial commit
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Tue, 14 Mar 2017 05:59:33 +0200 |
parents | |
children | 2560a8be8cb8 |
rev | line source |
---|---|
nuclear@0 | 1 .text |
nuclear@0 | 2 .extern main |
nuclear@0 | 3 |
nuclear@0 | 4 .global start |
nuclear@0 | 5 .global halt_cpu |
nuclear@0 | 6 start: |
nuclear@0 | 7 bsr.s disable_intr |
nuclear@0 | 8 |
nuclear@0 | 9 | copy .data section from ROM to RAM |
nuclear@0 | 10 move.l #_data_lma, %a0 |
nuclear@0 | 11 move.l #_data_start, %a1 |
nuclear@0 | 12 move.l #_data_end, %a2 |
nuclear@0 | 13 cmp.l %a1, %a2 |
nuclear@0 | 14 beq.s 1f | skip data copy if the section is empty |
nuclear@0 | 15 0: move.l (%a0)+, (%a1)+ |
nuclear@0 | 16 cmp.l %a1, %a2 |
nuclear@0 | 17 bne.s 0b |
nuclear@0 | 18 1: |
nuclear@0 | 19 |
nuclear@0 | 20 | zero the .bss section |
nuclear@0 | 21 move.l #_bss_start, %a0 |
nuclear@0 | 22 move.l #_bss_end, %a1 |
nuclear@0 | 23 cmp.l %a0, %a1 |
nuclear@0 | 24 beq.s 1f | skip bss zeroing if the section is empty |
nuclear@0 | 25 0: clr.l (%a0)+ |
nuclear@0 | 26 cmp.l %a0, %a1 |
nuclear@0 | 27 bne.s 0b |
nuclear@0 | 28 1: |
nuclear@0 | 29 |
nuclear@0 | 30 | setup the stack pointer stack |
nuclear@0 | 31 move.l #_stacktop, %sp |
nuclear@0 | 32 | now that we have a stack, we can enable interrupts |
nuclear@0 | 33 bsr.s enable_intr |
nuclear@0 | 34 |
nuclear@0 | 35 jsr main |
nuclear@0 | 36 halt_cpu: |
nuclear@0 | 37 stop #0x2700 |
nuclear@0 | 38 |
nuclear@0 | 39 .global enable_intr |
nuclear@0 | 40 enable_intr: |
nuclear@0 | 41 andi.w #0xf8ff, %sr |
nuclear@0 | 42 rts |
nuclear@0 | 43 |
nuclear@0 | 44 .global disable_intr |
nuclear@0 | 45 disable_intr: |
nuclear@0 | 46 ori.w #0x0300, %sr |
nuclear@0 | 47 rts |