Which architecture does that so I can avoid using it?
Here's how I throw down a stupid IIR:
result = (result + result_old*3)>>2;
Actually, newer ADCs have the filtering built in so who cares anymore?
As I was just trying to understand a piece of code, and not trying to fix a problem, per se, I didn't include any application details, but in case it helps, signal filtering for noise and to prevent aliasing is done in hardware; the filtering in the code here is strictly to render some of those same process variables "human readable".
The MCU is an atmega644p, so 8b, no division and yes, memory and CPU cycles are highly constrained. The ADC readings being averaged are parameters like switch duty cycle, supply voltage, output current, heatsink temp, etc. Some don't really require much averaging (e.g. - heatsink temp), some are all but rendered useless by averaging (e.g. - duty cycle) but they all get it anyway.