Announcement

Collapse
No announcement yet.

PPC ASM: Float to INT and vice versa - How to?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • PPC ASM: Float to INT and vice versa - How to?

    Hello,
    I have recently got much deeper into ppc asm and now I'm wondering how to convert a float into INT and vice versa. I have no clue how this could be done...
    Do I need pared singles for that..? Or is there a special casting set I'm not aware about?

    I'd like to do this to display several values on the HUD.
    My Website
    Hacking YouTube Channel


    No requests, please

  • #2
    Have an instruction set reference for your specific model of chip?

    Version 2.01
    Floating
    Convert From Integer Doubleword X-form
    fcfid FRT,FRB (Rc=0)
    fcfid. FRT,FRB (Rc=1)
    The 64-bit signed fixed-point operand in register FRB is converted to an infinitely precise floating-point integer. The result of the conversion is rounded to double-precision, using the rounding mode specified by FPSCR and placed into register FRT.
    Looking at the reference I have, the process requires a few steps. You have to start with a 64-bit integer, store it somewhere in memory, load it to a floating-point register, convert it, and then round it to single-precision if that's what you need. Minimum of 2 instructions if the game starts you off with a 64-bit integer in memory, and you need a double-precision result.
    Last edited by Pyriel; 04-26-2015, 12:44:23 PM.

    Comment


    • #3
      Thanks so far.
      I need it for some GCN and Wii games. The CPUs of both consoles are 32bit RISC based (I think). But support integers and floats in double precision.
      Well, I have found this: http://cr.yp.to/2005-590/powerpc-cwg.pdf
      on page 100 you can find a chapter dedicated to float to int and int to float conversion
      I will give it a try later
      My Website
      Hacking YouTube Channel


      No requests, please

      Comment

      Working...
      X