Welcome to mirror list, hosted at ThFree Co, Russian Federation.

crt0.S « mcore « libgloss - cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: cea4370191b65c2a31dd70c23739e37d0ca644cc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// MCore StartUp Code.

	.import	main
	.import	exit

	.text
	.export	_start
_start:
	.export	_mainCRTStartup
_mainCRTStartup:
	// Initialise the stack pointer
	lrw	r1, _stack
	mov	r0, r1

	// Zero the .bss data space
	lrw     r1, __bss_start__
	lrw     r2, __bss_end__
	movi	r3, 0
.L0:	
	st	r3, (r1, 0)
	addi	r1, 4
	cmphs	r1, r2
	bf      .L0
#ifdef __ELF__
	// Call the global/static constructors
	jbsr    _init

	// Setup destructors to be called from exit,
	// just in case main never returns...
	lrw     r2, _fini
	jbsr    atexit
#endif
	
	// Initialise the parameters to main()
	movi 	r2, 0	// argc 
	movi	r3, 0	// argv
	movi	r4, 0	// envp

	// Call main
	jbsr	main

	// Call exit
	movi	r2, 0
	jbsr	exit

	// We should never reach here.
	bkpt