megadrive_test1

diff src/startup.s @ 3:54739a11be66

- .data copy and .bss clearing - also made sure .data and .bss start and end markers are dword-aligned to make sure I can copy 4bytes at a time
author John Tsiombikas <nuclear@member.fsf.org>
date Tue, 31 Jan 2017 07:11:17 +0200
parents 909c22dc18d2
children 862f8a034cae
line diff
     1.1 --- a/src/startup.s	Mon Jan 30 16:57:51 2017 +0200
     1.2 +++ b/src/startup.s	Tue Jan 31 07:11:17 2017 +0200
     1.3 @@ -1,8 +1,27 @@
     1.4 -| TODO: copy .data and zero .bss
     1.5  	.text
     1.6  	.extern main
     1.7  
     1.8  	.global start
     1.9  start:
    1.10 +	| copy .data section from ROM to RAM
    1.11 +	move.l #_data_lma, %a0
    1.12 +	move.l #_data_start, %a1
    1.13 +	move.l #_data_end, %a2
    1.14 +	cmp.l %a1, %a2
    1.15 +	beq.s 1f	| skip data copy if the section is empty
    1.16 +0:	move.l (%a0)+, (%a1)+
    1.17 +	cmp.l %a1, %a2
    1.18 +	bne.s 0b
    1.19 +1:
    1.20 +
    1.21 +	| zero the .bss section
    1.22 +	move.l #_bss_start, %a0
    1.23 +	move.l #_bss_end, %a1
    1.24 +	cmp.l %a0, %a1
    1.25 +	beq.s 1f	| skip bss zeroing if the section is empty
    1.26 +0:	clr.l (%a0)+
    1.27 +	cmp.l %a0, %a1
    1.28 +	bne.s 0b
    1.29 +1:
    1.30  	jsr main
    1.31  	stop #0x2700