The answer to this question can be very easily found by looking at the proper page of the Intel 64 and IA-32 Instruction Set Reference. In this case, you’re looking for the MUL
and DIV
instructions (in case you’re operating on unsigned operands) or IMUL
and IDIV
instructions, which are used for signed integer multiplication and division.
So, in case you really don’t feel like looking through the manual :
- One of the operands of the multiplication must be placed in the
EAX
register if you’re usingMUL
. This is a bit more flexible if you’re using theIMUL
instruction, which allows you to specify the source and destination registers. - The number being divided is always a 64-bit number in 32-bit mode. The high bits go into
EDX
, while the lower bits go intoEAX
. - The remainder is always placed in
EDX
.
5
solved x86 assembly – masm32: absolute breakdown of multiplication and division [closed]