X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f Message-ID: <1d1801c3c7b6$b436a040$0600000a@broadpark.no> From: "Gisle Vanem" To: References: Subject: Re: Is this optimizable ? Date: Sun, 21 Dec 2003 12:36:41 +0100 MIME-Version: 1.0 Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 Reply-To: djgpp AT delorie DOT com "Sourcerer" said: > unsigned char data[1024], *data_ptr; > data_ptr = data; > > for(x = 0; x < 1024; x++) > *data_ptr++ = inportb(0x246); > > I am giving the compiler the -O3 option > > Only trouible is, my for() loop is not fast enough. How do to know? It may be your board is insert wait-states betwen each port read. You can use a "rep insb" or "rep insw" instructions if the board can keep up. extern inline void rep_insb (unsigned short port, unsigned char *buf, size_t bytes) { __asm__ __volatile__ ("cld ; rep ; insb" : "=D" (buf), "=c" (bytes) : "d" (port), "0" (buf), "1" (bytes)); } extern inline void rep_insw (unsigned short port, unsigned short *buf, size_t words) { __asm__ __volatile__ ("cld ; rep ; insw" : "=D" (buf), "=c" (words) : "d" (port), "0" (buf), "1" (words)); } ... rep_insb (0x246, data, sizeof(data); or rep_insw (0x246, (unsigned short*)data, sizeof(data); Word aligned access may be faster. You should time it with RDTSC etc. --gv