Match exp_by_squaring function (#110)

Signed-off-by: Taggerung <tyler.taggerung@gmail.com>
This commit is contained in:
Tyler McGavran
2021-12-21 00:56:24 -05:00
committed by GitHub
parent 48a06f2fa5
commit 8aca5f519e
3 changed files with 20 additions and 68 deletions
@@ -1,32 +0,0 @@
glabel func_80091750
/* 092350 80091750 04C10003 */ bgez $a2, .L80091760
/* 092354 80091754 3C013FF0 */ li $at, 0x3FF00000 # 1.875000
/* 092358 80091758 10000002 */ b .L80091764
/* 09235C 8009175C 00061023 */ negu $v0, $a2
.L80091760:
/* 092360 80091760 00C01025 */ move $v0, $a2
.L80091764:
/* 092364 80091764 44817800 */ mtc1 $at, $f15
/* 092368 80091768 44807000 */ mtc1 $zero, $f14
/* 09236C 8009176C 10400009 */ beqz $v0, .L80091794
/* 092370 80091770 46207086 */ mov.d $f2, $f14
.L80091774:
/* 092374 80091774 304E0001 */ andi $t6, $v0, 1
/* 092378 80091778 11C00003 */ beqz $t6, .L80091788
/* 09237C 8009177C 00027843 */ sra $t7, $v0, 1
/* 092380 80091780 462C1082 */ mul.d $f2, $f2, $f12
/* 092384 80091784 00000000 */ nop
.L80091788:
/* 092388 80091788 462C6302 */ mul.d $f12, $f12, $f12
/* 09238C 8009178C 15E0FFF9 */ bnez $t7, .L80091774
/* 092390 80091790 01E01025 */ move $v0, $t7
.L80091794:
/* 092394 80091794 04C20004 */ bltzl $a2, .L800917A8
/* 092398 80091798 46227003 */ div.d $f0, $f14, $f2
/* 09239C 8009179C 03E00008 */ jr $ra
/* 0923A0 800917A0 46201006 */ mov.d $f0, $f2
/* 0923A4 800917A4 46227003 */ div.d $f0, $f14, $f2
.L800917A8:
/* 0923A8 800917A8 03E00008 */ jr $ra
/* 0923AC 800917AC 00000000 */ nop
@@ -22,7 +22,7 @@ glabel func_800917B0
/* 092400 80091800 00000000 */ nop
/* 092404 80091804 45020006 */ bc1fl .L80091820
/* 092408 80091808 44801800 */ mtc1 $zero, $f3
/* 09240C 8009180C 0C0245D4 */ jal func_80091750
/* 09240C 8009180C 0C0245D4 */ jal exponent_by_squaring
/* 092410 80091810 00000000 */ nop
/* 092414 80091814 10000012 */ b .L80091860
/* 092418 80091818 8FBF0014 */ lw $ra, 0x14($sp)
+19 -35
View File
@@ -3,51 +3,35 @@
#include <defines.h>
#include "variables.h"
#ifdef MIPS_TO_C
//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307
f64 func_80091750(f64 arg0, s32 arg2) {
s32 temp_t7;
s32 phi_v0;
s32 phi_v0_2;
f64 phi_f2;
f64 phi_f2_2;
f64 phi_f2_3;
f64 phi_f12;
f64 exponent_by_squaring(f64 base, s32 exponent) {
s32 positive_exponent;
f64 result;
phi_f12 = arg0;
if (arg2 < 0) {
phi_v0 = -arg2;
if (exponent < 0) {
positive_exponent = -exponent;
} else {
phi_v0 = arg2;
positive_exponent = exponent;
}
phi_v0_2 = phi_v0;
phi_f2 = 1.0;
phi_f2_3 = 1.0;
if (phi_v0 != 0) {
result = 1.0;
if (positive_exponent != 0) {
do {
temp_t7 = phi_v0_2 >> 1;
phi_f2_2 = phi_f2_3;
if ((phi_v0_2 & 1) != 0) {
phi_f2_2 = phi_f2_3 * phi_f12;
if ((positive_exponent & 1) != 0) {
result *= base;
}
phi_v0_2 = temp_t7;
phi_f2 = phi_f2_2;
phi_f2_3 = phi_f2_2;
phi_f12 *= phi_f12;
} while (temp_t7 != 0);
positive_exponent >>= 1;
base *= base;
} while (positive_exponent != 0);
}
if (arg2 >= 0) {
return phi_f2;
if (exponent >= 0) {
return result;
}
return 1.0 / phi_f2;
return 1.0 / result;
}
#else
GLOBAL_ASM("asm/non_matchings/code_80091750/func_80091750.s")
#endif
#ifdef MIPS_TO_C
//generated by mips_to_c commit 3c3b0cede1a99430bfd3edf8d385802b94f91307
f64 func_80091750(s32); // extern
f64 exponent_by_squaring(s32); // extern
f64 func_8009186C(f64); // extern
f64 func_8009195C(f64, f64); // extern
extern f64 D_800F0CB0;
@@ -59,7 +43,7 @@ f64 func_800917B0(f64 arg0, f64 arg1, f64 arg2) {
phi_a2 = arg2;
if ((arg1 <= D_800F0CB0) && (D_800F0CB8 <= arg1) && (temp_f8 = arg1, phi_a2 = (bitwise f64) temp_f8, (arg1 == temp_f8))) {
return func_80091750(temp_f8);
return exponent_by_squaring(temp_f8);
}
if (arg0 > 0.0) {
arg2 = arg1;