flat assembler
Message board for the users of flat assembler.

Index > Main > simple floating point question

Author
Thread Post new topic Reply to topic
zolkefli



Joined: 05 Mar 2005
Posts: 12
zolkefli 29 Mar 2006, 07:18
I look in FAQ but can find. This is a very simple why.
I try to use 64bit floating point. so I declare

var dq 0.0

then when I try to use the variable like this

MOV qword[var],123.3454

Its error. Where I done wrong.
Post 29 Mar 2006, 07:18
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 29 Mar 2006, 07:21
there just isn't such instruction. processor doesn't have one.
Post 29 Mar 2006, 07:21
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
Reverend



Joined: 24 Aug 2004
Posts: 408
Location: Poland
Reverend 29 Mar 2006, 09:17
in 32-bit procedure you can move immediately only one dword. But you can try:
Code:
pushq 123.3454
movq mm0, qword [esp]
movq qword [var], mm0
add esp, 8

; or
pushq 123.3454
fld qword [esp]
fstp qword [var]
add esp, 8    
It is also possible to create macro which will convert such mov with qword as operand to two movs.
Post 29 Mar 2006, 09:17
View user's profile Send private message Visit poster's website Reply with quote
zolkefli



Joined: 05 Mar 2005
Posts: 12
zolkefli 29 Mar 2006, 10:05
thanks
Post 29 Mar 2006, 10:05
View user's profile Send private message Reply with quote
zolkefli



Joined: 05 Mar 2005
Posts: 12
zolkefli 29 Mar 2006, 11:27
I try

pushq 123.345

error pushq not valid instruction
Post 29 Mar 2006, 11:27
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 29 Mar 2006, 13:23
you can use more advanced features:
Code:
macro movq destptr, value
{
   local ..LO, ..HO
   virtual at 0
      dq 123.456
      load ..LO dword from 0
      load ..HO dword from 4
   end virtual
   mov ptr dest, ..LO
   mov ptr dest+4, ..HO
}
dq var
...
movq var, 123.456
    

(not tested, but idea is there)
Post 29 Mar 2006, 13:23
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
UCM



Joined: 25 Feb 2005
Posts: 285
Location: Canada
UCM 29 Mar 2006, 21:29
vid wrote:
you can use more advanced features:
Code:
macro movq destptr, value
{
   local ..LO, ..HO
   virtual at 0
      dq 123.456
      load ..LO dword from 0
      load ..HO dword from 4
   end virtual
   mov ptr dest, ..LO
   mov ptr dest+4, ..HO
}
dq var
...
movq var, 123.456
    

(not tested, but idea is there)


you mean:
Code:
macro movq destptr, value
{
   local ..LO, ..HO
   virtual at 0
      dq value ;not 123.456
      load ..LO dword from 0
      load ..HO dword from 4
   end virtual
   mov [dest], ..LO
   mov [dest+4], ..HO
}
dq var
...
movq var, 123.456
    

_________________
This calls for... Ultra CRUNCHY Man!
Ta da!! *crunch*
Post 29 Mar 2006, 21:29
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 30 Mar 2006, 00:54
yup, that's it. And i think ptr would work too Wink
Post 30 Mar 2006, 00:54
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
Reverend



Joined: 24 Aug 2004
Posts: 408
Location: Poland
Reverend 30 Mar 2006, 22:03
Yes, that's a great idea, but don't forget that movq is an instruction and your macro overloads it making original one unachievable (eg. movq mm0, qword [esp])

pushq works similar as the movq macro above. I thought it was in official win32ax include, but maybe I'm wrong
Post 30 Mar 2006, 22:03
View user's profile Send private message Visit poster's website Reply with quote
RedGhost



Joined: 18 May 2005
Posts: 443
Location: BC, Canada
RedGhost 31 Mar 2006, 05:56
Reverend wrote:
Yes, that's a great idea, but don't forget that movq is an instruction and your macro overloads it making original one unachievable (eg. movq mm0, qword [esp])

pushq works similar as the movq macro above. I thought it was in official win32ax include, but maybe I'm wrong


Code:
match pushd =double num,pushd value \{ \local ..high,..low
   virtual at 0
    dq num
    load ..low dword from 0
    load ..high dword from 4
   end virtual
   push ..high
   push ..low
   pushd equ \}
    

and
Code:
 match pushd =double =ptr var,pushd value \{
   push dword [var+4]
   push dword [var]
   pushd equ \}
    


are both from win32ax, so you are indeed correct

_________________
redghost.ca
Post 31 Mar 2006, 05:56
View user's profile Send private message AIM Address MSN Messenger Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 31 Mar 2006, 07:55
Reverend: you are right, i forgot there is a movq instruction, i don't play with MMX/SSE stuff a lot. This macro should have another name.
Post 31 Mar 2006, 07:55
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
Reverend



Joined: 24 Aug 2004
Posts: 408
Location: Poland
Reverend 31 Mar 2006, 13:42
zolkefli: According to RedGhost's post and FASM macro, you don't write 'pushq 123.345' but 'push double 123.345' instead.
Post 31 Mar 2006, 13:42
View user's profile Send private message Visit poster's website Reply with quote
UCM



Joined: 25 Feb 2005
Posts: 285
Location: Canada
UCM 01 Apr 2006, 02:23
or... pushd double 123.345
Post 01 Apr 2006, 02:23
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 cannot attach files in this forum
You can download files in this forum


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

Website powered by rwasa.