avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [avr-gcc-list] refactoring to reduce code size


From: Yann Ramin
Subject: RE: [avr-gcc-list] refactoring to reduce code size
Date: 29 Jan 2003 00:26:09 -0800

Wow, ok, yeah. Thats what I meant to say. Of course it came out as a
weird convergence of what to do and what not to do. Like that one day I
couldn't say ranister or bail correctly (banister, rail if you're
confused :)).


On Wed, 2003-01-29 at 00:08, Sander Pool wrote:
> That is bad advise. Gcc, like all other c compilers will evaluate constant
> expressions to a single constant in the assembly. So using #defines to
> determine baud rate is a -good- idea as it makes code more readable and
> easier to maintain at no cost:
> 
> #define F_CPU            16000000      /* 16Mhz */
> #define UART_BAUD_RATE      9600      /* 9600 baud */
> 
> #define UART_BAUD_SELECT (F_CPU/(UART_BAUD_RATE*16l)-1)
> 
>       UBRR1L = (u08) UART_BAUD_SELECT;
> 
> This carries no code size penalty over hard coding a numeric constant.
> 
> So maybe you meant "don't calculate constants at run-time"?
> 
>       Sander
-- 
----------------------------------------------------------
Yann Ramin              address@hidden
Atrus Trivalie Productions
Jabber: address@hidden
AIM: oddAtrus, Bristomath
www.atrustrivalie.org

"Who is General Failure, and why is he reading my disk?"
Key ID:  B790A0EC 
Fingerprint: 
3E2F FFBC B244 BFF6 C089 7AE3 940D 1037 B790 A0EC 
----------------------------------------------------------

Attachment: signature.asc
Description: This is a digitally signed message part


reply via email to

[Prev in Thread] Current Thread [Next in Thread]