flat assembler
Message board for the users of flat assembler.

Index > Main > how to mov a register into a qword

Author
Thread Post new topic Reply to topic
patchariadog



Joined: 24 Mar 2013
Posts: 94
patchariadog 21 Jun 2014, 04:35
I am trying to move a specific value generated by the user into a dq? to use SSE2 arithmetic on it

when I use the FPU I use dword and do something like this
Code:
mov eax,255.5
mov [buffer1],eax
    


but I can't do this for dq words

how would I get eax into buffer1 if it was a dq?

thanks srry for the noob question
Post 21 Jun 2014, 04:35
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20445
Location: In your JS exploiting you and your system
revolution 21 Jun 2014, 04:46
A DQ sized value is 64-bits so it won't fit into a 32-bit register. There are various options.
Code:
buffer1 dq ?
value = qword 255.5
mov eax,value and 0xffffffff
mov ecx,value shr 32
mov dword[buffer1+4*0],eax
mov dword[buffer1+4*1],ecx

;or maybe

mov dword[buffer1+4*0],value and 0xffffffff
mov dword[buffer1+4*1],value shr 32    
Post 21 Jun 2014, 04:46
View user's profile Send private message Visit poster's website Reply with quote
patchariadog



Joined: 24 Mar 2013
Posts: 94
patchariadog 21 Jun 2014, 05:20
thanks for helping revolution, but I still can't get it to do what I want.
I have a proc that will calculate the area of a triangle and shove the result into the eax register

I was wondering how can I get the eax register into the buffer1 dq ?

in the example you provided I don't understand why the value is their, and frankly I have never seen half of the instructions, lol.

i tried this
Code:
mov eax,1.0
  mov ecx,1.0

mov dword[buffer1+4*0],eax
mov dword[buffer1+4*1],ecx 
    


but instead of buffer1 containing 1.0 it contained 0.00781

thanks
Post 21 Jun 2014, 05:20
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20445
Location: In your JS exploiting you and your system
revolution 21 Jun 2014, 05:36
Oh, so you want to convert from single precision to double? Is that your query?

If so then perhaps:
Code:
mov dword[buffer1],eax
fld dword[buffer1]
fstp qword[buffer1]    
Post 21 Jun 2014, 05:36
View user's profile Send private message Visit poster's website Reply with quote
patchariadog



Joined: 24 Mar 2013
Posts: 94
patchariadog 21 Jun 2014, 05:48
thanks revolution, you taught me something new again, lol

if you don't mind could you explain to me a few things on the first code you posted.

first of all what was the first code for(what is the purpose of it?)
second I have never seen multiple instructions on the same line? like the "mov eax,value and 0xffffffff "
lastly I know what the [buffer1+4] is but I have never seen the [buffer1+4*0] what is the * for?

thanks for helping me!
Post 21 Jun 2014, 05:48
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20445
Location: In your JS exploiting you and your system
revolution 21 Jun 2014, 05:57
There are not multiple instructions on one line. It is an "expression" that is evaluated by fasm to get the final constant. "value" is 64-bits so it is broken into two pieces of 32-bits and placed into the buffer. And the * is just a multiply, the same as +, - and / where fasm computes the value at assembly time. So 4*0 is just 0, and 4*1 is 4.
Post 21 Jun 2014, 05:57
View user's profile Send private message Visit poster's website Reply with quote
patchariadog



Joined: 24 Mar 2013
Posts: 94
patchariadog 21 Jun 2014, 06:00
oh okay. thanks!
Post 21 Jun 2014, 06:00
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-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.