On Wednesday 12 December 2007 01:16, Albert Andras wrote: > ----- Original Message ----- > From: "Nathan Moore" <[EMAIL PROTECTED]> > > > unsigned char a, b, c; > > c = some_input_function(); > > LABEL: > > a = c/10; > > b = c%10; > > ... > > > > ***************************************** > > LABEL: > > mov r24,r18 > > ldi r22,lo8(10) > > call __udivmodqi4 > > mov r19,r24 > > .LM436: > > mov r24,r18 > > call __udivmodqi4 > > > > If I'm understanding __udivmodqi4 it produces the results of both of > > these with one call. > > Acording to: > http://www.nongnu.org/avr-libc/user-manual/structdiv__t.html > > you could do: > > div_t t; > t=div(c/10); > a=t.quot; > b=t.rem;
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; } -------------------------------------------------------------- _______________________________________________ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list