Lesson 5: Writing Linear Assembly
2-29
Compiler Optimization Tutorial
Example 2–16. Rewriting the iircas4 ( ) Function in Linear Assembly
.def _iircas4_sa
_iircas4_sa: .cproc AI,C,BD,AY
.no_mdep
.reg BD0,BD1,AA,AB,AJ0,AF0,AE0,AG0,AH0,AY0,AK0,AM0,BD00
.reg BA2,BB2,BJ1,BF1,BE1,BG1,BH1,BY1,BK1,BM1
LDW .D2 *+AY[0],AY0
LDW .D2 *+AY[1],BY1
.mptr C, bank+0, 8
.mptr BD, bank+4, 8
LOOP: .trip 10
LDW .D2T1 *C++, AA ; a0 = c[i][0], a1 = c[i][1]
LDW .D2T1 *C++, AB ; b0 = c[i][2], b1 = c[i][3]
LDW .D1T2 *BD[0], BD0 ; d0 = d[i][0]
LDW .D1T2 *BD[1], BD1 ; d1 = d[i][1]
MPYH .1 BD1, AA, AE0 ; e0 = (d1 >> 16) * a1
MPYHL .1 BD0, AA, AJ0 ; j0 = (d0 >> 16) * a0
MPYH .1 BD1, AB, AG0 ; g0 = (d1 >> 16) * b1
MPYHL .1 BD0, AB, AF0 ; f0 = (d0 >> 16) * b0
ADD .1 AJ0, AE0, AH0 ; h0 = j0 + e0
ADD .1 AH0, AY0, AK0 ; k0 = h0 + y0
ADD .1 AF0, AG0, AM0 ; m0 = f0 + g0
ADD .1 AM0, AK0, AY0 ; y0 = m0 + k0
MV .2 AA,BA2
MV .2 AB,BB2
MV .2 BD0,BD00
STW .D1T1 AK0, *BD[1] ; d[i][1] = k0
MPYH .2 BD00, BA2, BE1 ; e1 = (d0 >> 16) * a1
MPYHL .2 AK0, BA2, BJ1 ; j1 = (k0 >> 16) * a0
MPYH .2 BD00, BB2, BG1 ; g1 = (d0 >> 16) * b1
MPYHL .2 AK0, BB2, BF1 ; f1 = (k0 >> 16) * b0
ADD .2 BJ1, BY1, BH1 ; h1 = j1 + y1
ADD .2 BH1, BE1, BK1 ; k1 = h1 + e1
ADD .2 BF1, BG1, BM1 ; m1 = f1 + g1
ADD .2 BM1, BK1, BY1 ; y1 = m1 + k1
STW .D1T2 BK1, *BD++[2] ; d[i][0] = k1
SUB .1 AI,1,AI ; i––
[AI] B .1 LOOP ; for
STW .D2T1 AY0,*+AY[0]
STW .D2T2 BY1,*+AY[1]
.endproc