flat assembler
Message board for the users of flat assembler.

Index > Main > PUSH-ing FPU constant...

Author
Thread Post new topic Reply to topic
AsmGuru62



Joined: 28 Jan 2004
Posts: 1413
Location: Toronto, Canada
AsmGuru62
Hi,

I just tried the following code:
Code:
push 0.15
    

and it actually worked!! I am blown away!
FASM pushes the DWORD (4 byte FLOAT type) onto stack, which is FPU representation of 0.15.
Is it possible to do the same with the QWORD (8 bytes DOUBLE type)?
I tried few things, like:
Code:
pushq 0.15
push qword 0.15
    

but these did not work.

Well, even if DOUBLE constants can't be PUSH-ed - I am OK to use DWORDs, but precision may be not the same.

So, anyone knows how to do it with DOUBLEs?

P.S. I love FASM!
Now I do not need to waste data section for FPU constants.
And instruction to access stack is coded in less bytes that access the same in data section.
Very cool!!
Post 16 Mar 2012, 21:13
View user's profile Send private message Send e-mail Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4633
Location: Argentina
LocoDelAssembly
Code:
macro pushDouble value*
{
local v
  v = value

  push v shr 32 and $FFFF'FFFF
  push v and $FFFF'FFFF
}    
If you want to "overload" the PUSH instruction then you could inspect invoke and the macros it depends on and see you double parameters are implemented (I haven't looked into them when writing the code above so it would be a good idea to do it even if you don't want to "overload" PUSH)
Post 16 Mar 2012, 22:36
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17492
Location: In your JS exploiting you and your system
revolution
This also works:
Code:
use64
mov rax,2.7182818284590452353602874713527
push rax    
Post 17 Mar 2012, 01:34
View user's profile Send private message Visit poster's website Reply with quote
AsmGuru62



Joined: 28 Jan 2004
Posts: 1413
Location: Toronto, Canada
AsmGuru62
Cool!
Thanks.
Post 18 Mar 2012, 12:57
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-2020, Tomasz Grysztar. Also on YouTube, Twitter.

Website powered by rwasa.