Assembly Optimizer Options and Directives
6-7
Optimizing Assembly Code via Linear Assembly
Example 6–4. Linear Assembly Dot Product With .mptr
dotp: .cproc ptr_a, ptr_b, cnt
.reg
val1, val2, val3, val4
.reg
prod1, prod2, sum1, sum2
zero
sum1
zero
sum2
.mptr ptr_a, x, 4
.mptr ptr_b, x, 4
loop: .trip 20, 20
ldh
*ptr_a++, val1
ldh
*ptr_b++, val2
mpy
val1, val2, prod1
add
sum1, prod1, sum1
ldh
*ptr_a++, val3
ldh
*ptr_b++, val4
mpy
val3, val4, prod2
add
sum2, prod2, sum2
[cnt] add
–1, cnt, cnt
[cnt] b
loop
add
sum1, sum2, sum1
return sum1
.endproc
<loop kernel generated>
loop: ; PIPED LOOP KERNEL
[!A1] ADD .L2 B4,B6,B4
|| MPY .M2X B8,A0,B6
|| [ B0] B .S1 loop
|| LDH .D2T2 *B5++(4),B8
|| LDH .D1T1 *–A4(2),A0
[ A1] SUB .S1 A1,1,A1
|| [!A1] ADD .L1 A5,A3,A5
|| MPY .M1X B7,A0,A3
|| [ B0] ADD .L2 –1,B0,B0
|| LDH .D2T2 *–B5(2),B7
|| LDH .D1T1 *A4++(4),A0