www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/08/23/17:48:40

Comments: Authenticated sender is <mert0407 AT sable DOT ox DOT ac DOT uk>
From: "George Foot" <george DOT foot AT merton DOT oxford DOT ac DOT uk>
To: Endlisnis <s257m AT unb DOT ca>
Date: Sun, 23 Aug 1998 22:45:20 +0000
MIME-Version: 1.0
Subject: Re: ASM
Reply-to: george DOT foot AT merton DOT oxford DOT ac DOT uk
CC: djgpp AT delorie DOT com
Message-Id: <E0zAhyH-0007pt-00@sable.ox.ac.uk>

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 -


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