> -----Original Message----- > From: > [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] > org] On Behalf Of Dmitry K. > Sent: Tuesday, December 11, 2007 3:44 PM > To: avr-gcc-list@nongnu.org > Cc: Nathan Moore > Subject: Re: [avr-gcc-list] dev and mod may not be optimized > > > Alas, the usage of div() function is more space and more time > expansive. The reason is that div() uses an another function: > __divmodhi4(), i.e. 16-bits. > > Compare two programs: > prog1: 150 bytes, 238 clocks > prog2: 212 bytes, 316 clocks > > Regards, > Dmitry. > > ------------------------------------------------------------- > volatile unsigned char a, b, v = 123; > int main () > { > unsigned char c = v; > a = c / 10; > b = c % 10; > return 0; > } > ------------------------------------------------------------- > #include <stdlib.h> > volatile unsigned char a, b, v = 123; > int main () > { > div_t d; > d = div (v, 10); > a = d.quot; > b = d.rem; > return 0; > } > --------------------------------------------------------------
Should we implement 2 (or 3) div functions then in avr-libc? 8, 16, and 32 bit? Eric _______________________________________________ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list