flat assembler
Message board for the users of flat assembler.

Index > Windows > A problem with numbers...

Author
Thread Post new topic Reply to topic
Necromancer13



Joined: 18 Oct 2007
Posts: 32
Location: Ukraine
Necromancer13 26 Oct 2007, 02:03
In source I wrote
Code:
push 3.2    

but in debugger (OllyDebugger) I see:
Code:
push 404CCCCD    

but why?
Other compillers find an error in this instruction...

_________________
FASM Rulezzzzzz!
Post 26 Oct 2007, 02:03
View user's profile Send private message Visit poster's website MSN Messenger ICQ Number Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4330
Location: Now
edfed 26 Oct 2007, 02:12
in fasm must write
push dword 3.2

the op code 66 68 CD CC 4C 40 is:
push dword (66 68 ) 3.2 (404CCCCD)

see the floating point format to understand the encoding!
Post 26 Oct 2007, 02:12
View user's profile Send private message Visit poster's website Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 26 Oct 2007, 02:19
Quote:
in fasm must write
push dword 3.2

the op code 66 68 CD CC 4C 40 is:
push dword (66 68 ) 3.2 (404CCCCD)

that is not true, and not what he was asking about

necromancer: FASM accepts floating point value in place of dword, and encodes it as single precision floating point number. "3.2" corresponds to 404CCCCD in single precision format.
Post 26 Oct 2007, 02:19
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4330
Location: Now
edfed 26 Oct 2007, 02:34
it was what i was saying

push dword ( 66 68 ) push ( 68 ) dword, 32 bits (66 prefix)
3.2 ( 404CCCCD ) single precision format

bit 31 = sign
bits 0 to 22 = mantissa
bits 23 to 30 = exponent
Post 26 Oct 2007, 02:34
View user's profile Send private message Visit poster's website Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 26 Oct 2007, 02:55
1. why do you mention 66h prefix? that has nothing to do with problem. He didn't understood why FASM accepts floating point at place of dword.

2. you was talking about 16 bit code. In 32bit code you don'y have to use "dword", and no "66" prefix is generated. We are in "WINDOWS" section... why do you mix 66h prefix and 16 bit code here?

3. When describing format of number, you shouldn't forget about normalization, and about format of exponenet. Otherwise this info isn't very useful.
Post 26 Oct 2007, 02:55
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4330
Location: Now
edfed 26 Oct 2007, 07:06
because for me it was very late

very tired

sorry


Last edited by edfed on 26 Oct 2007, 07:10; edited 1 time in total
Post 26 Oct 2007, 07:06
View user's profile Send private message Visit poster's website Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4330
Location: Now
edfed 26 Oct 2007, 07:07
ok Confused Embarassed Arrow Question Rolling Eyes Crying or Very sad Shocked Mad Sad Exclamation Evil or Very Mad
Post 26 Oct 2007, 07:07
View user's profile Send private message Visit poster's website Reply with quote
Necromancer13



Joined: 18 Oct 2007
Posts: 32
Location: Ukraine
Necromancer13 26 Oct 2007, 14:16
ok... Thanks:)
I think I must read about floating point format...
Post 26 Oct 2007, 14:16
View user's profile Send private message Visit poster's website MSN Messenger ICQ Number Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 26 Oct 2007, 15:32
Necromancer: why? you don't need to understand how are floating point numbers encoded to work with them using FPU
Post 26 Oct 2007, 15:32
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4330
Location: Now
edfed 26 Oct 2007, 15:35
a good technician need to know the more possible about his tools and techniques

don't you better use the FPU and SSEx instructions since you know how it is encoded??
Post 26 Oct 2007, 15:35
View user's profile Send private message Visit poster's website Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 26 Oct 2007, 15:47
Yeah, understanding how it works is good, but NOT for someone who wants to learn how to use it.

Quote:
don't you better use the FPU and SSEx instructions since you know how it is encoded??

i doubt understanding encoding of FP would affect how you write FPU code
Post 26 Oct 2007, 15:47
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
Necromancer13



Joined: 18 Oct 2007
Posts: 32
Location: Ukraine
Necromancer13 26 Oct 2007, 15:49
No, I need to know how are they encoded.... I want to know it:(
Post 26 Oct 2007, 15:49
View user's profile Send private message Visit poster's website MSN Messenger ICQ Number Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4330
Location: Now
edfed 26 Oct 2007, 16:02
yes, encoding is not important to write good code

but with binary ( integer ) it is very usefull to know the different values of bits
to make xor eax,eax you need to know the encoding of dwords

as to make fpn manipulation well, you need to know that exists NANs QNANs etc
and knowing the fp encoding is good to manipulate the exponents, the sign, the mantissa

no?

PS: i never code in fp because it's too hard for me
but a young beginer can probably use that really good by learning these kind of things!
Post 26 Oct 2007, 16:02
View user's profile Send private message Visit poster's website Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 26 Oct 2007, 16:09
Quote:
as to make fpn manipulation well, you need to know that exists NANs QNANs etc
and knowing the fp encoding is good to manipulate the exponents, the sign, the mantissa

no?

first of all: why would you need to manipulate other way than by using FPU? If you use FPU, you don't need to know encoding. Encoding of floating point numbers is quite complicated.

Of course you need to know there is NAN, etc.
Post 26 Oct 2007, 16:09
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
Necromancer13



Joined: 18 Oct 2007
Posts: 32
Location: Ukraine
Necromancer13 26 Oct 2007, 17:14
I'll try to find some information about it on the Net...
Post 26 Oct 2007, 17:14
View user's profile Send private message Visit poster's website MSN Messenger ICQ Number Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 27 Oct 2007, 01:36
Necro: my advice: forget about how are FPs encoded, and learn how to work with them
Post 27 Oct 2007, 01:36
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
edfed



Joined: 20 Feb 2006
Posts: 4330
Location: Now
edfed 27 Oct 2007, 01:45
necro: listen to vid, first learn how to use the fpu
vid: maybe one day he will want to know fp encoding?
Post 27 Oct 2007, 01:45
View user's profile Send private message Visit poster's website Reply with quote
Xorpd!



Joined: 21 Dec 2006
Posts: 161
Xorpd! 27 Oct 2007, 03:08
Let's see: SSE doesn't have FABS, FCHS, FSCALE, nor FXTRACT instructions so to synthesize them you have to know the format of floating point numbers in XMM registers, whether single or double, and slice and dice them via logical and shift operations.

Knowing IEEE 754 formats is essential for SSE and one of the fundamental pieces of knowledge one should have if one wants to write x87 code competently. Just think about how any introductory book on assembly language has a chapter on binary, octal, 2's complement arithmetic and the like. Introductory treatises on the x87 FPU similarly have a discussion on IEEE 754 formats. Look in 253665.pdf, for example in section 4.8 Real Numbers and Floating-Point Formats.
Post 27 Oct 2007, 03:08
View user's profile Send private message Visit poster's website Reply with quote
Necromancer13



Joined: 18 Oct 2007
Posts: 32
Location: Ukraine
Necromancer13 11 Nov 2007, 21:19
I've already understood the encoding:)
Post 11 Nov 2007, 21:19
View user's profile Send private message Visit poster's website MSN Messenger ICQ Number Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.