• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: PowerPC optional instructions
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: PowerPC optional instructions


  • Subject: Re: PowerPC optional instructions
  • From: Urs Heckmann <email@hidden>
  • Date: Wed, 26 May 2004 23:30:43 +0200

Am 26.05.2004 um 22:00 schrieb Pavol Markovic:

If you look into motorola/ibm cpu tech specs you'll find the answer. If I remember right it's implemented in G3/G4/G5 CPU's.

My question is, how to use this instruction - asm block in C code?

Here's what I use in XCode (defined in a header file, of course):

static inline float __fsel(float number, float val1, float val2)
{
float y;
asm("fsel %0,%1,%2,%3" : "=f" (y) : "f" (number), "f" (val1), "f" (val2));
return y;
}

static inline float __fres(float number)
{
float y;
asm("fres %0,%1" : "=f" (y) : "f" (number));
return y;
}

static inline float __frsqrte(float number)
{
float y;
asm("frsqrte %0,%1" : "=f" (y) : "f" (number + 0.000001f));
return y;
}

static inline float FastReciprocalSqrt( float number ) {
float x = 0.5f * number;
float y;
y = __frsqrte( number );
y *= (1.5f - (x * y * y));
return y * (1.5f - (x * y * y));
}

static inline float FastSqrt(float x)
{
return x * FastReciprocalSqrt(x);
}

// compute two square roots at once... faster...

static inline void FastSqrt2( float &num1, float &num2 )
{

float x1 = 0.5f * num1;
float x2 = 0.5f * num2;

float y1, y2;

asm("frsqrte %0,%1" : "=f" (y1) : "f" (num1 + 0.000001f));
asm("frsqrte %0,%1" : "=f" (y2) : "f" (num2 + 0.000001f));

y1 = y1 * ( 1.5f - ( x1 * y1 * y1 ));
y2 = y2 * ( 1.5f - ( x2 * y2 * y2 ));

y1 = y1 * ( 1.5f - ( x1 * y1 * y1 ));
y2 = y2 * ( 1.5f - ( x2 * y2 * y2 ));

num1 *= y1;
num2 *= y2;
}

Cheers,

;) Urs
_______________________________________________
coreaudio-api mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/coreaudio-api
Do not post admin requests to the list. They will be ignored.


References: 
 >PowerPC optional instructions (From: Os <email@hidden>)
 >Re: PowerPC optional instructions (From: Urs Heckmann <email@hidden>)
 >Re: PowerPC optional instructions (From: Os <email@hidden>)
 >Re: PowerPC optional instructions (From: Pavol Markovic <email@hidden>)

  • Prev by Date: Re: PowerPC optional instructions
  • Next by Date: Re: PowerPC optional instructions
  • Previous by thread: Re: PowerPC optional instructions
  • Next by thread: Re: PowerPC optional instructions
  • Index(es):
    • Date
    • Thread