Mail Archives: djgpp/1998/08/23/14:29:37
George Foot wrote:
> On 22 Aug 98 at 23:31, Endlisnis wrote:
> > int main(){
> > int T=9;
> > asm("movl T, %eax");
> > }
> > How can I make that program compile. How can I load 'T' into %eax without
> > using input registers.
>
> You have to ask gcc to load it for you, because there's no guarrantee
> that `T' has a place in memory. It might for instance be stored in a
> register throughout its useful life.
> You can only load global variables directly; prefix the variable's
> name with an underline.
> Why don't you want to use input registers?
I was trying to make an 'RGB' function that took 3 byte's as parameters and
returned a long. My idea was to do something like:
unsigned int RGB(unsigned char R, unsigned char G, unsigned char B)
{
unsigned Ret;
asm ("shll $8, %%eax; "
"movb G, %%al; "
"shll &8, %%eax; "
"movb B, %%al; "
: "=a" (Ret) : "a" (R) : );
return Ret;
}
That would be faster than loading R,G,B into registers then combining them into
one register.
--
(\/) Endlisnis (\/)
s257m AT unb DOT ca
Endlisnis AT GeoCities DOT com
Endlis AT nbnet DOT nb DOT ca
- Raw text -