Let's say I have the following math operation:
FOR b0 = 0 to 255
w0 = 500 * b0 / 2
'do something here with w0
NEXT
Question: Will I have problems with w0 wrapping around back to zero once b0 gets to 132 in the loop? Does the chip calculate w0 as 500 * 132 = 66000 (which is really 464 since w0 is 16 bits), and then divide by two? Will I end up with an answer of 232, or will I end up with 500*132/2 = 33000? Two very different answers! I'm wondering if w0 stores the answer at each and every step of the calculation, or if the entire calculation is completed (without worrying about exceeding 16 bits), and then the answer is dumped into w0.
I know I can just rewrite this example as 500 / 2 * b0, or 250 * b0, but this is just an example. I can't do the same simple rewrite with my actual equation. Once again, I'm just wondering how the calculation is performed.
Thanks.
FOR b0 = 0 to 255
w0 = 500 * b0 / 2
'do something here with w0
NEXT
Question: Will I have problems with w0 wrapping around back to zero once b0 gets to 132 in the loop? Does the chip calculate w0 as 500 * 132 = 66000 (which is really 464 since w0 is 16 bits), and then divide by two? Will I end up with an answer of 232, or will I end up with 500*132/2 = 33000? Two very different answers! I'm wondering if w0 stores the answer at each and every step of the calculation, or if the entire calculation is completed (without worrying about exceeding 16 bits), and then the answer is dumped into w0.
I know I can just rewrite this example as 500 / 2 * b0, or 250 * b0, but this is just an example. I can't do the same simple rewrite with my actual equation. Once again, I'm just wondering how the calculation is performed.
Thanks.