Get Square Root of Any Hex Value: PPC ASM
#10
Here is my new version of this, call it as a function, r3 = number, r4 = rounding type (0 = Standard Rounding, 1 = Round Towards Zero):

(Region-Free)
7C651B78 3860FFFF
38630001 7CC319D6
7C062840 4180FFF4
28040001 4082000C
3883FFFF 4800001C
3883FFFF 7CE421D6
7CC53050 7CA72850
7C062840 4C810020
7C832378 4E800020


Code:
typedef int BOOL;
enum { FALSE, TRUE };

unsigned int squareRoot(unsigned int num, BOOL roundDown) {
    unsigned int i = 0;
    while (i * i < num) i = i + 1;
    if (roundDown == TRUE || (i * i) - num > num - (i - 1) * (i - 1)) return i - 1;
    else return i;
}
Super Mario Eclipse, what Super Mario Sunshine could've been.
Reply


Messages In This Thread
RE: Get Square Root of Any Hex Value: PPC ASM - by JoshuaMK - 04-15-2020, 12:34 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)