Mail Archives: djgpp/2003/12/21/06:37:31
"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 -