Slide 15.1: Multiplication and division instructions Slide 15.3: IMUL instruction Home |
MUL
Instruction
MUL
instruction sets the Carry
and Overflow
flags if the upper half of the product is not equal to zero.
Carry
flag is ordinarily used for unsigned arithmetic, so the Overflow
flag can be ignored.
For example, when AX is multiplied by a 16-bit operand, the product is stored in DX:AX .
The Carry flag is set if DX is not equal to zero.
|
|
8-Bit Multiplication | 8-Bit Multiplication | 16-Bit Multiplication |
.data x BYTE 02h y BYTE 20h .code movsx eax, x mul y call DumpRegs |
.code mov eax, 20h mov bl, 20h mul bl call DumpRegs |
.code mov eax, 30h mov bx, 150h mul bx call DumpRegs |
Output | Output | Output |
16-Bit Multiplication | 32-Bit Multiplication | 32-Bit Multiplication |
.data x WORD 0300h .code movzx eax, x mov bx, 150h mul bx call DumpRegs |
.data x DWORD 00000200h y DWORD 00008000h .code mov eax, x mul y call DumpRegs |
.data x DWORD 00020000h y DWORD 00090000h .code mov eax, x mov ebx, y mul ebx call DumpRegs |
Output | Output | Output |