At 11:40 AM +1000 6/8/02, Erik de Castro Lopo wrote:
>
>
>Now that I have a PPC machine I will compare the standard C cast
>against a function similar to the one I posted. I cannot do that
>until I can convert the code, so if anyone knows how to do it,
>I would appreciate hearing from them.


This was from last week on another mailing list:



At 6:30 PM -0700 5/24/02, Fred Forsman wrote:
>Subject: Re: inline PPC assembly using gcc?
>Cc: Raphael Sebbe <[EMAIL PROTECTED]>,
>    Stephane Huaulme
>   <[EMAIL PROTECTED]>,
>    [EMAIL PROTECTED]
>To: Gérard Iglesias <[EMAIL PROTECTED]>
>From: Fred Forsman <[EMAIL PROTECTED]>
>Sender: [EMAIL PROTECTED]
>List-Archive: <http://www.lists.apple.com/archives/projectbuilder-users/>
>Date: Fri, 24 May 2002 18:30:58 -0700
>
>On Friday, May 24, 2002, at 01:21  PM, Girard Iglesias wrote:
>
>>  How do we find the doc to make PPC asm in gcc?
>
>There is no one document covering what you are asking for.  The FSF GCC
>documentation has a general explanation of the inline assembly feature in GCC
>(with x86-based examples).  You will then need to apply those general
>guidelines to PPC assembly language.  You will probably want to have your PPC
>processor manual at your side.
>
>A word of warning, the gcc assembler syntax requires that you identify
>explicitly what arguments to each asm instruction are input and outputs.
>
>Here are some examples:
>
>/*
>   * __OSReadSwapUInt16
>   */
>static inline unsigned short
>__OSReadSwapUInt16 (volatile void *base, int index)
>{
>    unsigned long result;
>    __asm__ ("lhbrx %0, %1, %2"
>             /* outputs:  */ : "=r" (result)
>             /* inputs:   */ : "b" (index), "r" (base)
>             /* clobbers: */ : "memory");
>    return result;
>}
>
>/*
>   * __astrcmp - assembly strcmp
>   */
>static inline int
>astrcmp (const char *in_s1, const char *in_s2)
>{
>    int result, temp;
>    register const char *s1 = in_s1 - 1;
>    register const char *s2 = in_s2 - 1;
>
>    __asm__ ("1:lbzu %0,1(%1)\n"
>             "\tcmpwi cr1,%0,0\n"
>             "\tlbzu %3,1(%2)\n"
>             "\tsubf. %0,%3,%0\n"
>             "\tbeq- cr1,2f\n"
>             "\tbeq+ 1b\n2:"
>              /* outputs: */  : "=&r" (result), "+b" (s1), "+b" (s2), "=r"
>(temp)
>              /* inputs: */   : "1" (s1) , "2" (s2)
>              /* clobbers: */ : "cr0", "cr1", "memory");
>
>    return result;
>
>    /*
>     * "=&r" (result)     means: 'result' is written on (the '='), it's any GP
>     *                    register (the 'r'), and it must not be the same as
>     *                    any of the input registers (the '&').
>     * "+b" (s1)          means: 's1' is read from and written to (the '+'),
>     *                    and it must be a base GP register (i.e., not R0.)
>     * "=r" (temp)        means: 'temp' is any GP reg and it's only written
>to.
>     *
>     * "memory"           in the 'clobbers' section means that gcc will make
>     *                    sure that anything that should be in memory IS there
>     *                    before calling this routine.
>     */
>}
>
>Fred Forsman
>Apple Computer, Inc.
>_______________________________________________
>projectbuilder-users mailing list | [EMAIL PROTECTED]
>Help/Unsubscribe/Archives:
>http://www.lists.apple.com/mailman/listinfo/projectbuilder-users
>Do not post admin requests to the list. They will be ignored.

--
http://homepage.mac.com/bhines/

_______________________________________________________________

Don't miss the 2002 Sprint PCS Application Developer's Conference
August 25-28 in Las Vegas - 
http://devcon.sprintpcs.com/adp/index.cfm?source=osdntextlink

_______________________________________________
Fink-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/fink-devel

Reply via email to