SPRUIE9D May 2017 – May 2024 DRA74P , DRA75P , DRA76P , DRA77P
Signed Division of Two Register Values
DIV src1, src2, dst
Functional unit = M
32 bit
| 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 | 15 | 13 | 12 | 10 | 9 | 7 | 6 | 0 |
| x | x | x | x | x | x | x | x | x | x | x | 0 | 1 | 0 | 0 | 1 | dst | src2 | src1 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | ||||||
| 3 | 3 | 3 | opcode | ||||||||||||||||||||||||||||
Signed division of src1 and src2 and store result to dst. Divide by 0 raises UNDEF interrupt, dst is written with 0, CSR:EQ gets set.
Using DIV (integer division) and SHRA (arithmetic right shift) does not produce the same result for negative numbers. The quotient of DIV is rounded towards zero, whereas the quotient of SHRA is rounded towards negative infinity. For example, using the DIV instruction: -9/4 = -2, whereas using the SHRA instruction: -9/4 = -3.
CSR:EQ = (dst == 0)
dst = src2 / src1 14 execute cycles. This is a blocking multi-execute cycle instruction.