Mail Archives: djgpp/1998/08/23/17:48:40
On 23 Aug 98 at 11:39, Endlisnis wrote:
> > 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.
Hmm. Write your own function then; you can then access the
parameters directly, on the stack.
unsigned int RGB (unsigned char, unsigned char, unsigned char);
asm (
".globl _RBG \n"
"_RGB: \n"
" xorl %eax, %eax \n"
" movb 4(%esp), %ah \n"
" movb 8(%esp), %al \n"
" shll $8, %eax \n"
" movb 12(%esp), %al \n"
" ret \n"
);
--
george DOT foot AT merton DOT oxford DOT ac DOT uk
- Raw text -