flat assembler
Message board for the users of flat assembler.

Index > Windows > pass qword issue

Author
Thread Post new topic Reply to topic
nazha



Joined: 05 Mar 2009
Posts: 40
Location: Beijing, China
nazha 25 Mar 2009, 05:41
Following code form two dwords to one qword, it work well, q1 value will be 1111111122222222h:
q1 dq 0
dlow dd 11111111h
dhigh dd 22222222h

movd mm0, [dhigh]
punpckldq mm0, qword ptr dlow
movq qword [q1],mm0

But if I move it to a proc:
proc d2q qval,highval,lowval
movd mm0, [highval]
punpckldq mm0, qword ptr lowval
movq qword [qval],mm0
ret
endp

stdcall d2q,q1,[dhigh],[dlow]

the result in q1 is incorrect, in debug windows, seems the mm0 value can not be moved to qval, the stack only have the address of q1, not have qword value of q1.
How can I return the qword value to caller?

_________________
Assembly Asker
Post 25 Mar 2009, 05:41
View user's profile Send private message Reply with quote
comrade



Joined: 16 Jun 2003
Posts: 1150
Location: Russian Federation
comrade 25 Mar 2009, 06:03
you need to pass in a pointer to an output variable
Post 25 Mar 2009, 06:03
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
nazha



Joined: 05 Mar 2009
Posts: 40
Location: Beijing, China
nazha 25 Mar 2009, 06:20
Thanks, sorry but how to do? I'm new to asm.
Post 25 Mar 2009, 06:20
View user's profile Send private message Reply with quote
nazha



Joined: 05 Mar 2009
Posts: 40
Location: Beijing, China
nazha 25 Mar 2009, 10:09
Oh, I got it, it work. thank you, comrade, also OllyDbg.
Change to:

proc d2q qval,highval,lowval
movd mm0, [highval]
punpckldq mm0, qword ptr lowval
mov eax,dword[qval]
movq qword [eax],mm0
ret
endp
Post 25 Mar 2009, 10:09
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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.