asetup.s
8.73 KB
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
/*************************************************************************
* *
* Copyright (C) 1994, Silicon Graphics, Inc. *
* *
* These coded instructions, statements, and computer programs contain *
* unpublished proprietary information of Silicon Graphics, Inc., and *
* are protected by Federal copyright law. They may not be disclosed *
* to third parties or copied or duplicated in any form, in whole or *
* in part, without the prior written consent of Silicon Graphics, Inc. *
* *
************************************************************************/
/*
* File: asetup.s
*
* Contains the commands: A_CLEARBUFF, A_LOADBUFF, A_SAVEBUFF, A_LOADADPCM,
* A_SEGMENT, A_SETBUFF, A_SETVOL, A_DMMOVE.
*
*/
#########################################################################
#
# Clear a DMEM buffer
#
.ent aclear_buff
.name mask, $1
.name dmemstart, $2
.name count, $3
.name bufbase, $4
.name vzero, $v1
case_A_CLEARBUFF:
andi count, aud1, 0xffff
beq count, zero, AudDone
addi bufbase, zero, RSP_BUFFER_OFFSET # ok for delay slot
andi dmemstart, aud0, 0xffff
add dmemstart, dmemstart, bufbase
vxor vzero, $v1, $v1
addi count, count, -16
cbloop: sdv vzero[0], 0(dmemstart)
sdv vzero[0], 8(dmemstart)
addi dmemstart, dmemstart, 16
bgtz count, cbloop
addi count, count, -16
j AudDone
nop
.unname mask
.unname dmemstart
.unname count
.unname bufbase
.unname vzero
.end aclear_buff
########################################################################
#
# DMA loading and saving DMEM buffers from/to DRAM
#
.ent aload_buff
.name dm_in, $1
.name dr_addr, $2
.name count, $3
.name seg_id, $4
.name seg_addr, $5
case_A_LOADBUFF:
lhu count, RSP_PARAMETER_COUNT(parbase)
beq count, zero, AudDone
sll dr_addr, aud1, 8 # ok for delay slot
srl dr_addr, dr_addr, 8
srl seg_id, aud1, 24 # must clear bits
sll seg_id, seg_id, 2 # leave mult. by 4 for offset
lw seg_addr, RSP_SEG_OFFSET(seg_id)
add dr_addr, dr_addr, seg_addr
lhu dm_in, RSP_PARAMETER_DMEMIN(parbase)
jal DMAread
addi count, count, -1
LBwait: mfc0 $1, DMA_BUSY
bne $1, zero, LBwait
nop
# Release the semaphore
j AudDone
mtc0 $0, SP_RESERVED
.unname dm_in
.end aload_buff
#
# Save buffer
#
.ent asave_buff
.name dm_out, $1
case_A_SAVEBUFF:
lhu count, RSP_PARAMETER_COUNT(parbase)
beq count, zero, AudDone
sll dr_addr, aud1, 8 # ok for delay slot
srl dr_addr, dr_addr, 8
srl seg_id, aud1, 24 # must clear bits
sll seg_id, seg_id, 2 # leave mult. by 4 for offset
lw seg_addr, RSP_SEG_OFFSET(seg_id)
add dr_addr, dr_addr, seg_addr
lhu dm_out, RSP_PARAMETER_DMEMOUT(parbase)
jal DMAwrite
addi count, count, -1
SBwait: mfc0 $1, DMA_BUSY
bne $1, zero, SBwait
nop
# Release the semaphore
j AudDone
mtc0 $0, SP_RESERVED
.unname dm_out
.end asave_buff
#########################################################################
#
# Load ADPCM coefficient table
#
.ent aload_adpcm
.name dm_in, $1
case_A_LOADADPCM:
sll dr_addr, aud1, 8
srl dr_addr, dr_addr, 8
srl seg_id, aud1, 24 # must clear bits
sll seg_id, seg_id, 2 # leave mult. by 4 for offset
lw seg_addr, RSP_SEG_OFFSET(seg_id)
add dr_addr, dr_addr, seg_addr
addi dm_in, zero, RSP_ADPCMTABLE_OFFSET
andi count, aud0, 0xffff
jal DMAread
addi count, count, -1
LAwait: mfc0 $1, DMA_BUSY
bne $1, zero, LAwait
nop
j AudDone
mtc0 $0, SP_RESERVED
.unname dm_in
.unname seg_id
.unname dr_addr
.unname seg_addr
.unname count
.end aload_adpcm
########################################################################
#
# Set the DRAM segment base addresses
#
.ent asegment
.name seg_id, $2
.name seg_addr, $3
.name seg_ptr, $4
.name mask, $5
case_A_SEGMENT:
sll seg_addr, aud1, 8
srl seg_addr, seg_addr, 8
srl seg_id, aud1, 24 # must clear bits
sll seg_id, seg_id, 2 # leave mult. by 4 for offset
add seg_ptr, zero, seg_id
j AudDone
sw seg_addr, RSP_SEG_OFFSET(seg_ptr)
.unname seg_id
.unname seg_addr
.unname seg_ptr
.unname mask
.end asegment
#######################################################################
#
# Set the buffer parameters in DMEM. parbase is a permanent register
# which holds the base of the parameter area.
#
# the following variable names have meaning before underscore when
# when assigning MAIN bus, and meaning after underscore when
# when assigning AUX bus
.ent aset_buff
.name in_outR, $1
.name out_auxL, $2
.name cnt_auxR, $3
.name flags, $4
case_A_SETBUFF:
addi in_outR, aud0, RSP_BUFFER_OFFSET
srl out_auxL, aud1, 16
addi out_auxL, out_auxL, RSP_BUFFER_OFFSET
#
# check MAIN/AUX flag
#
srl flags, aud0, 16
andi flags, flags, A_AUX
bgtz flags, aux_set
addi cnt_auxR, aud1, RSP_BUFFER_OFFSET
#
# A_AUX clear
#
sh in_outR, RSP_PARAMETER_DMEMIN(parbase)
sh out_auxL, RSP_PARAMETER_DMEMOUT(parbase)
j AudDone
sh aud1, RSP_PARAMETER_COUNT(parbase)
#
# A_AUX set
#
aux_set: sh cnt_auxR, RSP_PARAMETER_DMAUXR(parbase)
sh in_outR, RSP_PARAMETER_DMOUTR(parbase)
j AudDone
sh out_auxL, RSP_PARAMETER_DMAUXL(parbase)
.unname in_outR
.unname out_auxL
.unname cnt_auxR
.unname flags
.end aset_buff
########################################################################
#
# Set the volume parameters in DMEM.
#
.ent aset_vol
.name tmp, $1
.name flags, $2
case_A_SETVOL:
#
# check AUX flag
#
srl flags, aud0, 16
andi tmp, flags, A_AUX
beq tmp, zero, sv_chvol
andi tmp, flags, A_VOL
#
# AUX flag set
#
sh aud0, RSP_PARAMETER_DRYAMT(parbase)
j AudDone
sh aud1, RSP_PARAMETER_WETAMT(parbase)
sv_chvol: # AUX flag clear
# check VOL flag
#
beq tmp, zero, sv_chrate
andi tmp, flags, A_LEFT
#
# do vol
# check L/R
#
beq tmp, zero, sv_volR
nop
j AudDone
sh aud0, RSP_PARAMETER_VOLL(parbase)
sv_volR: j AudDone
sh aud0, RSP_PARAMETER_VOLR(parbase)
#
# do rate and target
# check L/R
#
sv_chrate: beq tmp, zero, sv_rateR
srl tmp, aud1, 16
sh aud0, RSP_PARAMETER_VOLTGTL(parbase)
sh tmp, RSP_PARAMETER_VOLRATELM(parbase)
j AudDone
sh aud1, RSP_PARAMETER_VOLRATELL(parbase)
sv_rateR: sh aud0, RSP_PARAMETER_VOLTGTR(parbase)
sh tmp, RSP_PARAMETER_VOLRATERM(parbase)
j AudDone
sh aud1, RSP_PARAMETER_VOLRATERL(parbase)
.unname tmp
.unname flags
.end aset_vol
########################################################################
#
# Interleave two DMEM buffers
#
.ent ainterleave
.name count, $1
.name inpl, $2
.name inpr, $3
.name outp, $4
.name left, $v1
.name right, $v2
case_A_INTERLEAVE:
lhu count, RSP_PARAMETER_COUNT(parbase)
lhu outp, RSP_PARAMETER_DMEMOUT(parbase)
beq count, zero, AudDone
andi inpr, aud1, 0xffff
addi inpr, inpr, RSP_BUFFER_OFFSET
srl inpl, aud1, 16
addi inpl, inpl, RSP_BUFFER_OFFSET
INTERloop1:
lqv left[0], 0(inpl)
lqv right[0], 0(inpr)
ssv left[0], 0(outp)
ssv right[0], 2(outp)
ssv left[2], 4(outp)
ssv right[2], 6(outp)
ssv left[4], 8(outp)
ssv right[4], 10(outp)
ssv left[6], 12(outp)
ssv right[6], 14(outp)
ssv left[8], 16(outp)
ssv right[8], 18(outp)
ssv left[10], 20(outp)
ssv right[10], 22(outp)
ssv left[12], 24(outp)
ssv right[12], 26(outp)
ssv left[14], 28(outp)
ssv right[14], 30(outp)
addi count, count, -16
addi inpl, inpl, 16
addi inpr, inpr, 16
bgtz count, INTERloop1
addi outp, outp, 32
j AudDone
nop
.unname count
.unname inpl
.unname inpr
.unname outp
.unname left
.unname right
.end ainterleave
########################################################################
#
# Move an area of DMEM
#
.ent admem_move
.name count, $1
.name inpp, $2
.name outp, $3
.name tmp0, $v1
.name tmp1, $v2
case_A_DMMOVE:
andi count, aud1, 0xffff
beq count, zero, AudDone
andi inpp, aud0, 0xffff # ok for delay slot
addi inpp, inpp, RSP_BUFFER_OFFSET
srl outp, aud1, 16
addi outp, outp, RSP_BUFFER_OFFSET
DMEMloop1: ldv tmp0[0], 0(inpp)
ldv tmp1[0], 8(inpp)
addi count, count, -16
addi inpp, inpp, 16
sdv tmp0[0], 0(outp)
sdv tmp1[0], 8(outp)
bgtz count, DMEMloop1
addi outp, outp, 16
j AudDone
nop
.unname count
.unname inpp
.unname outp
.unname tmp0
.unname tmp1
.end admem_move
########################################################################
#
# Set the loop state address
#
.ent aset_lstate
.name dr_addr, $1
.name seg_addr, $2
.name seg_id, $3
case_A_SETLSTATE:
sll dr_addr, aud1, 8
srl dr_addr, dr_addr, 8
srl seg_id, aud1, 24 # must clear bits
sll seg_id, seg_id, 2 # leave mult. by 4 for offset
lw seg_addr, RSP_SEG_OFFSET(seg_id)
add dr_addr, dr_addr, seg_addr
sw dr_addr, RSP_PARAMETER_LSTATE(parbase)
j AudDone
nop
.unname dr_addr
.unname seg_addr
.unname seg_id
.end aset_lstate