Hello, We are thinking about switching from 8051 to Cortex M3. At the moment everything is written in assembler. Now I simply would like to know, how many assembler statements a Cortex M3 CPU will take to evaluate a square root from a 48 Bit integer value. Is this (square root of a 48 Bit integer) included in a math library and a nobrainer or is only floating point supported. I am new and just evaluating, what the switch means for us, so I would highly appreciate to get an answer to this question.
Thanks a lot.
Uwe Renschler
:-)
No; I think you really meant, "lightning fast"...?
;-)
I hope that it is also trivial to get the answer to my question: How many assembler statements are executed from a Cortex M3 CPU to figure out the square root of a 48 Bit integer value ?
That depends mostly on what algorithm you intend to use.
This one here is quite interesting:
www.embedded.com/.../9802fe2.htm
However, I don't believe you're going to beat the speed of a table-lookup-plus-interpolation solution, if the slight imprecision of such a solution is acceptable in your application.
The square root calculation will require a number of shifts and additions for each step, and each step will process two input bits, so you'll end up with 24 times a whole bunch of shifts, additions, and one conditional. That may still be faster than 60 statements on an 8051 (especially if it's a 12-clocker), but if you use a lookup-table-based approximation on the ARM, it'll be even faster than the exact calculation.
I meant: "lightening fast", of course.
I never worked with a 8051, however I can assure you that the M3 is lighting fast compared to it. I am confident that you'd be delighted with the calculation speed.
Nice to hear that a fixed point sqrt is trivial. I hope that it is also trivial to get the answer to my question: How many assembler statements are executed from a Cortex M3 CPU to figure out the square root of a 48 Bit integer value ? (min, max values if variable) What I read so far, is that the library could be used. And that is really trivial. But I don t know, what the library looks like and the 48 Bit square root is in our application performance critical. (At the moment we have implemented it using a 128 Entry lookup table and it takes between 40 and 60 8051 assembler statements). The same like in the brackets before would I like to know, for the Cortex M3 with the standard math lib.
A fixed point implementation of SQRT is trivial to implement using 64-bit integers.
I think it's safe to expect the standard C library functionality - no more, no less. There are some extensions, but they are not related to square roots: http://www.keil.com/support/man/docs/armlib/armlib_chdeifcf.htm You can count on 'double sqrt(double)' and 'float sqrtf(float)'. But surely it would be easy to port the existing square root of integer routine from 8051 assembly to C?
View all questions in Keil forum