megadrive_test2
annotate src/startup.s @ 4:72ab63f262bf
tiles
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Mon, 19 Jun 2017 08:02:51 +0300 |
parents | b22bc95f0cc0 |
children | 54caa2b214ca |
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@0 | 10 | copy .data section from ROM to RAM |
nuclear@0 | 11 move.l #_data_lma, %a0 |
nuclear@0 | 12 move.l #_data_start, %a1 |
nuclear@0 | 13 move.l #_data_end, %a2 |
nuclear@0 | 14 cmp.l %a1, %a2 |
nuclear@0 | 15 beq.s 1f | skip data copy if the section is empty |
nuclear@0 | 16 0: move.l (%a0)+, (%a1)+ |
nuclear@0 | 17 cmp.l %a1, %a2 |
nuclear@0 | 18 bne.s 0b |
nuclear@0 | 19 1: |
nuclear@0 | 20 |
nuclear@0 | 21 | zero the .bss section |
nuclear@0 | 22 move.l #_bss_start, %a0 |
nuclear@0 | 23 move.l #_bss_end, %a1 |
nuclear@0 | 24 cmp.l %a0, %a1 |
nuclear@0 | 25 beq.s 1f | skip bss zeroing if the section is empty |
nuclear@0 | 26 0: clr.l (%a0)+ |
nuclear@0 | 27 cmp.l %a0, %a1 |
nuclear@0 | 28 bne.s 0b |
nuclear@0 | 29 1: |
nuclear@0 | 30 |
nuclear@0 | 31 | setup the stack pointer stack |
nuclear@0 | 32 move.l #_stacktop, %sp |
nuclear@0 | 33 | now that we have a stack, we can enable interrupts |
nuclear@1 | 34 jsr enable_intr |
nuclear@0 | 35 |
nuclear@0 | 36 jsr main |
nuclear@0 | 37 halt_cpu: |
nuclear@0 | 38 stop #0x2700 |