Please explain how MUL operation works in this situation:
MUL ECX
Before operation:
EAX: 000062F7 (25335) ECX: 3B9ACA00 (1000000000) EDX: 00000000 (0)
After operation:
EAX: C3ACE600 EDX: 0000170A (5898)
Would be thankful if anyone can explain me how 5898 was calculated.
Multiplication of two 32-bit values can yield a 64-bit result.
The result of MUL
is stored in EDX:EAX. (The upper 32 bits in EDX, the lower 32 bits in EAX).
0x3b9aca00 * 0x62f7 = 0x170a c3ace600
ECX EAX EDX EAX
It's quite simple actually. The description of MUL r/m32
( r/m32
refers to ECX
in this case) is:
MUL r/m32 (EDX:EAX ← EAX ∗ r/m32).
So EAX
is multiplied by ECX
to form a 64-bit product which is stored in EDX:EAX
(ie the low 32 bits end up in EAX
, and the high 32 bits in EDX
).
So if we punch in 000062F7 * 3B9ACA00
in a calculator, we get 170AC3ACE600
, meaning that EAX
will be C3ACE600
and EDX
will be 170A
(or 5898 in base10).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.