??? 11/15/04 11:50 Read: times |
#81164 - Division by 32bit constant |
Hello all!
Some days ago i have finished writing my own version of sprintf function. I've compared my sprintf and Keil standart sprintf functions. Keil version works x20 faster! After profiling i've found the source of problem. When I convert 32 bit value to string, i use integer division : a=base. (base = 8,10,16). So, as I now, it's naturaly, because universal division function is very slow. For optimization developers usually use (in such cases) "division by constatnt" alghorithms. For example, if i need alghorithm a=8, I just write a>>=3; And that's all! But when I use 10 base system I need a = a10 alghorithm. On PC there is standart agorithm (a = a*(2^32/base), in high 4 bytes we recive a*2/base). But this trick is possible only on 32bit architecture. QUESTION: Does anybody know algorithm for 32 bit value division by constatnt in the context of 8 bit architecture? I tryed to study Keil's sprintf version but it's a 'strong meat' for me... Thanks, Zahar. |
Topic | Author | Date |
Division by 32bit constant | 01/01/70 00:00 | |
RE: Division by 32bit constant | 01/01/70 00:00 | |
If it aint broke... | 01/01/70 00:00 | |
RE: If it aint broke... | 01/01/70 00:00 | |
RE: Division by 32bit constant | 01/01/70 00:00 | |
RE: Division by 32bit constant | 01/01/70 00:00 | |
RE: Division by 32bit constant![]() | 01/01/70 00:00 | |
RE: Division 32bit by 10 | 01/01/70 00:00 |