aboutsummaryrefslogtreecommitdiff
path: root/libgloss/fr30/crt0.s
blob: e83a308497d26c812ba519a4e234fe9c6ec4ccc1 (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
# FR30 startup code

	.section .text
	.global	_start
_start:
	
	;; Initialise the stack pointer
	ldi:32	__stack, r0
	mov	r0, sp
	mov	r0, fp

	;; Zero the data space
	ldi:32	#_edata, r0
	ldi:32	#_end,   r1
	ldi:8	#0,	 r2
.L0:	
	st	r2, @r0
	add	#4, r0
	cmp	r1, r0
	blt	.L0

	;; Call global and static constructors
	ldi:32	_init, r0
	call	@r0
	
	;;  Setup destrcutors to be called from exit.
	;;  (Just in case main never returns....)
	ldi:32	atexit, r0
	ldi:32	_fini, r4
	call	@r0
	
	;;  Initialise argc, argv and envp to empty
	ldi:8	#0, r4
	ldi:8	#0, r5
	ldi:8	#0, r6

	;; Call main
	ldi:32	main, r0
	call	@r0

	;; Jump to exit
	ldi:32	exit, r0
	call	@r0

	;; Should never reach here
	int	#9