delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/12/08/12:04:27

Message-ID: <348B9A4A.58FE@mailexcite.com>
Date: Mon, 08 Dec 1997 01:57:14 -0500
From: Doug Gale <dgale AT mailexcite DOT com>
Reply-To: dgale AT mailexcite DOT com
MIME-Version: 1.0
Newsgroups: comp.os.msdos.djgpp
Subject: Re: PLEASE HELP with ExtAsm
References: <66e3ui$9jd$1 AT duke DOT telepac DOT pt>
NNTP-Posting-Host: oshawappp8.idirect.com
Lines: 46
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Hugo Jose Ferreira wrote:
> 
> Hi !
> Can someone, please, help me with this Assembly Routine...
> I'm new to the Extended ASM of DJGPP.. I used to program with RealMode, TASM
> Systax,
> but, all this AT&T syntax confuse me ! 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" );
> }
> 
> Thanks In Advance...

Hmmm. I'm not going to test this, but it should be close if there is a
bug :)

void setdaccolor(byte color, byte red, byte green, byte blue) {
 __asm__ __volatile__ (
   "movl  $0x3C8, %%edx \n\t"
   "outb  %%al, %%dx \n\t"	/* "a" below put color in eax
   "incl  %%edx\n\t"
   "movb  %b1, %%al \n\t"	/* red */
   "outb  %%al, %%dx \n\t"
   "movb  %b2, %%al \n\t"	/* green */
   "outb  %%al, %%dx \n\t"
   "movb  %b3, %%al \n\t"	/* blue */
   "outb  %%al, %%dx"
   : : "a" (color), "rm" (red), "rm" (green), "rm" (blue)
   : "%eax", "%edx" );
}

I also changed your 16-bit move to 32-bit because they are
faster&better. Also, instead of using %1, I used %b1 to specify byte
type.

- Raw text -


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