Optimal Int to Float Function
#2
How does this differ from way back when Salmon01 posted a version of this he found in the PPC Compiler Writer's Guide? https://mkwii.com/showthread.php?tid=1252

When taking what Salmon provided and changing it to be self-contained, I ended up with this (untested) ---

Code:
#Prologue
stwu sp, -0x30 (sp)
stmw r30, 0x8 (sp)
stfd f31, 0x10 (sp)

#Conversion
lis r30, 0x4330
lis r31, 0x8000
stmw r30, 0x18 (sp)
lfd f31, 0x18 (sp)
xoris r3, r3, 0x8000
stw r3, 0x1C (sp)
lfd f1, 0x18 (sp)
fsub f1, f1, f31

#Epilogue
lfd f31, 0x10 (sp)
lmw r30, 0x8 (sp)
addi sp, sp, 0x30
blr

Also what's the purpose of the lis r31, 0x5980 instruction? Floats are by far my weakest point of my ASM knowledge.
Reply


Messages In This Thread
Optimal Int to Float Function - by JoshuaMK - 11-10-2020, 10:35 AM
RE: Optimal Int to Float Function - by Vega - 11-10-2020, 10:20 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)