Post: [PPC] square rooting in powerpc
05-06-2015, 02:30 AM #1
(adsbygoogle = window.adsbygoogle || []).push({}); hi ngu Smile lots of people are starting to learn ppc, and alot dont know about certin instructions/methods.
anyways to square root in ppc you can use 'sqrts' for a double, or 'fsqrts' for floats.
the params for both are: sqrts RD,RS. fsqrts FD,FS (RD/FD = Destination, RS/FS = Source)
example:
    
lis %r5,0x200
lfs %f1,0x20(%r5)
fsqrts %f2,%f1
stfs %f2,0x30(%r5)

c++ (sprx) example
    
float sqrt(float flt)
{
*(float*)(0x2100000 + 0x10) = flt;
__asm("lis %r5,0x210;"
"lfs %f1,0x10(%r5);"
"fsqrts %f1,%f1;"
"stfs %f1,0x00(%r5);");
return *(float*)0x2100000;
}

hope this helped Happy

The following 5 users say thank you to milky4444 for this useful post:

Bad Luck Brian, Sabotage, LBK, Maverick, Swaqq
05-06-2015, 10:36 AM #2
Swaqq
Professional Thanker
obviously fake, we both know that lfs means last fucker standing. fake, rat, dont download. Thats all I will say.
05-06-2015, 11:28 AM #3
Originally posted by milky4444 View Post
hi ngu Smile lots of people are starting to learn ppc, and alot dont know about certin instructions/methods.
anyways to square root in ppc you can use 'sqrts' for a double, or 'fsqrts' for floats.
the params for both are: sqrts RD,RS. fsqrts FD,FS (RD/FD = Destination, RS/FS = Source)
example:
    
lis %r5,0x200
lfs %f1,0x20(%r5)
fsqrts %f2,%f1
stfs %f2,0x30(%r5)

c++ (sprx) example
    
float sqrt(float flt)
{
*(float*)(0x2100000 + 0x10) = flt;
__asm("lis %r5,0x210;"
"lfs %f1,0x10(%r5);"
"fsqrts %f1,%f1;"
"stfs %f1,0x00(%r5);");
return *(float*)0x2100000;
}

hope this helped Happy


Thanks man Happy
05-07-2015, 08:54 PM #4
Originally posted by Swaqq View Post
obviously fake, we both know that lfs means last fucker standing. fake, rat, dont download. Thats all I will say.


actually means Listen For Santa
05-09-2015, 12:03 PM #5
Swaqq
Professional Thanker
Originally posted by milky4444 View Post
actually means listen for santa


no, it means lag for sluts!

Copyright © 2024, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo