OpenCores
URL https://opencores.org/ocsvn/eco32/eco32/trunk

Subversion Repositories eco32

[/] [eco32/] [trunk/] [stdalone/] [wrtmbr/] [start.s] - Blame information for rev 75

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 18 hellwig
;
2
; start.s -- startup code
3
;
4
 
5
        .import main
6
        .import _ecode
7
        .import _edata
8
        .import _ebss
9
 
10
        .export _bcode
11
        .export _bdata
12
        .export _bbss
13
 
14
        .export enable
15
        .export disable
16
        .export getISR
17
        .export setISR
18
 
19
        .code
20
_bcode:
21
 
22
        .data
23
_bdata:
24
 
25
        .bss
26
_bbss:
27
 
28
        .code
29
 
30
        ; reset arrives here
31
reset:
32
        j       start
33
 
34
        ; interrupts arrive here
35
intrpt:
36
        j       isr
37
 
38
        ; user TLB misses arrive here
39
userMiss:
40
        j       userMiss
41
 
42
isr:
43
        add     $26,$29,$0       ; sp -> $26
44
        add     $27,$1,$0        ; $1 -> $27
45
        add     $29,$0,istack    ; set stack
46
        sub     $29,$29,108
47
        stw     $2,$29,0 ; save registers
48
        stw     $3,$29,4
49
        stw     $4,$29,8
50
        stw     $5,$29,12
51
        stw     $6,$29,16
52
        stw     $7,$29,20
53
        stw     $8,$29,24
54
        stw     $9,$29,28
55
        stw     $10,$29,32
56
        stw     $11,$29,36
57
        stw     $12,$29,40
58
        stw     $13,$29,44
59
        stw     $14,$29,48
60
        stw     $15,$29,52
61
        stw     $16,$29,56
62
        stw     $17,$29,60
63
        stw     $18,$29,64
64
        stw     $19,$29,68
65
        stw     $20,$29,72
66
        stw     $21,$29,76
67
        stw     $22,$29,80
68
        stw     $23,$29,84
69
        stw     $24,$29,88
70
        stw     $25,$29,92
71
        stw     $26,$29,96
72
        stw     $27,$29,100
73
        stw     $31,$29,104
74
        mvfs    $4,0             ; $4 = IRQ number
75
        slr     $4,$4,16
76
        and     $4,$4,0x1F
77
        sll     $26,$4,2        ; $26 = 4 * IRQ number
78
        ldw     $26,$26,irqsrv  ; get addr of service routine
79
        jalr    $26             ; call service routine
80
        beq     $2,$0,resume     ; resume instruction if ISR returned 0
81
        add     $30,$30,4       ; else skip offending instruction
82
resume:
83
        ldw     $2,$29,0
84
        ldw     $3,$29,4
85
        ldw     $4,$29,8
86
        ldw     $5,$29,12
87
        ldw     $6,$29,16
88
        ldw     $7,$29,20
89
        ldw     $8,$29,24
90
        ldw     $9,$29,28
91
        ldw     $10,$29,32
92
        ldw     $11,$29,36
93
        ldw     $12,$29,40
94
        ldw     $13,$29,44
95
        ldw     $14,$29,48
96
        ldw     $15,$29,52
97
        ldw     $16,$29,56
98
        ldw     $17,$29,60
99
        ldw     $18,$29,64
100
        ldw     $19,$29,68
101
        ldw     $20,$29,72
102
        ldw     $21,$29,76
103
        ldw     $22,$29,80
104
        ldw     $23,$29,84
105
        ldw     $24,$29,88
106
        ldw     $25,$29,92
107
        ldw     $26,$29,96
108
        ldw     $27,$29,100
109
        ldw     $31,$29,104
110
        add     $1,$27,$0        ; $27 -> $1
111
        add     $29,$26,0        ; $26 -> sp
112
        rfx                     ; return from exception
113
 
114
start:
115
        mvfs    $8,0
116
        or      $8,$8,1 << 27   ; let vector point to RAM
117
        mvts    $8,0
118
        add     $29,$0,stack     ; set sp
119
        add     $10,$0,_bdata    ; copy data segment
120
        add     $8,$0,_edata
121
        sub     $9,$8,$10
122
        add     $9,$9,_ecode
123
        j       cpytest
124
cpyloop:
125
        ldw     $11,$9,0
126
        stw     $11,$8,0
127
cpytest:
128
        sub     $8,$8,4
129
        sub     $9,$9,4
130
        bgeu    $8,$10,cpyloop
131
        add     $8,$0,_bbss      ; clear bss
132
        add     $9,$0,_ebss
133
        j       clrtest
134
clrloop:
135
        stw     $0,$8,0
136
        add     $8,$8,4
137
clrtest:
138
        bltu    $8,$9,clrloop
139
        jal     main            ; call 'main'
140
start1:
141
        j       start1          ; loop
142
 
143
enable:
144
        mvfs    $8,0
145
        or      $8,$8,1 << 23
146
        mvts    $8,0
147
        jr      $31
148
 
149
disable:
150
        mvfs    $8,0
151
        and     $8,$8,~(1 << 23)
152
        mvts    $8,0
153
        jr      $31
154
 
155
getISR:
156
        sll     $4,$4,2
157
        ldw     $2,$4,irqsrv
158
        jr      $31
159
 
160
setISR:
161
        sll     $4,$4,2
162
        stw     $5,$4,irqsrv
163
        jr      $31
164
 
165
        .data
166
 
167
; interrupt service routine table
168
 
169
        .align  4
170
 
171
irqsrv:
172
        .word   0                ; 00: terminal 0 transmitter interrupt
173
        .word   0                ; 01: terminal 0 receiver interrupt
174
        .word   0                ; 02: terminal 1 transmitter interrupt
175
        .word   0                ; 03: terminal 1 receiver interrupt
176
        .word   0                ; 04: keyboard interrupt
177
        .word   0                ; 05: unused
178
        .word   0                ; 06: unused
179
        .word   0                ; 07: unused
180
        .word   0                ; 08: disk interrupt
181
        .word   0                ; 09: unused
182
        .word   0                ; 10: unused
183
        .word   0                ; 11: unused
184
        .word   0                ; 12: unused
185
        .word   0                ; 13: unused
186 38 hellwig
        .word   0                ; 14: timer 0 interrupt
187
        .word   0                ; 15: timer 1 interrupt
188 18 hellwig
        .word   0                ; 16: bus timeout exception
189
        .word   0                ; 17: illegal instruction exception
190
        .word   0                ; 18: privileged instruction exception
191
        .word   0                ; 19: divide instruction exception
192
        .word   0                ; 20: trap instruction exception
193
        .word   0                ; 21: TLB miss exception
194
        .word   0                ; 22: TLB write exception
195
        .word   0                ; 23: TLB invalid exception
196
        .word   0                ; 24: illegal address exception
197
        .word   0                ; 25: privileged address exception
198
        .word   0                ; 26: unused
199
        .word   0                ; 27: unused
200
        .word   0                ; 28: unused
201
        .word   0                ; 29: unused
202
        .word   0                ; 30: unused
203
        .word   0                ; 31: unused
204
 
205
        .bss
206
 
207
        .align  4
208
        .space  0x800
209
stack:
210
 
211
        .align  4
212
        .space  0x800
213
istack:

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.