how do i pack 2 dword (high dword and low dword) into a 64bit number
how do i slpit 1 64 bit number to 2 dword (high and low)
how do i mul 2 64 bit number
how do i div 2 64 bit number
Thanks
Posted on 2002-12-02 18:54:34 by Thor0Asgard
DWord_Low dd 01234567h
DWord_High dd 89ABCDEFh
Originally posted by Thor0Asgard
how do i pack 2 dword (high dword and low dword) into a 64bit number
movd mm0, DWord_High
punpckldq mm0, QWORD PTR DWord_Low
how do i slpit 1 64 bit number to 2 dword (high and low)
movd DWord_Low, mm0
punpckhdq mm0, mm0
movd DWord_High, mm0
how do i mul 2 64 bit number
not availible with MMX
how do i div 2 64 bit number
not availible with MMX
Posted on 2002-12-02 19:10:58 by bitRAKE
can i do mul and div operations by FPU.
if yes how can xchg data from mmx to fpu for this operations.
can you also give me samples for fpu mul and div
thanks again it will help me lots
Posted on 2002-12-02 19:35:57 by Thor0Asgard
min Dword2ToQword proc works fine but my Qword2Dword split rountine not why ?
wher am i wrong ?

QwordTo2Dwords proc,num1:qword
.data
QwordToDwordsDD1 dd 0 ; high dword
QwordToDwordsDD2 dd 0 ; Low dword
QwordToDwordsDq dq 0
.code
pusha
pushf
push num1
pop QwordToDwordsDq
movq mm0,QwordToDwordsDq ;strore the qword num1 into mm0
movd QwordToDwordsDD2, mm0
punpckhdq mm0, mm0
movd QwordToDwordsDD1, mm0
popf
popa
mov eax,QwordToDwordsDD1
mov ebx,QwordToDwordsDD2
ret
QwordTo2Dwords endp

Dwords2ToQword proc,val1:dword,val2:dword
.data
Dwords2ToQwordDq dq 0
Dwords2ToQwordDD1 dd 0
Dwords2ToQwordDD2 dd 0
.code
pusha
pushf
mov eax,val1
mov Dwords2ToQwordDD1,eax
mov eax,val2
mov Dwords2ToQwordDd2,eax
movd mm0,Dwords2ToQwordDD1
punpckldq mm0, QWORD PTR Dwords2ToQwordDD2
movq Dwords2ToQwordDq,mm0
popf
popa
push Dwords2ToQwordDq
ret
Dwords2ToQword endp

here's the test code:
.data
qval dq 0
dd1 dd 0
dd2 dd 0
dwordval1 dd 121
dwordval2 dd 545
.code
call Dword2ToQWord,dwordval1,dwordval2 ;work fine
pop qval
call QwordTo2Dwords,qval
eax=1999.......(in decimal)
ebx=20.........(in decimal)
Posted on 2002-12-02 20:25:44 by Thor0Asgard
Here is the MASM code without error:
QwordTo2Dwords PROC num1:QWORD

movq mm0, num1
movd eax, mm0
punpckhdq mm0, mm0
movd edx, mm0
ret
QwordTo2Dwords ENDP


Dword2ToQWord PROC pQWORD:PTR QWORD, val1:DWORD, val2:DWORD
movd mm0, val1
punpckldq mm0, QWORD PTR val2
mov eax, pQWORD
movq [eax], mm0
ret
Dword2ToQWord ENDP


; here's the test code:
_DATA SEGMENT
qval dq 0
dwordval1 dd 121
dwordval2 dd 545
_DATA ENDS
invoke Dword2ToQWord, OFFSET qval, dwordval1, dwordval2
invoke QwordTo2Dwords, qval
cmp eax, dwordval1
jne Error
cmp edx, dwordval2
jne Error
Posted on 2002-12-02 21:30:53 by bitRAKE
Erm, why use MMX to do this?
Posted on 2002-12-02 21:38:09 by iblis
because it just a sample to see how manipulate dwords and qwords with mmx
now i'll implement this into a DLL so when i'll use MXX funcs it will be easier
i'wont have to rote this code again just use theses funcs
that's all


but iblis if you have the same code using fpu it can interrest me so post it
also mul and div func with fpu (64bit mul/div)

ok thanks bitrake your code is much better for me

ps:can someone give me link or just just a list of the MMX instructions with their use and what they do
thanks gain
Posted on 2002-12-03 07:11:36 by Thor0Asgard
in your QwordTo2Dwords

where is the low nd high dword
is eax the high and edx the low or high in edx and low in eax

cause it seems to me that low is in eax

and i'e got 545 in edx and 121 in eax ?????
i stricty pasted your code .....
Posted on 2002-12-03 07:25:53 by Thor0Asgard