[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: [avr-gcc-list] dev and mod may not be optimized
From: |
Weddington, Eric |
Subject: |
RE: [avr-gcc-list] dev and mod may not be optimized |
Date: |
Tue, 11 Dec 2007 16:29:54 -0700 |
> -----Original Message-----
> From:
> address@hidden
> [mailto:address@hidden
> org] On Behalf Of Dmitry K.
> Sent: Tuesday, December 11, 2007 3:44 PM
> To: address@hidden
> 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] dev and mod may not be optimized, Nathan Moore, 2007/12/11
- AW: [avr-gcc-list] dev and mod may not be optimized, Haase Bjoern (PT/EMM1), 2007/12/11
- Re: [avr-gcc-list] dev and mod may not be optimized, Albert Andras, 2007/12/11
- Re: [avr-gcc-list] dev and mod may not be optimized, Gre7g Luterman, 2007/12/11
- Re: [avr-gcc-list] dev and mod may not be optimized, Paulo Marques, 2007/12/12
- Re: [avr-gcc-list] dev and mod may not be optimized, Paulo Marques, 2007/12/12
- Re: [avr-gcc-list] dev and mod may not be optimized, Gre7g Luterman, 2007/12/12
- Re: [avr-gcc-list] dev and mod may not be optimized, Paulo Marques, 2007/12/12
- Re: [avr-gcc-list] dev and mod may not be optimized, David Brown, 2007/12/12