background image

IDIV—Signed Divide

INSTRUCTION SET REFERENCE, A-L

Vol. 2A 3-439

IDIV—Signed Divide

Instruction Operand Encoding

Description

Divides the (signed) value in the AX, DX:AX, or EDX:EAX (dividend) by the source operand (divisor) and stores the 
result in the AX (AH:AL), DX:AX, or EDX:EAX registers. The source operand can be a general-purpose register or a 
memory location. The action of this instruction depends on the operand size (dividend/divisor).
Non-integral results are truncated (chopped) towards 0. The remainder is always less than the divisor in magni-
tude. Overflow is indicated with the #DE (divide error) exception rather than with the CF flag.
In 64-bit mode, the instruction’s default operation size is 32 bits. Use of the REX.R prefix permits access to addi-
tional registers (R8-R15). Use of the REX.W prefix promotes operation to 64 bits. In 64-bit mode when REX.W is 
applied, the instruction divides the signed value in RDX:RAX by the source operand. RAX contains a 64-bit 
quotient; RDX contains a 64-bit remainder. 
See the summary chart at the beginning of this section for encoding data and limits. See Table 3-50.

Opcode

Instruction

Op/ 

En

64-Bit 

Mode

Compat/

Leg Mode

Description

F6 /7

IDIV r/m8

M

Valid

Valid

Signed divide AX by r/m8, with result stored in: 

AL ← Quotient, AH ← Remainder.

REX + F6 /7

IDIV r/m8*

M

Valid

N.E.

Signed divide AX by r/m8, with result stored in 

AL ← Quotient, AH ← Remainder.

F7 /7

IDIV r/m16

M

Valid

Valid

Signed divide DX:AX by r/m16, with result 

stored in AX ← Quotient, DX ← Remainder.

F7 /7

IDIV r/m32

M

Valid

Valid

Signed divide EDX:EAX by r/m32, with result 

stored in EAX ← Quotient, EDX ← Remainder.

REX.W + F7 /7

IDIV r/m64

M

Valid

N.E.

Signed divide RDX:RAX by r/m64, with result 

stored in RAX ← Quotient, RDX ← Remainder.

NOTES:

* In 64-bit mode, r/m8 can not be encoded to access the following byte registers if a REX prefix is used: AH, BH, CH, DH. 

Op/En

Operand 1

Operand 2

Operand 3

Operand 4

M

ModRM:r/m (r)

NA

NA

NA

Table 3-50.  IDIV Results

Operand Size

Dividend

Divisor

Quotient

Remainder

Quotient Range

Word/byte

AX

r/m8

AL

AH

−128 to +127

Doubleword/word

DX:AX

r/m16

AX

DX

−32,768 to +32,767

Quadword/doubleword

EDX:EAX

r/m32

EAX

EDX

−2

31

 to 2

31

 − 1

Doublequadword/ quadword

RDX:RAX

r/m64

RAX

RDX

−2

63

 to 2

63

 − 1