Slide 88 of 97
Notes:
Now we're going to rewrite our C code knowing that we can use word-wide optimizations and can take advantage of the fact that we do have two multipliers on this DSP.
We have declared * M and * N not as shorts, but as 32-bit values, calling them "int’s”. We have created product L and a product H, and now can do a low product and a high product. The sum has been broken into high and low components, sumL and sumH.
For the loop, we’ll say product L is equal to underscore MPY M sub I times N sub I, and we are getting the lower 16 bits and then summing L. Next we sum the lower product using sum L plus/equals product L. Similar syntax is used with an underscore MPY H to obtain the high product, producth.
Finally, since we are computing two multiplies in the loop, we no longer need to iterate 40 times. Instead we loop 20 times. When we have completed the loop, we get the final sum by adding the low sum to the high sum, and returning this value.