flat assembler
Message board for the users of flat assembler.

Index > Heap > [Solved] float x=1; equals what in Assembly language?

Author
Thread Post new topic Reply to topic
CampTheBoss



Joined: 02 Feb 2015
Posts: 42
Location: A chair
CampTheBoss
Hey, I know that to load a value as a floating-point in assembly, you type (for example)
Code:
fld dword[esp]    
but what i want to know is this. This code in C:
Code:
float x=1;    
equals what in Assembly language? is it the same as the code using fld?

Extra Information:
C Interpreter: NetBeans 8.0.2
C Compiler: GCC with Msys 1.0


Last edited by CampTheBoss on 29 Mar 2015, 20:49; edited 1 time in total
Post 29 Mar 2015, 19:44
View user's profile Send private message Send e-mail Reply with quote
HaHaAnonymous



Joined: 02 Dec 2012
Posts: 1180
Location: Unknown
HaHaAnonymous
Quote:

equals what in Assembly language? is it the same as the code using fld?

In case of float (not double):
In assembly code you would do:
Code:
fld1
    

or
Code:
fld dword [y]

y:
 dd 1.0
    

or
Code:
movss xmm0, dword [y]

y:
 dd 1.0
    


Now, what the compiler will actually generate, depends on its configuration and code in question. It may use the FPU, SSE or even skip it (not generating it) if it finds unnecessary, etc...

Not sure.


Last edited by HaHaAnonymous on 29 Mar 2015, 20:45; edited 2 times in total
Post 29 Mar 2015, 20:29
View user's profile Send private message Reply with quote
CampTheBoss



Joined: 02 Feb 2015
Posts: 42
Location: A chair
CampTheBoss
Thanks Smile
I can set my GCC compiler to spit out debug information, but it is compiled. I guess it uses plain FPU because GCC is a legacy application
Post 29 Mar 2015, 20:32
View user's profile Send private message Send e-mail Reply with quote
Tyler



Joined: 19 Nov 2009
Posts: 1216
Location: NC, USA
Tyler
You can use the "-masm=intel -S" flags to have it output the assembly it generates.
Post 30 Mar 2015, 00:49
View user's profile Send private message 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 can attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar.

Powered by rwasa.