Variable initialization in assembly for IA-32

I have a question about initializing variables in a MASM assembly.

How can I initialize a variable with 2 ^ 32 variable and which variable should I initialize? DWORD or REAL4?

I am trying to do it like:

val DWORD 2.0E+32

      

When I assign var to a register (eg mov eax, val) and try to write the value, I see something that is not 2 ^ 32. I also tried it with the REAL4 type. The result is still the same.

So what am I doing wrong here?

Thanks in advance...

0


source to share


2 answers


2 ^ 32 = 4294967296 = 0x100000000 (that's 8 zeros).



2.0E+32

- this is 2 * 10 ^ 32 = 200000000000000000000000000000000, a completely different number. It is also a floating point number and is an integer. 0x100000000

+3


source


2 ^ 32 is one bit more than dword supports, let me throw in some ranges:

0 <= dword < 2^32
0 <= qword < 2^64
-2^31 <= sdword < 2^31
-2^63 <= sqword < 2^63

      



if REAL4 is a 4-byte floating point, then it has a completely different structure than what an integer has. If you are using x86 then floating point format is probably IEEE 754 . This supports 2 ^ 32-zero, but you might run into precision issues.

+2


source







All Articles