Last change
on this file since 495 was
444,
checked in by satin@…, 7 years ago
|
add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc
|
File size:
2.1 KB
|
Line | |
---|
1 | # XSTORMY16 startup code |
---|
2 | |
---|
3 | # Interrupt vectors at 0x8000. |
---|
4 | .section .int_vec,"ax" |
---|
5 | .global _start |
---|
6 | .align 1 |
---|
7 | _start: |
---|
8 | ;; Reset, watchdog timer interrupt |
---|
9 | jmpf _int_reset |
---|
10 | ;; base timer interrupt |
---|
11 | jmpf _int_basetimer |
---|
12 | ;; timer 0 |
---|
13 | jmpf _int_timer0 |
---|
14 | ;; timer 1 |
---|
15 | jmpf _int_timer1 |
---|
16 | ;; SIO0 interrupt |
---|
17 | jmpf _int_sio0 |
---|
18 | ;; SIO1 interrupt |
---|
19 | jmpf _int_sio1 |
---|
20 | ;; port0 interrupt |
---|
21 | jmpf _int_port0 |
---|
22 | ;; port1 interrupt |
---|
23 | jmpf _int_port1 |
---|
24 | |
---|
25 | # Reset code, set up memory and call main. |
---|
26 | .section .rodata |
---|
27 | 2: .word __rdata |
---|
28 | .text |
---|
29 | _int_reset: |
---|
30 | ;; Set up the stack pointer. |
---|
31 | mov r0,#__stack |
---|
32 | bz r0,#0,0f |
---|
33 | mov sp,r0 |
---|
34 | 0: |
---|
35 | ;; Zero the data space |
---|
36 | mov r0,#_edata |
---|
37 | mov r1,#_end |
---|
38 | mov r2,#0 |
---|
39 | 0: mov.w (r0++),r2 |
---|
40 | blt r0,r1,0b |
---|
41 | |
---|
42 | ;; Copy data from ROM into RAM. ROM area may be above 64k, |
---|
43 | ;; but RAM may not. |
---|
44 | mov r1,#__data |
---|
45 | mov r3,#_edata |
---|
46 | mov r4,#2b |
---|
47 | mov.w r0,(r4++) |
---|
48 | mov.w r2,(r4) |
---|
49 | mov r8,r2 |
---|
50 | ;; If _data == _rdata there's no need to copy anything. |
---|
51 | bnz r0,r1,0f |
---|
52 | bz r2,#0,1f |
---|
53 | 0: movf.w r2,(r0++) |
---|
54 | bnz r0,#0,2f |
---|
55 | add r8,#1 |
---|
56 | 2: mov.w (r1++),r2 |
---|
57 | blt r1,r3,0b |
---|
58 | 1: |
---|
59 | ;; Call hardware init routine |
---|
60 | callf _hwinit |
---|
61 | ;; Call initialization routines |
---|
62 | callf _init |
---|
63 | ;; Set up fini routines to be called from exit |
---|
64 | mov r2,#@fptr(_fini) |
---|
65 | callf atexit |
---|
66 | ;; Call main() with empty argc/argv/envp |
---|
67 | mov r2,#0 |
---|
68 | mov r3,#0 |
---|
69 | mov r4,#0 |
---|
70 | callf main |
---|
71 | ;; Exit. |
---|
72 | callf exit |
---|
73 | ;; Should never reach this code. |
---|
74 | halt |
---|
75 | 1: .size _int_reset,1b-_int_reset |
---|
76 | |
---|
77 | # Stub interrupt routines. |
---|
78 | .globl _int_timer0 |
---|
79 | .weak _int_timer0 |
---|
80 | .globl _int_timer1 |
---|
81 | .weak _int_timer1 |
---|
82 | .globl _int_sio0 |
---|
83 | .weak _int_sio0 |
---|
84 | .globl _int_sio1 |
---|
85 | .weak _int_sio1 |
---|
86 | .globl _int_port0 |
---|
87 | .weak _int_port0 |
---|
88 | .globl _int_port1 |
---|
89 | .weak _int_port1 |
---|
90 | .globl _int_basetimer |
---|
91 | .weak _int_basetimer |
---|
92 | _int_timer0: |
---|
93 | _int_timer1: |
---|
94 | _int_sio0: |
---|
95 | _int_sio1: |
---|
96 | _int_port0: |
---|
97 | _int_port1: |
---|
98 | _int_basetimer: |
---|
99 | iret |
---|
100 | 1: .size _int_timer0,1b-_int_timer0 |
---|
101 | |
---|
102 | # Stub hardware init |
---|
103 | .globl _hwinit |
---|
104 | .weak _hwinit |
---|
105 | _hwinit: |
---|
106 | ret |
---|
107 | 1: .size _hwinit,1b-_hwinit |
---|
108 | |
---|
109 | # The first word in .data has address 0, so it's not a good |
---|
110 | # idea to use it as its address conflicts with NULL. |
---|
111 | # Place a HALT instruction there to try to catch NULL pointer |
---|
112 | # dereferences. |
---|
113 | .data |
---|
114 | halt |
---|
Note: See
TracBrowser
for help on using the repository browser.