flat assembler
Message board for the users of flat assembler.

 Index > DOS > Float 16bit?
Author
d0z

Joined: 11 Oct 2005
Posts: 11
Location: Sweden
d0z
I'm trying to use float in 16bit environment. But I can't figure out how to declare an single precision float.

This is what I'm trying to do.
Code:
```Sin dd 0.173648f   ;Sin 10 degrees
mov ax,word [Sin]
mov dx,word [Sin+2]
```

The result is: dx:ax = 1|11110001|100011101000011001000 = Very large negative number.

Are all declared float treated as double precision?
[/edit]
24 Oct 2005, 13:34
d0z

Joined: 11 Oct 2005
Posts: 11
Location: Sweden
d0z
Hehe, if you read my previous post you can atleast see one error in it. I'm trying to represent a double word with 30bits.
What I have learned from this is to never trust Microsoft's calculator as it cuts of ending zeros. The bits should look like this:

0|01111100|01100011101000011001000

If I have understood floating numbers this is how it works. Lets say we have bit 0 to the right and bit 31 to the left.
Bit31 = 1 if negative otherwise 0
Bit23-30 = Exponent
Bit0-22(23) = Mantissa

Bit23 is a very special bit since it being assumed to be 1 when used together with mantissa even if it is 0 in my example above. It is only assumed to be 0 in special cases. The mantissa is represented like this when you calculate it:
1.01100011101000011001000
2^0+0^-1+2^-2...+0^-23
If you want to make it easy on yourself you put everything after the dot in a calculator converts it to decimal and divide it by 2^23 and then add 1.

Conclusion:
What I tried to represent as a dw was 0.173648 if you do the calculation from my bits above you get. 1*2^(124-127)*1.389183=0.1736478. So it seems my previous code was right and Fasm handles my Sin value as single precision.

If you would like to know more about float go here http://stevehollasch.com/cgindex/coding/ieeefloat.html

Hopefully this helps some confused float newbies as myself.
24 Oct 2005, 20:34
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First

 Jump to: Select a forum Official----------------AssemblyPeripheria General----------------MainDOSWindowsLinuxUnixMenuetOS Specific----------------MacroinstructionsCompiler InternalsIDE DevelopmentOS ConstructionNon-x86 architecturesHigh Level LanguagesProgramming Language DesignProjects and IdeasExamples and Tutorials Other----------------FeedbackHeapTest Area

Forum Rules:
 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot vote in polls in this forumYou cannot attach files in this forumYou can download files in this forum