www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2003/12/21/06:37:31

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
Message-ID: <1d1801c3c7b6$b436a040$0600000a@broadpark.no>
From: "Gisle Vanem" <giva AT bgnett DOT no>
To: <djgpp AT delorie DOT com>
References: <h9uauvkip8afd6q7sj942qh4e8pmjv5lsi AT 4ax DOT com>
Subject: Re: Is this optimizable ?
Date: Sun, 21 Dec 2003 12:36:41 +0100
MIME-Version: 1.0
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" <A_Pox_on_all_spammers AT n DOT com> 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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019