The IMUL instruction

Signed multiplication.

The IMUL instruction format

InstructionDescription
IMUL reg/mem8Signed multiplication (AX := AL ∗ reg/mem8).
IMUL reg/mem16Signed multiplication (DX:AX := AX ∗ reg/mem16).
IMUL reg16, reg/mem16, imm8Multiplies reg16/mem16 by imm8 and stores the result in reg16. (186/286C)

Multiplies the contents of the specified register or memory location by the al register (8-bit operation) or the ax register (16-bit operation), treating both operands as signed binary numbers, i.e. it performs signed multiplication.

If an 8-bit operation is performed, the 8 least significant bits of the result are stored in the al register, and the 8 most significant bits of the result are stored in the ah register. If a 16-bit operation is performed, the least significant 16 bits of the result are stored in the ax register, and the most significant 16 bits of the result are stored in the dx register. If the high half of the result is a sign extension of the low half of the result, the overflow and carry flags are set to 0; otherwise they are set to 1.

Usage example

title Author: Evgeny Sergeevich Dovgopolov

.286C
.model small
.stack 100h

code segment public        ; Start of the code segment
    assume cs:code

    main proc              ; Start of the main procedure
        mov     ax, -2     ; Copy the value -2 into the ax register
        mov     bx, 4      ; Copy the value 4 into the bx register
        imul    bx         ; Perform signed multiplication of ax by bx

        mov     ax, 5      ; Copy the value 5 into the ax register
        imul    bx, ax, 2  ; Perform signed multiplication of ax by 2. The result is in bx

        mov     ax, 4C00h  ; Copy the process termination function number into ah and the value into al
        int     21h        ; Call the interrupt
    main endp              ; End of the main procedure

code ends                  ; End of the code segment
end main                   ; End of file. The main procedure is the entry point

Example taken from the textbook "HANDYFAR - MASM (Evgeny Sergeevich Dovgopolov)".

Processor status flags

CF
Yes
PF
?
AF
?
ZF
?
SF
?
TF
No
IF
No
DF
No
OF
Yes