mov eax,0ffh
mov ecx,0ffh
div ecx

push ecx
INVOKE wsprintf,ADDR register1,ADDR DecimalFormat,eax
pop ecx
INVOKE wsprintf,ADDR register2,ADDR DecimalFormat,edx



invoke MessageBox,NULL,addr register1,addr register2,MB_OK
invoke ExitProcess,NULL
end start


this wont work how can i possibly screw up div ecx?
comment that out and it works fine. put it back in and it dosen't I just wrote it to verify that I couls do modulus division easily but it apears that i cant to division at all opcodes.hlp said that if the i divided by a byte then ah would contain the remainder if i divided by a wrod. the remainder would be in CX (in the example above) so i figured that the remainder would be in ecx if i divided a dword. so i wrote this and was going to play around with it changeing values and such untill i had it all figured out except that all it will do is crash :mad: HELP!
Posted on 2002-04-19 08:52:21 by dionysus
Hi dionysus

You forgot to clear edx.

mov eax,0ffh

mov ecx,0ffh
xor edx,edx
div ecx

push ecx
INVOKE wsprintf,ADDR register1,ADDR DecimalFormat,eax
pop ecx
INVOKE wsprintf,ADDR register2,ADDR DecimalFormat,edx



invoke MessageBox,NULL,addr register1,addr register2,MB_OK
invoke ExitProcess,NULL
end start


KetilO
Posted on 2002-04-19 08:57:05 by KetilO
WOW THX!!!! :P opcodes never said you had to clear out edx to use div but it works hehe. btw yea EDX keeps the remainder :)
Posted on 2002-04-19 22:02:35 by dionysus
You can read more about Div Here...
Posted on 2002-04-19 23:48:22 by NaN
ok so now I can use div to divide numbers up to 64 bits.... how can i divide REALLY HUGE numbers?
Posted on 2002-04-20 04:35:33 by dionysus
Afternoon, dionysus.

ummmm...


push ecx
INVOKE wsprintf,ADDR register1,ADDR DecimalFormat,eax
pop ecx
INVOKE wsprintf,ADDR register2,ADDR DecimalFormat,edx

Shouldn't that be...


push [COLOR=red]edx[/COLOR]
INVOKE wsprintf,ADDR register1,ADDR DecimalFormat,eax
pop [COLOR=red]edx[/COLOR]
INVOKE wsprintf,ADDR register2,ADDR DecimalFormat,edx
?

Cheers,
Scronty
Posted on 2002-04-20 05:13:36 by Scronty
dionysus: Although DIV divides a 64-bit number, it cannot divide any 64-bit number by any 32-bit number. The result has to fit in eax (as edx is used for the remainder), so the result has to be 32-bits at most.
You can't divide 12345678ABCDEF99h by 3. As the result would be 61172283944A533h which will never fit in eax. This will cause an integer overflow exception, just like you had when you forgot to clear eax.

Thomas
Posted on 2002-04-20 05:13:47 by Thomas
erm yes scronty. but i didnt know for shure what register would end up with what in em... so I was checking them all.

nan sweet site has a couple of different opcodes files than what i have lol looks like the later would have saved me from this lol

thomas thx for the additional info.


oh yea any one know how to divide really huge numbers im talkin big now. REAL BIG like as in speed of light... pffft its tiny hehe
Posted on 2002-04-20 05:28:17 by dionysus

oh yea any one know how to divide really huge numbers im talkin big now. REAL BIG like as in speed of light... pffft its tiny hehe


There have been some threads about this, one is:
http://www.asmcommunity.net/board/index.php?topic=2294

But I remember there was one that explained it in more detail.. can't find it anymore though.

I also believe some people have written big number libraries to handle really big numbers, do a search on bignum or biglib.

Thomas
Posted on 2002-04-20 05:31:28 by Thomas