summaryrefslogtreecommitdiffstats
path: root/c/src/lib/libbsp/avr/avrtest/start/start.S
blob: 1043ad674cf5779436802eabfe12cc84685a8ddd (plain) (blame)
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#warning Call to boot_card has changed and needs checking.
#warning The call is "void boot_card(const char* cmdline);"
#warning Please check and remove these warnings.

#define SPL 0x3d
#define SPH 0x3e
#define SREG 0x3f
#define RAMPZ 0x3b

#define RAMEND (64 * 1024)

/*
	.weak	__stack
	.set	__stack, RAMEND - 1
*/

	.weak	__heap_end
	.set	__heap_end, 0


	.section .vectors,"ax",@progbits
	.global	__vectors
	.func	__vectors
__vectors:
__reset:
	jmp	__start
	.endfunc	

	.section .init0,"ax",@progbits
	.weak	__start
;	.func	__start
__start:
	
	.section .init2,"ax",@progbits
	clr	r1
	out	0x3f, r1
	ldi	r28,lo8(__stack)
	ldi	r29,hi8(__stack)
	out	SPH, r29
	out	SPL, r28

	/* Only for >64K devices with RAMPZ, replaces the default code
	   provided by libgcc.S which is only linked in if necessary.  */

	.section .init4,"ax",@progbits
	.global __do_copy_data
__do_copy_data:
	.global	__do_clear_bss
__do_clear_bss:
#if 0
	ldi	r17, hi8(__data_end)
	
	ldi	r26, lo8(__data_start)
	ldi	r27, hi8(__data_start)
	
	ldi	r30, lo8(__data_load_start)
	ldi	r31, hi8(__data_load_start)
	ldi	r16, hh8(__data_load_start)
	out	RAMPZ, r16

0:	
	cpi	r26, lo8(__data_end)
	cpc	r27, r17
	breq	1f
	
	elpm	r0, Z+
	st	X+, r0
	rjmp	0b
1:	
#endif

	.section .init9,"ax",@progbits
	call	boot_card
	jmp	exit
;	.endfunc

	.global	exit
	.func	exit
exit:	out 0x2f, r0
	.endfunc

	.global	abort
	.func	abort
abort:	out 0x29, r0
	.endfunc