Re: [Fink-devel] ASM in C file ; porting from CodeWarrior -> OSX

2002-06-08 Thread Ben Hines

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: 
>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



Re: [Fink-devel] ASM in C file ; porting from CodeWarrior -> OSX

2002-06-07 Thread Erik de Castro Lopo

On Fri, 7 Jun 2002 21:28:20 -0400
Alexander Strange <[EMAIL PROTECTED]> wrote:

> int float2int(register float in)
> {
> return (int)in;
> }

Hmm. 

I'm not an expert on PPC, in fact I've only had one for three days. 

However I know that on x86 a bit of inline assember can improve
the execution speed of float/double to int casts by a factor of
8 or more. 

In fact, I wrote a paper on it:

http://mega-nerd.com/FPcast/

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.

Regards,
Erik
-- 
+---+
  Erik de Castro Lopo  [EMAIL PROTECTED] (Yes it's valid)
+---+
"Reality is just a crutch for people that can't handle CyberSpace!!"
- Hank Duderstadt

___

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



Re: [Fink-devel] ASM in C file ; porting from CodeWarrior -> OSX

2002-06-07 Thread Alexander Strange

int float2int(register float in)
{
return (int)in;
}

Begin forwarded message:

> From: Erik de Castro Lopo <[EMAIL PROTECTED]>
> Date: Fri Jun 07, 2002  08:54:14  PM US/Eastern
> To: [EMAIL PROTECTED]
> Subject: [Fink-devel] ASM in C file ; porting from CodeWarrior -> OSX
>
> Hi all,
>
> Does anyboy have any idea how to port his code from CodeWarrior
> to OSX?
>
> inline int
> float2int (register float in)
> {   long res [2] ;
>   
>   asm
>   {   fctiw   in,in
> stfd  in,res
>   }
>   
> return res [1] ;
> }
>
> Thanks in advance,
> Erik
> --
> +---+
>   Erik de Castro Lopo  [EMAIL PROTECTED] (Yes it's valid)
> +---+
> "If dolphins are so smart, why do they live in igloos?" -Eric Cartman
>
> ___
>
> 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


___

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



[Fink-devel] ASM in C file ; porting from CodeWarrior -> OSX

2002-06-07 Thread Erik de Castro Lopo

Hi all,

Does anyboy have any idea how to port his code from CodeWarrior
to OSX?

inline int 
float2int (register float in) 
{   long res [2] ;

asm
{   fctiw   in,in
stfdin,res
}

return res [1] ;
}

Thanks in advance,
Erik
-- 
+---+
  Erik de Castro Lopo  [EMAIL PROTECTED] (Yes it's valid)
+---+
"If dolphins are so smart, why do they live in igloos?" -Eric Cartman

___

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