On Tuesday 13 December 2005 11:36, uedogan wrote: > Hi everybody, > > i'm currently working with the LPC2136 and the latest KEIL C-compiler. > Does anybody know some functions that provide a (much) faster 16-bit > unsigned integer division than KEIL currently has? I have ~58MHz and > the division currently needs about 2us. > I would even prefer some 32-Bit unsigned integer divisions but these > run totaly out of my available timing (KEIL needs ~3.9us for that). OK, I have not tried this out, but I'm quite surprised it takes soooooo long. Keil have a good reputation and I would have expected a better result than this. I looked at the gcc code for divi3 and it is approx 256 bytes long, but not all of that is getting executed. I would expect this to run faster than the numbers you give. Curious how are you doing the measurement? You probably already know this.... ARM does not have a built-in divide instruction so it uses a funky multiply instead. Most of execution goes into calculating the multipliers. Shifting is very cheap on ARM, so if you're doing a lot of divisions by a shiftable number (eg. power of 2), then use shifts instead. The compiler should be able to figure this out itself for constants (eg. x = y / 16; ==> x = y >> 4;). Since remainder (x = y % z) also uses a division, you should also consider using and masking instead (x = y % 8; ==> x = y & 7;)
Message
Re: [lpc2000] Faster integer division with KEIL
2005-12-13 by Charles Manning
Attachments
- No local attachments were found for this message.