On Mon, 31 Jan 2000, Phu T. Van wrote: > Thanks for all your help. I think part (most/all?) of my dilema lies in > the fact that I'm using the PIC, small-ish in both memory and raw > processing power. But I'm also lacking a very fundamental thing : the > knowledge of how to do elementary math with the PIC's very limited > insruction set, specifically its bit-wise operations. > How do you, for example : > --Multiple/divide ? For 12 and 14 bit cores, you're confined to shift-and-add algorithms for multiplications. For the 16 bit cores, there's a hardware multiply. But it only multiplies 8bit numbers to produce a 16bit result. For division, all pics are limited to shift and subtract. If you're dividing by a constant, then you may take the appropriate scaled reciprocal and multiply instead. Another trick I often employ for division is: N N / / e \ / e \2 / e \3 \ ------- = --- * | 1 - |---| + |---| - |---| + ... | v + e v \ \ v / \ v / \ v / / The trick is that you can split denominator into a sum. One of those numbers is easy to divide into N (e.g. a power of two). The other is multiplied. If e is large compared to v, then the series converges rapidly. > --Calculate exponents ? I like Feynmann's method. > --Anything taught in Elementary Algebra ? Hmmm. I'm not sure what you mean here. I'd suggest lurking on this list, wade through all the bull shit, and save those gems that pop up from time to time. > P.S. : I've dug up some information on the CORDIC algorithm. Is there > any way to implement it (painlessly, if possible) on the 16F84 ? The > page claimed it was successfully used on the Basic Stamp II, which is I > think more powerful than the PIC. A completely painless way to implement CORDIC algorithms on a pic is to not. Pics are far better with look up tables. And almost every problem that involves math and the pic can be restructured to use tables. If you don't think so, then ask a question on the list and you'll get an answer showing you how. If you find your self doing a whole lot of simple algebra with a pic, then I'd suggest investing in a C compiler. Scott