<<< IMUL Instruction     Index     DIV Instruction >>>

7. IMUL Examples


  1. The following fragment computes 8-bit signed multiplication (48 × 4):

        mov  al, 48
        mov  bl, 4
        imul bl      ; AX = 00C0h (decimal +192), OF = 1
    

    Because AH is not a sign extension of AL, the Overflow flag is set to 1.

     

  2. The following instructions perform 8-bit signed multiplication of (-4 × 4), producing -16 in AX:

        mov  al, -4
        mov  bl, 4
        imul bl      ; AX = FFF0h, OF = 0
    

    AH is a sign extension of AL, meaning that the signed result fits within AL, therefore the Overflow flag is cleared.

     

  3. The following instructions perform 16-bit signed multiplication (48 × 4), producing +192 in DX:AX:

        mov  ax, 48
        mov  bx, 4
        imul bx      ; DX:AX = 0000h:00C0h , OF = 0
    

    Here, DX is a sign extension of AX, so the Overflow flag is cleared.

     

  4. 32-bit signed multiplication example:

        .data
        signed_val SDWORD ?  ; Data type is signed doubleword
        .code
        mov  eax, +4823424
        mov  ebx, -423
        imul ebx             ; EDX:EAX = FFFFFFFFh:86635D80h, OF = 0
        move signed_val, eax ; store the result
    

    EDX is a sign extension of EAX, so the Overflow flag is cleared.

     


<<< IMUL Instruction     Index     DIV Instruction >>>