DIV Instruction

Purpose:To perform arithmetic division
Format:DIVX2: opcode divr.rx, quo.mx
DIVX3: opcode divr.rx, divd.rx, quo.wx
Operation:DIVX2: quo <- quo / divr;
DIVX3: quo <- divd / divr;
Condition
Codes:
N <- quo LSS 0;
Z <- quo EQL 0;
V <- overflow Or (divr equal to 0);
C <- 0;
Exceptions:Integer Overflow;
Divide by Zero
Floating Overflow;
Floating Underflow;
Reserved Operand (Float)
Opcodes:
86DIVB2Divide Byte 2 Operand
87DIVB3Divide Byte 3 Operand
A6DIVW2Divide Word 3 Operand
A6DIVW3Divide Word 2 Operand
C6DIVL2Divide Long 2 Operand
C7DIVL3Divide Long 3 Operand
46DIVF2Divide Float 2 Operand
47DIVF3Divide Float 3 Operand
66DIVD2Divide Double 2 Operand
67DIVD3Divide Double 3 Operand
Description: In the 2 operand format, the quotient operand is divided by the divisor operand and the quotient operand is replaced with the result. The divisor operand is unaffected.

In the 3 Operand format, the dividend is divided by the divisor operand and the quotient operand is replaced with the result.The dividend and divisor operands are unaffected.

In floating point format, the result is rounded.

Notes:
1.
Integer division is performed such that the remainder (unless it is zero) has the same sign as the dividend; i.e. the result is truncated towards 0.
2.
Integer overflow occurs if and only if the largest negative number is divided by -1. On overflow, the operands are effected as described in 3, below.
3.
If the integer divisor operand is zero, then in 2 operand integer format, the quotient operand is not affected; in 3 operand format the quotient operand is replaced by the dividend operand.
4.
On a floating reserved operand fault, the quotient is unaffected and the condition codes are unpredictable.
3.
On floating underflow, the quotient operand is replaced by 0.
4.
On floating divide by zero or on floating overflow, the quotient operand is replaced by an operand of all 0 bits except for the sign bit of 1 (a reserved operand (-1)). N <- 1; Z <- 0; V <- 1; and C <- 0.