[Top][All Lists]

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

Re: [avr-libc-dev] [CVS commit: HEAD] document <avr/delay.h>

From: René Liebscher
Subject: Re: [avr-libc-dev] [CVS commit: HEAD] document <avr/delay.h>
Date: Mon, 20 Dec 2004 09:25:39 +0100
User-agent: Mozilla/5.0 (X11; U; Linux i686; de-AT; rv:1.7.2) Gecko/20040906

Joerg Wunsch schrieb:

I just committed the attached patch to the HEAD of CVS.

As I wrote the doxygenized documentation while sitting in a train,
without Internet access, I didn't use any of the submitted ideas
but rather rolled my own version.  (That way, I could find a useful
use of about an hour's worth of time. ;-)

I also tried to make a stab at rolling _delay_ms and _delay_us
macros.  The patch submitted in path #3495 looked too much like
code duplication to me, compared to the already existing inline
functions.  Marek's idea (in the TODO of the header file) about
using fp math was not OK as the preprocessor can only do integer

But the complier can do fp math !

#define X (1.0/3.0)
#define Y (3.14*(X+2.7))
void test(){
   double a=3.14*(X+2.7);

double b=Y;
wil become after the prepocessor
# 1 "x.c"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "x.c"

void test(){
   double a=3.14*((1.0/3.0)+2.7);

double b=(3.14*((1.0/3.0)+2.7));
and as assembler source ( 0x41186509 == 1092117769 ==(3.14*((1.0/3.0)+2.7)) )
       .file   "x.c"
       .arch avr2
__SREG__ = 0x3f
__SP_H__ = 0x3e
__SP_L__ = 0x3d
__tmp_reg__ = 0
__zero_reg__ = 1
       .global __do_copy_data
       .global __do_clear_bss
.global test
       .type   test, @function
/* prologue: frame size=4 */
/* prologue end (size=10) */
       ldi r24,lo8(0x41186509)
       ldi r25,hi8(0x41186509)
       ldi r26,hlo8(0x41186509)
       ldi r27,hhi8(0x41186509)
       std Y+1,r24
       std Y+2,r25
       std Y+3,r26
       std Y+4,r27
/* epilogue: frame size=4 */
/* epilogue end (size=9) */
/* function test size 27 (8) */
       .size   test, .-test
.global b
       .type   b, @object
       .size   b, 4
       .long   1092117769
/* File "x.c": code   27 = 0x001b (   8), prologues  10, epilogues   9 */

reply via email to

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