Converting Floaters to Integers for ASM Codes
Converting Floaters to Integers for ASM Codes

Mini guide to demonstrate how to change a floating point value to an integer.

Let's say f0 has our floating point value.

Its double word value is 4077B000 00000000

We first run this ASM...

fctiwz f0, f0

f0 is now converted to an integer, it's value is now FFF80000 0000017B

We want the 17B (our integer value) from the Floating Point Register..

We run this ASM...

stfd f0, 0xXXXX (rX)

rX being some register that holds a memory location. 0xXXXX being the offset if one is present. For example, let's say we want to store our floating-point doubleword to address 0x80001700.

lis r12, 0x8000
stfd f0, 0x1700 (r12)

At address 0x80001700 will be 0xFFF80000
At address 0x80001704 will be 0x0000017B

Now the next step is simple, just load the word 0x0000017B into a desired register

lwz r11, 0x1704 (r12)

And r11 now holds our finalized integer value.

Forum Jump:

Users browsing this thread: 1 Guest(s)