.include "macros.inc"
.section .text, "ax"
.global __num2dec
__num2dec:
mflr r0
stw r0, 4(r1)
stwu r1, -0x68(r1)
stfd f31, 0x60(r1)
fmr f31, f1
stw r31, 0x5c(r1)
stw r30, 0x58(r1)
addi r30, r4, 0
stw r29, 0x54(r1)
mr r29, r3
lha r0, 2(r3)
cmpwi r0, 0x10
mr r31, r0
ble lbl_800833E0
li r31, 0x10
lbl_800833E0:
li r3, 0
stb r3, 0(r30)
li r0, 1
sth r3, 2(r30)
stb r0, 4(r30)
lfd f0, "@268"@sda21(r2)
fcmpu cr0, f0, f31
bne lbl_8008340C
li r0, 0x30
stb r0, 5(r30)
b lbl_80083738
lbl_8008340C:
stfd f31, 0x28(r1)
lis r0, 0x7ff0
lwz r4, 0x28(r1)
rlwinm r3, r4, 0, 1, 0xb
cmpw r3, r0
beq lbl_80083434
bge lbl_8008347C
cmpwi r3, 0
beq lbl_80083458
b lbl_8008347C
lbl_80083434:
clrlwi. r0, r4, 0xc
bne lbl_80083448
lwz r0, 0x2c(r1)
cmpwi r0, 0
beq lbl_80083450
lbl_80083448:
li r0, 1
b lbl_80083480
lbl_80083450:
li r0, 2
b lbl_80083480
lbl_80083458:
clrlwi. r0, r4, 0xc
bne lbl_8008346C
lwz r0, 0x2c(r1)
cmpwi r0, 0
beq lbl_80083474
lbl_8008346C:
li r0, 5
b lbl_80083480
lbl_80083474:
li r0, 3
b lbl_80083480
lbl_8008347C:
li r0, 4
lbl_80083480:
cmpwi r0, 2
bgt lbl_80083518
stfd f31, 0x20(r1)
lis r0, 0x7ff0
lwz r4, 0x20(r1)
rlwinm r3, r4, 0, 1, 0xb
cmpw r3, r0
beq lbl_800834B0
bge lbl_800834F8
cmpwi r3, 0
beq lbl_800834D4
b lbl_800834F8
lbl_800834B0:
clrlwi. r0, r4, 0xc
bne lbl_800834C4
lwz r0, 0x24(r1)
cmpwi r0, 0
beq lbl_800834CC
lbl_800834C4:
li r0, 1
b lbl_800834FC
lbl_800834CC:
li r0, 2
b lbl_800834FC
lbl_800834D4:
clrlwi. r0, r4, 0xc
bne lbl_800834E8
lwz r0, 0x24(r1)
cmpwi r0, 0
beq lbl_800834F0
lbl_800834E8:
li r0, 5
b lbl_800834FC
lbl_800834F0:
li r0, 3
b lbl_800834FC
lbl_800834F8:
li r0, 4
lbl_800834FC:
cmpwi r0, 1
bne lbl_8008350C
li r0, 0x4e
b lbl_80083510
lbl_8008350C:
li r0, 0x49
lbl_80083510:
stb r0, 5(r30)
b lbl_80083738
lbl_80083518:
li r0, 0
stb r0, 4(r30)
lfd f0, "@268"@sda21(r2)
fcmpo cr0, f31, f0
bge lbl_80083538
li r0, 1
fneg f31, f31
stb r0, 0(r30)
lbl_80083538:
fmr f1, f31
addi r3, r1, 0x30
bl frexp
lis r3, 0x000497E5@ha
lwz r4, 0x30(r1)
addi r0, r3, 0x000497E5@l
mullw r0, r4, r0
lis r3, 0x431BDE83@ha
addi r3, r3, 0x431BDE83@l
mulhw r0, r3, r0
srawi r0, r0, 0x12
srwi r3, r0, 0x1f
add. r4, r0, r3
lis r3, bit_values@ha
addi r0, r3, bit_values@l
addi r3, r4, 0
mr r5, r0
bge lbl_800835AC
neg r4, r4
b lbl_800835A0
lbl_80083588:
clrlwi. r0, r4, 0x1f
beq lbl_80083598
lfd f0, 0(r5)
fmul f31, f31, f0
lbl_80083598:
srawi r4, r4, 1
addi r5, r5, 8
lbl_800835A0:
cmpwi r4, 0
bne lbl_80083588
b lbl_800835DC
lbl_800835AC:
ble lbl_800835DC
lfd f1, "@270"@sda21(r2)
b lbl_800835D0
lbl_800835B8:
clrlwi. r0, r4, 0x1f
beq lbl_800835C8
lfd f0, 0(r5)
fmul f1, f1, f0
lbl_800835C8:
srawi r4, r4, 1
addi r5, r5, 8
lbl_800835D0:
cmpwi r4, 0
bne lbl_800835B8
fdiv f31, f31, f1
lbl_800835DC:
lfd f1, "@362"@sda21(r2)
lfd f0, "@270"@sda21(r2)
b lbl_800835F0
lbl_800835E8:
fmul f31, f31, f1
addi r3, r3, 1
lbl_800835F0:
fcmpo cr0, f31, f0
cror 2, 1, 2
beq lbl_800835E8
lfd f1, "@363"@sda21(r2)
lfd f0, "@362"@sda21(r2)
b lbl_80083610
lbl_80083608:
fmul f31, f31, f1
addi r3, r3, -1
lbl_80083610:
fcmpo cr0, f31, f0
blt lbl_80083608
lis r5, 0x66666667@ha
lfd f1, "@272"@sda21(r2)
lis r6, digit_values@ha
addi r4, r30, 5
addi r7, r5, 0x66666667@l
addi r10, r6, digit_values@l
lis r9, 0x4330
b lbl_800836E0
lbl_80083638:
cmpwi r31, 8
addi r12, r31, 0
ble lbl_80083648
li r12, 8
lbl_80083648:
lbz r6, 4(r30)
slwi r0, r12, 3
add r5, r10, r0
add r0, r6, r12
stb r0, 4(r30)
subf r31, r12, r31
subf r3, r12, r3
lfd f0, -8(r5)
add r4, r4, r12
addi r11, r12, 1
fmul f31, f31, f0
fctiwz f0, f31
stfd f0, 0x40(r1)
lwz r0, 0x44(r1)
stfd f0, 0x48(r1)
xoris r0, r0, 0x8000
stw r0, 0x3c(r1)
lwz r6, 0x4c(r1)
stw r9, 0x38(r1)
lfd f0, 0x38(r1)
fsub f0, f0, f1
fsub f31, f31, f0
b lbl_800836D4
lbl_800836A4:
mulhw r8, r7, r6
srawi r0, r8, 2
srwi r5, r0, 0x1f
add r0, r0, r5
mulli r0, r0, 0xa
subf r6, r0, r6
srawi r0, r8, 2
addi r6, r6, 0x30
stb r6, -1(r4)
srwi r5, r0, 0x1f
add r6, r0, r5
addi r4, r4, -1
lbl_800836D4:
addic. r11, r11, -1
bne lbl_800836A4
add r4, r4, r12
lbl_800836E0:
cmpwi r31, 0
bne lbl_80083638
lha r5, 2(r29)
cmpwi r5, 0x24
ble lbl_800836F8
li r5, 0x24
lbl_800836F8:
lbz r0, 4(r30)
subf. r5, r0, r5
ble lbl_80083730
addi r6, r5, 1
li r0, 0x30
b lbl_80083718
lbl_80083710:
stb r0, 0(r4)
addi r4, r4, 1
lbl_80083718:
addic. r6, r6, -1
bne lbl_80083710
lbz r0, 4(r30)
subf r3, r5, r3
add r0, r0, r5
stb r0, 4(r30)
lbl_80083730:
extsh r0, r3
sth r0, 2(r30)
lbl_80083738:
lwz r0, 0x6c(r1)
lfd f31, 0x60(r1)
lwz r31, 0x5c(r1)
mtlr r0
lwz r30, 0x58(r1)
lwz r29, 0x54(r1)
addi r1, r1, 0x68
blr
.section .rodata, "a"
.balign 8
bit_values:
.4byte 0x40240000
.4byte 0
.4byte 0x40590000
.4byte 0
.4byte 0x40C38800
.4byte 0
.4byte 0x4197D784
.4byte 0
.4byte 0x4341C379
.4byte 0x37E08000
.4byte 0x4693B8B5
.4byte 0xB5056E17
.4byte 0x4D384F03
.4byte 0xE93FF9F5
.4byte 0x5A827748
.4byte 0xF9301D32
.4byte 0x75154FDD
.4byte 0x7F73BF3C
digit_values:
.4byte 0x40240000
.4byte 0
.4byte 0x40590000
.4byte 0
.4byte 0x408F4000
.4byte 0
.4byte 0x40C38800
.4byte 0
.4byte 0x40F86A00
.4byte 0
.4byte 0x412E8480
.4byte 0
.4byte 0x416312D0
.4byte 0
.4byte 0x4197D784
.4byte 0
.section .sdata2, "a"
.balign 8
"@268":
.4byte 0
.4byte 0
"@270":
.4byte 0x3FF00000
.4byte 0
"@272":
.4byte 0x43300000
.4byte 0x80000000
"@362":
.4byte 0x3FB99999
.4byte 0x9999999A
"@363":
.4byte 0x40240000
.4byte 0