I am working on implementing the FFT algorithm in an assembly on an 8-bit microcontroller (HCS08) for fun. Once the algorithm is complete, I will have an array of 8-bit real / imaginary pairs, and I want to find the value of each of these values. That is, if x is complex, I want to find
|x| = sqrt(Re{x}^2 + Im{x}^2)
Now I have access to the 16-bit register and 8-bit register. I thought about just squaring them, adding them and taking the square root of the result, but this creates a problem: the maximum possible value of the sum of the squares of two 8-bit numbers is ~ 130 thousand, which is more than the maximum value may contain 16-bit register (65.5 thousand).
I came up with a routine that calculates the integer square root of a 16-bit number, which seems to work fine, but obviously I'm not guaranteed to work with values that fit in 16 bits. Now I think that there is an algorithm that will approximate what I need directly, but I can not find anything. Any ideas are greatly appreciated.
To summarize: Let's say I have a vector with two 8-bit components, and I want to find the length of the vector. How can I approximate this without calculating the squares and square roots?
Thank!
source
share