avr-libc-dev
[Top][All Lists]
Advanced

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

[avr-libc-dev] [bug #23783] Putchar/getchar use causes code growth


From: Wouter
Subject: [avr-libc-dev] [bug #23783] Putchar/getchar use causes code growth
Date: Sun, 06 Jul 2008 12:27:49 +0000
User-agent: Opera/9.50 (Windows NT 5.1; U; nl)

URL:
  <http://savannah.nongnu.org/bugs/?23783>

                 Summary: Putchar/getchar use causes code growth
                 Project: AVR C Runtime Library
            Submitted by: wutje
            Submitted on: Sunday 07/06/2008 at 14:27
                Category: None
                Severity: 3 - Normal
                Priority: 5 - Normal
              Item Group: libc code
                  Status: None
        Percent Complete: 0%
             Assigned to: None
             Open/Closed: Open
         Discussion Lock: Any
                 Release: Any
           Fixed Release: None

    _______________________________________________________

Details:

Currently putchar is defined as
#define         putchar(__c)   fputc(__c, stdout)

which causes C code like this:
putchar(' ')

To generate assembler like this:
lds r22,__iob+2
lds r23,(__iob+2)+1
ldi r24,lo8(32)
ldi r25,hi8(32)
call fputc

This is 8 bytes (lds == 4 bytes) for loading the stream pointer.
If we change this to a "real" putchar call we would save 8 bytes per putchar
call. the putchar call would then load the correct stream:

int putchar(int c)
{       
        return fputc(stdout, c);
}

Since most of libc's user go for size instead of speed this change seems
acceptable. The users who want faster access can still create there own
routines todo as it is done currently.





    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/bugs/?23783>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.nongnu.org/





reply via email to

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