megadrive_test1

annotate src/startup.s @ 7:8253942b0a1a

in the middle of something
author John Tsiombikas <nuclear@member.fsf.org>
date Sun, 19 Feb 2017 14:00:26 +0200
parents 862f8a034cae
children
rev   line source
nuclear@0 1 .text
nuclear@0 2 .extern main
nuclear@0 3
nuclear@0 4 .global start
nuclear@6 5 .global halt_cpu
nuclear@0 6 start:
nuclear@7 7 | copy the string 'SEGA' to appease the TMSS
nuclear@7 8 move.l 100, 0xa14000 | SEGA is always at address 100
nuclear@7 9
nuclear@3 10 | copy .data section from ROM to RAM
nuclear@3 11 move.l #_data_lma, %a0
nuclear@3 12 move.l #_data_start, %a1
nuclear@3 13 move.l #_data_end, %a2
nuclear@3 14 cmp.l %a1, %a2
nuclear@3 15 beq.s 1f | skip data copy if the section is empty
nuclear@3 16 0: move.l (%a0)+, (%a1)+
nuclear@3 17 cmp.l %a1, %a2
nuclear@3 18 bne.s 0b
nuclear@3 19 1:
nuclear@3 20
nuclear@3 21 | zero the .bss section
nuclear@3 22 move.l #_bss_start, %a0
nuclear@3 23 move.l #_bss_end, %a1
nuclear@3 24 cmp.l %a0, %a1
nuclear@3 25 beq.s 1f | skip bss zeroing if the section is empty
nuclear@3 26 0: clr.l (%a0)+
nuclear@3 27 cmp.l %a0, %a1
nuclear@3 28 bne.s 0b
nuclear@3 29 1:
nuclear@7 30
nuclear@7 31 | setup the stack pointer stack
nuclear@7 32 move.l #_stacktop, %sp
nuclear@7 33
nuclear@0 34 jsr main
nuclear@6 35 halt_cpu:
nuclear@0 36 stop #0x2700