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