The results of the SIN and COS functions are a Signed number ranging from -127 to +127.
PBPW can't multiply or divide negative numbers, so they have to be scaled up to be worked with.

Since Temp is a Byte sized variable, adding 127 brings it up to a range of 0 to 254, which can then be averaged easily.

Then after averaging, 127 is subtracted to restore the signed numbers for use with ATN.
<hr>
For the averaging ...

Code:
S=(S*9+Temp)/10  ; Temp is the new corrected sample
The current average is multiplied by one less than the AvgCount, the new sample is added in for a total of 10 samples. Then it divides by 10 (AvgCount) to get the new average. No WORDs needed.
<br>