AngoLinux

80386 Programmer's Reference Manual -- Opcode MUL


MUL -- Unsigned Multiplication of AL or AX

OpcodeInstructionClocks DescriptionExample
F6 /4mulb r/m8,al9-14/12-17 Unsigned multiply (AX := AL * r/m byte)mulb %dl
mulb (%ebx,1)
mulb m8(%ebx,1)
mulb m8(%ebx,%ebp,1)
F7 /4mulw r/m16,ax9-22/12-25 Unsigned multiply (DX:AX := AX * r/m word)mulw %cx
mulw (%ebx,1)
mulw (%ebx,2)
mulw (%ebx,%ebp,1)
F7 /4mull r/m32,eax9-38/12-41 Unsigned multiply (EDX:EAX := EAX * r/m dword)mull %ecx
mull (%ebx,2)
mull (%ebx,4)
mull (%ebx,%ebp,1)

Notes

The 80386 uses an early-out multiply algorithm. The actual number of clocks depends on the position of the most significant bit in the optimizing multiplier, shown underlined above. The optimization occurs for positive and negative multiplier values. Because of the early-out algorithm, clock counts given are minimum to maximum. To calculate the actual clocks, use the following formula:



    Actual clock = if  <> 0 then max(ceiling(log{2}(m)), 3) + 6 clocks;

    Actual clock = if  = 0 then 9 clocks
where m is the multiplier.

Operation




IF byte-size operation
THEN AX := AL * r/m8
ELSE (* word or doubleword operation *)
   IF OperandSize = 16
   THEN DX:AX := AX * r/m16
   ELSE (* OperandSize = 32 *)
      EDX:EAX := EAX * r/m32
   FI;
FI;

Description

MUL performs unsigned multiplication. Its actions depend on the size of its operand, as follows:
  • A byte operand is multiplied by AL; the result is left in AX. The carry and overflow flags are set to 0 if AH is 0; otherwise, they are set to 1.
  • A word operand is multiplied by AX; the result is left in DX:AX. DX contains the high-order 16 bits of the product. The carry and overflow flags are set to 0 if DX is 0; otherwise, they are set to 1.
  • A doubleword operand is multiplied by EAX and the result is left in EDX:EAX. EDX contains the high-order 32 bits of the product. The carry and overflow flags are set to 0 if EDX is 0; otherwise, they are set to 1.

Flags Affected

OF and CF as described above; SF, ZF, AF, PF, and CF are undefined

Protected Mode Exceptions

#GP(0) for an illegal memory operand effective address in the CS, DS, ES, FS, or GS segments; #SS(0) for an illegal address in the SS segment; #PF(fault-code) for a page fault

Real Address Mode Exceptions

Interrupt 13 if any part of the operand would lie outside of the effective address space from 0 to 0FFFFH

Virtual 8086 Mode Exceptions

Same exceptions as in Real Address Mode; #PF(fault-code) for a page fault


[Home Page dell'ITIS "Fermi"] [80386 Programmer's Reference Manual Index] [Previous] [Next]