In the asm opcode documentation

MUL src
Modifies flags: CF OF (AF,PF,SF,ZF undefined)
Unsigned multiply of the accumulator by the source. If "src" is
a byte value, then AL is used as the other multiplicand and the
result is placed in AX. If "src" is a word value, then AX is
multiplied by "src" and DX:AX receives the result. If "src" is
a double word value, then EAX is multiplied by "src" and EDX:EAX
receives the result. The 386+ uses an early out algorithm which
makes multiplying any size value in EAX as fast as in the 8 or 16
bit registers.

If i evaluate an expression, 0x123456*0x123123, where 0x123456 is the src. How could i print the result and store it?
Posted on 2002-05-09 15:44:58 by yoursguideline
xor edx, edx
mov eax, 123123h
mov ecx, 123455h
mul ecx

Answer is in EDX:EAX (64bit number max:: EDX = 63->32 bits, EAX = 31-0 bits.
Posted on 2002-05-09 16:31:01 by NaN
Please forgive me in advance for this :)

I still haven't understood this from the last time I noticed this in some code (in some optimization thread) a while back...

Why do you need to xor edx?

Doesn't the system just write over the value in edx? I've *never* seemed to have any problem when I don't xor edx, but then again it might be that I'm taking a chance... So I'd appreciate the feedback

Just a quick question...

Posted on 2002-05-09 16:51:30 by Sliver
Sorry your right,

Its just habbit. Mainly because you *MUST* for the DIV operation. Since they are formatted the same with simular dependancies on register types, it just becomes habbit to quickly punch out the three steps: Set EDX, Set EAX, Do operation.

In the case of MUL, the EDX is not needed.

Posted on 2002-05-09 16:57:47 by NaN
Thanks for the quick reply :)

Posted on 2002-05-09 16:59:49 by Sliver