Search
lxdream.org :: lxdream/test/lib/crt0.s
lxdream 0.9.1
released Jun 29
Download Now
filename test/lib/crt0.s
changeset 812:8cc61d5ea1f8
next976:e57a25d9eb7d
author nkeynes
date Thu Jan 15 07:21:34 2009 +0000 (15 years ago)
permissions -rw-r--r--
last change Add missed paths_osx.m from previous commit
file annotate diff log raw
nkeynes@812
     1
	.section .text
nkeynes@812
     2
	.global	start
nkeynes@812
     3
	.global ___exit
nkeynes@812
     4
	.global _atexit
nkeynes@812
     5
start:
nkeynes@812
     6
	mov.l	setup_cache_k,r0
nkeynes@812
     7
	mov.l	p2_mask,r1
nkeynes@812
     8
	or	r1,r0
nkeynes@812
     9
	jmp	@r0
nkeynes@812
    10
	nop
nkeynes@812
    11
setup_cache:
nkeynes@812
    12
	mov.l	ccr_addr,r0
nkeynes@812
    13
	mov.w	ccr_data,r1
nkeynes@812
    14
	mov.l	r1,@r0
nkeynes@812
    15
	mov.l	start_2_k,r0	
nkeynes@812
    16
	nop
nkeynes@812
    17
	nop
nkeynes@812
    18
	nop
nkeynes@812
    19
	nop
nkeynes@812
    20
	nop
nkeynes@812
    21
	nop
nkeynes@812
    22
	nop
nkeynes@812
    23
	jmp	@r0	
nkeynes@812
    24
	nop
nkeynes@812
    25
start_2:		
nkeynes@812
    26
	mov.l	old_stack_k,r14
nkeynes@812
    27
	mov.l	r15,@r14
nkeynes@812
    28
	mov.l	old_pr_k,r14
nkeynes@812
    29
	sts	pr,r15
nkeynes@812
    30
	mov.l	r15,@r14
nkeynes@812
    31
	mov.l	stack_k,r15
nkeynes@812
    32
nkeynes@812
    33
	! zero out bss
nkeynes@812
    34
	mov.l	edata_k,r0
nkeynes@812
    35
	mov.l	end_k,r1
nkeynes@812
    36
	mov	#0,r2
nkeynes@812
    37
start_l:
nkeynes@812
    38
	mov.l	r2,@r0
nkeynes@812
    39
	add	#4,r0
nkeynes@812
    40
	cmp/ge	r0,r1
nkeynes@812
    41
	bt	start_l
nkeynes@812
    42
nkeynes@812
    43
#if defined (__SH3E__) || defined(__SH4_SINGLE__) || defined(__SH4__) || defined(__SH4_SINGLE_ONLY)
nkeynes@812
    44
	mov.l set_fpscr_k, r1
nkeynes@812
    45
	jsr @r1
nkeynes@812
    46
	mov #0,r4
nkeynes@812
    47
	lds r3,fpscr
nkeynes@812
    48
#endif /*  defined (__SH3E__) || defined(__SH4_SINGLE__) || defined(__SH4__) || defined(__SH4_SINGLE_ONLY__) */
nkeynes@812
    49
nkeynes@812
    50
	! call the mainline	
nkeynes@812
    51
	mov.l	main_k,r0
nkeynes@812
    52
	jsr	@r0
nkeynes@812
    53
	or	r0,r0
nkeynes@812
    54
nkeynes@812
    55
	! call exit
nkeynes@812
    56
	mov	r0,r4
nkeynes@812
    57
	mov.l	exit_k,r0
nkeynes@812
    58
	jsr	@r0
nkeynes@812
    59
	or	r0,r0
nkeynes@812
    60
nkeynes@812
    61
___exit:
nkeynes@812
    62
	mov.l	old_pr_k,r14
nkeynes@812
    63
	mov.l	@r14,r15	
nkeynes@812
    64
	lds	r15,pr
nkeynes@812
    65
	mov.l	old_stack_k,r14
nkeynes@812
    66
	mov.l	@r14,r15	
nkeynes@812
    67
	rts
nkeynes@812
    68
	nop
nkeynes@812
    69
nkeynes@812
    70
_atexit:
nkeynes@812
    71
	rts
nkeynes@812
    72
	nop
nkeynes@812
    73
		
nkeynes@812
    74
	.align 4
nkeynes@812
    75
#if defined (__SH3E__) || defined(__SH4_SINGLE__) || defined(__SH4__) || defined(__SH4_SINGLE_ONLY__)
nkeynes@812
    76
set_fpscr_k:
nkeynes@812
    77
	.long	___set_fpscr
nkeynes@812
    78
#endif /*  defined (__SH3E__) || defined(__SH4_SINGLE__) || defined(__SH4__) || defined(SH4_SINGLE_ONLY) */
nkeynes@812
    79
stack_k:
nkeynes@812
    80
	.long	_stack	
nkeynes@812
    81
edata_k:
nkeynes@812
    82
	.long	_edata
nkeynes@812
    83
end_k:
nkeynes@812
    84
	.long	_end
nkeynes@812
    85
main_k:
nkeynes@812
    86
	.long	_main
nkeynes@812
    87
exit_k:
nkeynes@812
    88
	.long	_exit
nkeynes@812
    89
nkeynes@812
    90
old_stack_k:
nkeynes@812
    91
	.long	_old_stack
nkeynes@812
    92
old_pr_k:
nkeynes@812
    93
	.long	_old_pr
nkeynes@812
    94
nkeynes@812
    95
_old_stack:
nkeynes@812
    96
	.long	0
nkeynes@812
    97
_old_pr:
nkeynes@812
    98
	.long	0
nkeynes@812
    99
nkeynes@812
   100
setup_cache_k:
nkeynes@812
   101
	.long	setup_cache
nkeynes@812
   102
start_2_k:	
nkeynes@812
   103
	.long	start_2	
nkeynes@812
   104
p2_mask:
nkeynes@812
   105
	.long	0xa0000000
nkeynes@812
   106
ccr_addr:
nkeynes@812
   107
	.long	0xff00001c
nkeynes@812
   108
ccr_data:
nkeynes@812
   109
	.word	0x090b
nkeynes@812
   110
nkeynes@812
   111
	.align 4
nkeynes@812
   112
		
nkeynes@812
   113
#ifdef __ELF__
nkeynes@812
   114
	.section .stack,"aw"
nkeynes@812
   115
#else
nkeynes@812
   116
	.section .stack
nkeynes@812
   117
#endif
nkeynes@812
   118
! _stack:	.long	0xdeaddead
nkeynes@812
   119
.