I rewrite the code
MOV   EAX, Const_A
MOV  ECX, Const_B
MOV  ECX, 10

That code actually does ((Const_A*Const_B) mod 4294967296)/10 (where the "mod" represents the "xor edx, edx").

I think that the correct advice should be clear EDX if you don't know what is it holding or when you know but it is not part of the dividend. And of course don't clear EDX before multiplication because it is unneeded at all :)
Posted on 2008-01-01 16:26:55 by LocoDelAssembly

And of course don't clear EDX before multiplication because it is unneeded at all :)

That is correct. Anything that is in AX, DX:AX or EDX:EAX gets wiped due to the respective values being stored in those registers. Anything out of that order would be considered a severe design flaw :|

As I said before, if you do 16-bit multiplication with the result being in DX:AX, you could clear EDX beforehand if you expect to use EDX in the same manner as you would MOVZX/MOVSX a value. Other various situations apply, but none that require EDX to be cleared for the multiplication logic to work properly.

Well, you can lead a horse to water, but you can't make it drink ;)
Posted on 2008-01-01 19:17:32 by SpooK
mrgone: that quote applies to division, not multiplication.
Posted on 2008-01-01 19:50:22 by f0dder
  Man, I'm just saying it is a good general rule of thumb. What if you are multiplying a large number that will over flow into EDX and in your result you need the whole integer? You don't want some left over junk in EDX. It could be mistaken as part of the next math operation.
Posted on 2008-01-01 20:09:45 by mrgone

    With respect to the 32-bit MUL instruction, the EDX:EAX pair will contain the 64-bit product.  No matter what you load into EDX beforehand, it will be overwritten by the MUL instruction.  If the product is small, the product can be contained in the EAX register, and the EDX register will set to zero by the MUL instruction.  Furthermore the OF and CF flags will be set to zero.  If  the product is larger than 32-bits, EDX will contain the upper bits (32-63) of the product, and the OF and CF flags will be set.  Therefore it is completely unnecessary to clear EDX before a MUL instruction.  It will happen as described above no matter what the documentation says or how it is interpreted.  Ratch
Posted on 2008-01-01 20:50:32 by Ratch