How/where to find floating point values in the RAM

Discussion in 'NDS - Emulation and Homebrew' started by CosmoCortney, Jul 29, 2014.

  1. CosmoCortney
    OP

    CosmoCortney The Hacker Furry

    Member
    1,593
    1,511
    Apr 18, 2013
    Germany
    on the cool side of the pillow
    Hi,
    I wanted to start making nds cheats/codes and wanted to search for static floating point values. But afaik floats are emulated and represented by integers.
    i cant simply search for 0x00000001, because i will get a lot of real integers as well. so is there a special way how to find them or a special memory area where floats are located?
     
  2. ethanpet113

    ethanpet113 Member

    Newcomer
    12
    0
    Sep 13, 2009
    Canada
    http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dai0098a/index.html
    3) Software Floating-Point Emulation (FPE), where code is still generated to use coprocessor floating-point instructions, but the actual coprocessor hardware does not exist in the system to implement them. Instead an emulation of the coprocessor is provided which is attached to the ARM processor core’s undefined instruction trap.

    http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0067d/Cihfebih.html
    ^Controling software floating points.

    So basically
    Do not try to find the float, that's impossible; only recognize the truth, that there is no float.

    You can however trap on an undefined operation, which may be an undefined OPCODE that maps to a VFP operation.

    Consequently I expect many games use purely fixed-point and integer operations anyway.
     
  3. Coto

    Coto GBAtemp Addict

    Member
    2,385
    425
    Jun 4, 2010
    Chile
    single floats use 4 bytes, or double floats use 8 bytes in RAM.

    i'll explain single precision float numbers:

    (single) being a base of 2 , whose exponent ranges from -125 to 128. This is 2^31 depths.
    Or 0xFFFFFFFF in a WORD.

    A WORD is 2 bytes on a 32 bit system. A DOUBLE-WORD is 4 bytes on a 32bit system.


    Those fall in the IEEE 754 standard, single precision floating point numbers.

    Mantissa , exponent and bit sign: Mantissa (m for magnitude as well) is encoded in binary (2^ depth), where depth can be any integer, but encoded in binary format.

    [​IMG]
    sign stands for 0 positive exponent, and 1 negative exponent. (-1^s)

    There's a lot of background on this. Keep in mind this is a small brief on how floating point numbers are converted (and rounded ) down. This is not a full tutorial.

    edit: keep in mind depending on the implementation, you may translate binary to decimal:

    (integer*(0)) * (base^0)...+...(integer*(pos-1)) * (base^ (pos-1) )

    where base can be : 2 or 10, or anything else. And pos is the integer scale value, starting from zero to the nth number, being power of base (the right-most digit being nth integer scaler)

    For more info: http://en.wikipedia.org/wiki/IEEE_floating_point (... it makes sense to be coming from wikipedia).
     
    CosmoCortney likes this.
  4. CosmoCortney
    OP

    CosmoCortney The Hacker Furry

    Member
    1,593
    1,511
    Apr 18, 2013
    Germany
    on the cool side of the pillow
    Oh, I see. Thank you for these explanations.
     
  5. Coto

    Coto GBAtemp Addict

    Member
    2,385
    425
    Jun 4, 2010
    Chile
    edited because WORD was 2 bytes and not 4 bytes (that's a DOUBLE WORD). On the ARM9 (thumb mode), and ARM7.

    You welcome.