Mail Archives: djgpp/1997/12/08/04:21:47
"Hugo Jose Ferreira" <hugojf AT mail DOT telepac DOT pt> writes:
> Can someone, please, help me with this Assembly Routine...
> Please, Correct this function:
>
> void setdaccolor(byte color, byte red, byte green, byte blue) {
> __asm__ __volatile__ (
> "movw $0x3C8, %%dx \n\t"
> "outb %%al, %%dx \n\t"
> "movw $0x3C9, %%dx \n\t"
> "movb red, %%al \n\t"
> "outb %%al, %%dx \n\t"
> "movb green, %%al \n\t"
> "outb %%al, %%dx \n\t"
> "movb blue, %%al \n\t"
> "outb %%al, %%dx"
> : : "rm" (color)
> : "%eax", "%edx" );
> }
I don't think your need any assembly here.
void setdaccolor (byte color, byte red, byte green, byte blue)
{
outportb (0x3C8, color);
outportb (0x3C9, red);
outportb (0x3C9, green);
outportb (0x3C9, blue);
}
Or (trying to add some "optimizations"):
void setdaccolor (byte color, byte red, byte green, byte blue)
{
int port = 0x3C8;
outportb (port++, color);
outportb (port, red);
outportb (port, green);
outportb (port, blue);
}
But I don't think this will be any better (try both and choose best
one).
Compile it with: gcc -Wall -O2 -S setdac.c
And see the resulting code in setdac.s
Also, try the following commands:
info gcc invo
(for gcc switches)
info libc alpha outport
(for outport prototype, which headers to include...)
I have not tested the above functions because I have not DJGPP here,
but they should work (after inclusion of correct header and defining
`byte' type).
- Raw text -