Moderators: Dave Moll, Steve Anderson
Steve Anderson wrote:There are "For Dummies" books, several of them, C, C+ and C++...then I guess you need an assembler/compiler/programmer...
Steve Anderson wrote:I'm wondering, what would a routine look like that took a 32-bit number and multiplied that by 34.364 (decimal)....result still in binary...allow 40 bits for the result...with a 16-bit PIC it would be trifling...
long long result = (long long)(34.364 * original);
long long t64 = original; // cvt to 64-bit
long long result = (t64 << 5) + (t64 << 1) + (t64 >> 2); // etc...
Steve Anderson wrote:Yes, certainly easier for the human, I wonder mow many instructions the first example results in?
In this case speed isn't that important, would be nice to see the amount of memory required, both program and RAM.
Steve A.
Steve Anderson wrote:Quickly banging out some PIC assembly code for 26-bit binary input multiplied by 34.3597 (decimal) results in a 32-bit output in 175 bytes of code executed in under 88us*. So nowhere near as efficient as the C-code example as provided by Andrew...there may be ways to improve it, but not by much...
*With the processor and clock as per diagram previously. It will certainly do the job, but if there are more efficient ways to do it it makes sense to go that route...
Steve A.
Users browsing this forum: No registered users and 20 guests