Homebrew How/where to find floating point values in the RAM

CosmoCortney

i snack raw pasta and chew lollipops
OP
Member
Joined
Apr 18, 2013
Messages
1,768
Trophies
2
Location
on the cool side of the pillow
Website
follow-the-white-rabbit.wtf
XP
3,007
Country
Germany
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?
 

ethanpet113

Member
Newcomer
Joined
Sep 13, 2009
Messages
12
Trophies
0
XP
139
Country
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.
 

Coto

-
Member
Joined
Jun 4, 2010
Messages
2,979
Trophies
2
XP
2,565
Country
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.

qoagqw.jpg

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).
 
  • Like
Reactions: CosmoCortney

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • No one is chatting at the moment.
    Veho @ Veho: The cybertruck is a death trap.