flat assembler
Message board for the users of flat assembler.

Index > Windows > Floating point help

Author
Thread Post new topic Reply to topic
NanoBytes



Joined: 02 Jun 2011
Posts: 57
Location: Iowa, United States
NanoBytes 18 Sep 2011, 22:05
I am trying to figure out how to get floating point numbers to work.
My first question is, how do you set a constant into a FPU register
eg
Code:
MOV ST0,1.2    



My seconed question is how would I output this value to check to make sure it works.
eg
Code:
FIDPI
OUTPUT ST0    

and that should output 3.14...

_________________
He is no fool who gives what he cannot
keep to gain what he cannot loose.
Post 18 Sep 2011, 22:05
View user's profile Send private message Send e-mail Visit poster's website Reply with quote
Overflowz



Joined: 03 Sep 2010
Posts: 1046
Overflowz 18 Sep 2011, 22:43
Here you go, some tutorial Smile
http://www.website.masmforum.com/tutorials/fptute/index.html
for FPU, there is no MOV instruction. instead, use FILD, FLD, FSTP, FBSTP etc.. I'm not prof at FPU but.. I'm going learn it too Wink
Post 18 Sep 2011, 22:43
View user's profile Send private message Reply with quote
NanoBytes



Joined: 02 Jun 2011
Posts: 57
Location: Iowa, United States
NanoBytes 18 Sep 2011, 23:37
That is one question, but I still have no idea how i would output those values to the console?
Post 18 Sep 2011, 23:37
View user's profile Send private message Send e-mail Visit poster's website Reply with quote
AsmGuru62



Joined: 28 Jan 2004
Posts: 1660
Location: Toronto, Canada
AsmGuru62 19 Sep 2011, 15:36
I learned from here (good stuff!):
http://www.website.masmforum.com/tutorials/fptute/index.html

Go to chapter 6 - there is FBSTP instruction - using it you can convert
data from FPU into text and then print on console. It is not easy!

The only way to load 1.2 into FPU is to declare it and then load it:
Code:
value DQ 1.2

...

FLD   [value]
    


Or, you can get the same value by loading INTEGER 2 and then DIVIDING BY INTEGER 10 and then adding 1:
Code:
PUSH 2
FILD DWORD [ESP]
PUSH 10
FIDIV DWORD [ESP]
ADD ESP, 4+4
FLD1
FADDP
    


But that would be brutal waste of CPU cycles! However, you saved 8 bytes for a constant declared in memory.

Edit: wow! I posted same link as above - what are the chances!..
Post 19 Sep 2011, 15:36
View user's profile Send private message Send e-mail Reply with quote
dancho



Joined: 06 Mar 2011
Posts: 74
dancho 20 Sep 2011, 07:55
well THE actual link is : ( Latest revision August 2009 )

http://www.ray.masmcode.com/tutorial/index.html

and Ray's home page :

http://www.ray.masmcode.com/
Post 20 Sep 2011, 07:55
View user's profile Send private message Reply with quote
AsmGuru62



Joined: 28 Jan 2004
Posts: 1660
Location: Toronto, Canada
AsmGuru62 20 Sep 2011, 18:55
Impressive!!! Ray was married before I was born!! Holy cow!
And I was considering myself a senior programmer!
Post 20 Sep 2011, 18:55
View user's profile Send private message Send e-mail 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.