Currently Being ModeratedFeb 6, 2010 6:37 PM (in response to audioartillery)Re: integer multiplication - stupid assembly question
Think of the integers being scaled by some factor so that all numbers lie in the range [-1,+1). The scaling factor is a tradeoff between magnitude and precision. If the maximum possible value is 20 you could use 1/32 as the scaling factor, but I will use 1/128 in this example so that it is easier to see in the ToneCore UI hex display (not 1/256 - one bit is the sign bit). You need to rescale the multiplication results, which can be done using arithmetic shifts if the scaling factor is a power of 2.
Integer: 5 * 4 = 20
Fixed point: 5/128 *4/128 = 20/16384
multiply by 128 to get 20/128, which is the number you are looking for.
Here is some code:
move b,x:Debug_Read_from_DSP_4 ; displays 140000
Currently Being ModeratedFeb 6, 2010 8:54 PM (in response to RedPandaCurt)Re: integer multiplication - stupid assembly question
Thanks, RedPanda. It makes sense, I was just hoping for something more automatic. The accumulator shifter part of the processor is somewhat configurable from my read of the 56300 family manual, but I didn't see any option or instruction to prevent it from shifting.
For the data I need to handle I need to spend some time analyzing my algorithm to determine out the right precision to use, but it will work. I guess I could dynamically choose the precision based on the data, but that could burn a lot of cycles.