Subject: Re: gcc inline asm help?
To: Jeff Rizzo <riz@tastylime.net>
From: Kailash Sethuraman <hsaliak@gmail.com>
List: port-i386
Date: 04/14/2005 16:08:55
Hi,
I am no expert on this but I do have limited experience with inline asm.
From what I can see, the error=20

> > sci.c:91: error: impossible constraint in `asm'=20

probably comes with the constraint
"=3Dax" and similar being specified in the inline asm block. To my
limited knowledge this is incorrect. To specify that the output is to
the ax register, the constraint would have to be "=3Da".
=20
http://www.delorie.com/djgpp/doc/brennan/brennan_att_inline_djgpp.html=20
is a gentler intro to extended asm than the Extended Asm node in the
gcc texinfo manual. It may help.

I have 2 patches that changes these "=3Dax" sort of constraints. It
causes toshutils to compile. But the resultant program is a bit
"weird" in the sense, as I cant easily confirm if its working or not.
The LCD brightness adjustment doesnt seem to be.. but it does detect
the settings correctly.

I have a toshiba portege 3480.

I have attached 2 patches that fixes these according to my understanding.

--- src/hci.c.orig      1999-12-17 21:07:03.000000000 +0800
+++ src/hci.c
@@ -115,8 +115,8 @@ int HciFunction(HciRegisters *reg)
                ax =3D 0x0000;           =20
        } else {
                asm ("inb $0xb2,%%al\n" \
-                       :"=3Dax" (ax), "=3Dbx" (bx), "=3Dcx" (cx), "=3Ddx" =
(dx) \
-                       :"ax" (ax), "bx" (bx), "cx" (cx), "dx" (dx) \
+                       :"=3Da" (ax), "=3Db" (bx), "=3Dc" (cx), "=3Dd" (dx)=
 \
+                       :"a" (ax), "b" (bx), "c" (cx), "d" (dx) \
                        : "memory" );
        }



--- src/sci.c.orig      1999-12-17 21:07:03.000000000 +0800
+++ src/sci.c
@@ -98,7 +98,7 @@ int SciSupportCheck(int *version)
                "popl %%ecx\n\t" \
                "popl %%ebx\n\t" \
                "popl %%eax\n" \
-               :"=3Ddx" (dx), "=3Dah" (ah) : : "memory" );
+               :"=3Dd" (dx), "=3Da" (ah) : : "memory" );
=20
        *version =3D (int) dx;
=20
@@ -149,7 +149,7 @@ int SciCloseInterface(void)
                "popl %%ecx\n\t" \
                "popl %%ebx\n\t" \
                "popl %%eax\n" \
-               :"=3Dah" (ah) : : "memory" );
+               :"=3Da" (ah) : : "memory" );
=20
        return (int) (ah & 0xff);
 }
@@ -173,8 +173,8 @@ int SciGet(SciRegisters *reg)
                "inb $0xb2,%%al\n\t" \
                "popl %%edi\n\t" \
                "popl %%esi\n" \
-               :"=3Dax" (ax), "=3Dbx" (bx), "=3Dcx" (cx), "=3Ddx" (dx) \
-               :"bx" (bx), "cx" (cx) \
+               :"=3Da" (ax), "=3Db" (bx), "=3Dc" (cx), "=3Dd" (dx) \
+               :"b" (bx), "c" (cx) \
                : "memory" );
=20
        reg->attribute =3D (ax & 0xff);
@@ -205,8 +205,8 @@ int SciSet(SciRegisters *reg)
                "inb $0xb2,%%al\n\t" \
                "popl %%edi\n\t" \
                "popl %%esi\n" \
-               :"=3Dax" (ax) \
-               :"bx" (bx), "cx" (cx), "dx" (dx) \
+               :"=3Da" (ax) \
+               :"b" (bx), "c" (cx), "d" (dx) \
                : "memory" );
=20
        reg->attribute =3D (ax & 0xff);


Hope it works and that its the  correct fix!=20
Regards,
Kailash