MUL, IMUL 

Using Multiplication Instructions:

The MUL instruction multiplies unsigned numbers. IMUL multiplies signed numbers. For both instructions, one factor must be in the accumulator register (AL for 8-bit numbers, AX for 16-bit numbers, EAX for 32-bit numbers). The other factor can be in any single register or memory operand. However, it cannot be an immediate value. The result overwrites the contents of the accumulator register. Multiplying two 8-bit numbers produces a 16-bit result returned in AX. Multiplying two 16-bit operands yields a 32-bit result in DX:AX.
The 80386/486 processor handles 64-bit products in the same way in the EDX:EAX pair.

The following examples illustrate multiplication of unsigned and signed numbers.

multiplication of unsigned 8-bit integers

; 8-bit unsigned multiply
        mov     al, 23     ; Load AL                     23
        mov     bl, 24     ; Load BL                   * 24
        mul     bl         ; Multiply BL              -----
                           ; Product in AX              552
                           ;   overflow and carry set

multiplication of unsigned 16-bit integers
        .DATA
mem16   SWORD   30000
        .CODE
        .
        .
        .
; 16-bit signed multiply
        mov     ax, 50     ; Load AX                     50
                           ;                          30000
        mul    mem16       ; Multiply memory          -----
                           ; Product in DX:AX       1500000
                           ;   overflow and carry set

multiplication of signed 16-bit integers
        .DATA
mem16   SWORD   -30000
        .CODE
        .
        .
        .
; 16-bit signed multiply
        mov     ax, 50     ; Load AX                     50
                           ;                         -30000
        imul    mem16      ; Multiply memory          -----
                           ; Product in DX:AX      -1500000
                           ;   overflow and carry set

A nonzero number in the upper half of the result (AH for byte, DX or EDX for word) sets the overflow and carry flags. On the 80186–80486 processors, the IMUL instruction supports three additional operand combinations. The first syntax option allows for 16-bit multipliers producing a 16-bit product or 32-bit multipliers for 32-bit products on the 80386/486. The result overwrites the destination.

The syntax for this operation is:

	IMUL register16, immediate
	IMUL register32, immediate

The second syntax option specifies three operands for IMUL. The first operand must be a 16-bit register operand, the second a 16-bit memory (or register) operand, and the third a 16-bit immediate operand. IMUL multiplies the memory (or register) and immediate operands and stores the product in the register operand with this syntax:

	IMUL register16,{ memory16 | register16}, immediate

For the 80386/486 only, a third option for IMUL allows an additional operand for multiplication of a register value by a register or memory value.

The syntax is:
	IMUL register,{register | memory}

The destination can be any 16-bit or 32-bit register. The source must be the same size as the destination.
In all of these options, products too large to fit in 16 or 32 bits set the overflow and carry flags. The following examples show these three options for IMUL.

multiplication of signed 32-bit integers
        imul    dx, 456     ; Multiply DX times 456 on 80186-80486
        imul    ax, [bx],6  ; Multiply the value pointed to by BX
                            ;   by 6 and put the result in AX

        imul    dx, ax      ; Multiply DX times AX on 80386
        imul    ax, [bx]    ; Multiply AX by the value pointed to
                            ;   by BX on 80386

The IMUL instruction with multiple operands can be used for either signed or unsigned multiplication, since the 16-bit product is the same in either case. To get a 32-bit result, you must use the single-operand version of MUL or IMUL.