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

Subversion Repositories eco32

[/] [eco32/] [trunk/] [binutils/] [tests-2/] [intrpt/] [intrpt.s] - Blame information for rev 275

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

Line No. Rev Author Line
1 7 hellwig
;
2
; intrpt.s -- a first attempt to utilize interrupts
3
;
4
 
5
        .set    stack,0xC0010000        ; stack
6
        .set    timerbase,0xF0000000    ; timer base address
7
        .set    termbase,0xF0300000     ; terminal base address
8
 
9
reset:
10
        j       start           ; reset arrives here
11
 
12
intrpt:
13
        j       isr             ; interrupts arrive here
14
 
15
userMiss:
16
        j       userMiss        ; user TLB miss exceptions arrive here
17
 
18
isr:
19
        mvfs    $26,0            ; determine cause
20
        slr     $26,$26,14      ; $26 = 4 * IRQ number
21
        and     $26,$26,0x1F << 2
22
        ldw     $26,$26,irqsrv  ; get addr of service routine
23
        jr      $26             ; jump to service routine
24
 
25
start:
26
        add     $29,$0,stack     ; set sp
27
        add     $4,$0,runmsg     ; pointer to string
28
        jal     msg             ; show string
29
        add     $8,$0,timerbase  ; program timer
30
        add     $9,$0,1000       ; divisor = 1000
31
        stw     $9,$8,4
32
        add     $9,$0,2          ; enable timer interrupts
33
        stw     $9,$8,0
34
        mvfs    $8,0
35
        or      $8,$8,1 << 14   ; open timer IRQ mask bit
36
        or      $8,$8,1 << 23   ; enable processor interrupts
37
        or      $8,$8,1 << 27   ; let vector point to RAM
38
        mvts    $8,0
39
start1:
40
        j       start1          ; loop
41
 
42
tmrisr:
43
        add     $8,$0,0x02       ; ien = 1, int = 0
44
        stw     $8,$0,timerbase
45
        j       shmsg
46
 
47
shmsg:
48
        mvfs    $8,0
49
        slr     $8,$8,14        ; $8 = 4 * IRQ number
50
        and     $8,$8,0x1F << 2
51
        ldw     $4,$8,msgtbl    ; get addr of message
52
        jal     msg             ; show message
53
        rfx                     ; return from exception
54
 
55
msg:
56
        sub     $29,$29,8       ; save registers
57
        stw     $31,$29,4
58
        stw     $16,$29,0
59
        add     $16,$4,$0        ; get pointer
60
msg1:
61
        ldbu    $4,$16,0 ; get char
62
        beq     $4,$0,msg2       ; null - finished
63
        jal     out             ; output char
64
        add     $16,$16,1       ; bump pointer
65
        j       msg1            ; next char
66
msg2:
67
        ldw     $16,$29,0        ; restore registers
68
        ldw     $31,$29,4
69
        add     $29,$29,8
70
        jr      $31             ; return
71
 
72
out:
73
        add     $8,$0,termbase   ; set I/O base address
74
out1:
75
        ldw     $9,$8,8         ; get status
76
        and     $9,$9,1         ; xmtr ready?
77
        beq     $9,$0,out1       ; no - wait
78
        stw     $4,$8,12        ; send char
79
        jr      $31             ; return
80
 
81
; service routine table
82
 
83
irqsrv:
84
        .word   shmsg           ; 00: terminal 0 transmitter interrupt
85
        .word   shmsg           ; 01: terminal 0 receiver interrupt
86
        .word   shmsg           ; 02: terminal 1 transmitter interrupt
87
        .word   shmsg           ; 03: terminal 1 receiver interrupt
88
        .word   shmsg           ; 04: keyboard interrupt
89
        .word   shmsg           ; 05: unused
90
        .word   shmsg           ; 06: unused
91
        .word   shmsg           ; 07: unused
92
        .word   shmsg           ; 08: disk interrupt
93
        .word   shmsg           ; 09: unused
94
        .word   shmsg           ; 10: unused
95
        .word   shmsg           ; 11: unused
96
        .word   shmsg           ; 12: unused
97
        .word   shmsg           ; 13: unused
98
        .word   tmrisr          ; 14: timer interrupt
99
        .word   shmsg           ; 15: unused
100
        .word   shmsg           ; 16: bus timeout exception
101
        .word   shmsg           ; 17: illegal instruction exception
102
        .word   shmsg           ; 18: privileged instruction exception
103
        .word   shmsg           ; 19: divide instruction exception
104
        .word   shmsg           ; 20: trap instruction exception
105
        .word   shmsg           ; 21: TLB miss exception
106
        .word   shmsg           ; 22: TLB write exception
107
        .word   shmsg           ; 23: TLB invalid exception
108
        .word   shmsg           ; 24: illegal address exception
109
        .word   shmsg           ; 25: privileged address exception
110
        .word   shmsg           ; 26: unused
111
        .word   shmsg           ; 27: unused
112
        .word   shmsg           ; 28: unused
113
        .word   shmsg           ; 29: unused
114
        .word   shmsg           ; 30: unused
115
        .word   shmsg           ; 31: unused
116
 
117
; message table
118
 
119
msgtbl:
120
        .word   xmtmsg          ; 00: terminal 0 transmitter interrupt
121
        .word   rcvmsg          ; 01: terminal 0 receiver interrupt
122
        .word   xmtmsg          ; 02: terminal 1 transmitter interrupt
123
        .word   rcvmsg          ; 03: terminal 1 receiver interrupt
124
        .word   kbdmsg          ; 04: keyboard interrupt
125
        .word   uimsg           ; 05: unused
126
        .word   uimsg           ; 06: unused
127
        .word   uimsg           ; 07: unused
128
        .word   dskmsg          ; 08: disk interrupt
129
        .word   uimsg           ; 09: unused
130
        .word   uimsg           ; 10: unused
131
        .word   uimsg           ; 11: unused
132
        .word   uimsg           ; 12: unused
133
        .word   uimsg           ; 13: unused
134
        .word   tmrmsg          ; 14: timer interrupt
135
        .word   uimsg           ; 15: unused
136
        .word   btmsg           ; 16: bus timeout exception
137
        .word   iimsg           ; 17: illegal instruction exception
138
        .word   pimsg           ; 18: privileged instruction exception
139
        .word   dimsg           ; 19: divide instruction exception
140
        .word   timsg           ; 20: trap instruction exception
141
        .word   msmsg           ; 21: TLB miss exception
142
        .word   wrmsg           ; 22: TLB write exception
143
        .word   ivmsg           ; 23: TLB invalid exception
144
        .word   iamsg           ; 24: illegal address exception
145
        .word   pamsg           ; 25: privileged address exception
146
        .word   uemsg           ; 26: unused
147
        .word   uemsg           ; 27: unused
148
        .word   uemsg           ; 28: unused
149
        .word   uemsg           ; 29: unused
150
        .word   uemsg           ; 30: unused
151
        .word   uemsg           ; 31: unused
152
 
153
; sign-on message
154
 
155
runmsg:
156
        .byte   "system running..."
157
        .byte   0x0D, 0x0A, 0
158
 
159
; interrupt messages
160
 
161
uimsg:
162
        .byte   "unknown interrupt"
163
        .byte   0x0D, 0x0A, 0
164
 
165
xmtmsg:
166
        .byte   "terminal transmitter interrupt"
167
        .byte   0x0D, 0x0A, 0
168
 
169
rcvmsg:
170
        .byte   "terminal receiver interrupt"
171
        .byte   0x0D, 0x0A, 0
172
 
173
kbdmsg:
174
        .byte   "keyboard interrupt"
175
        .byte   0x0D, 0x0A, 0
176
 
177
dskmsg:
178
        .byte   "disk interrupt"
179
        .byte   0x0D, 0x0A, 0
180
 
181
tmrmsg:
182
        .byte   "timer interrupt"
183
        .byte   0x0D, 0x0A, 0
184
 
185
; exception messages
186
 
187
uemsg:
188
        .byte   "unknown exception"
189
        .byte   0x0D, 0x0A, 0
190
 
191
btmsg:
192
        .byte   "bus timeout exception"
193
        .byte   0x0D, 0x0A, 0
194
 
195
iimsg:
196
        .byte   "illegal instruction exception"
197
        .byte   0x0D, 0x0A, 0
198
 
199
pimsg:
200
        .byte   "privileged instruction exception"
201
        .byte   0x0D, 0x0A, 0
202
 
203
dimsg:
204
        .byte   "divide instruction exception"
205
        .byte   0x0D, 0x0A, 0
206
 
207
timsg:
208
        .byte   "trap instruction exception"
209
        .byte   0x0D, 0x0A, 0
210
 
211
msmsg:
212
        .byte   "TLB miss exception"
213
        .byte   0x0D, 0x0A, 0
214
 
215
wrmsg:
216
        .byte   "TLB write exception"
217
        .byte   0x0D, 0x0A, 0
218
 
219
ivmsg:
220
        .byte   "TLB invalid exception"
221
        .byte   0x0D, 0x0A, 0
222
 
223
iamsg:
224
        .byte   "illegal address exception"
225
        .byte   0x0D, 0x0A, 0
226
 
227
pamsg:
228
        .byte   "privileged address exception"
229
        .byte   0x0D, 0x0A, 0

powered by: WebSVN 2.1.0

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