Renesas R8C/Tiny Series Software Manual page 286

16-bit single-chip microcomputer
Hide thumbs Also See for R8C/Tiny Series:
Table of Contents

Advertisement

Q
What is the difference between the DIV instruction and the DIVX instruction?
A
Either of the DIV instruction and the DIVX instruction is an instruction for signed division, the sign of
the remainder is different.
The sign of the remainder left after the DIV instruction is the same as that of the dividend, on the
contrary, the sign of the remainder of the DIVX instruction is the same as that of the divisor.
In general, the following relation among quotient, divisor, dividend, and remainder holds.
dividend = divisor
Since the sign of the remainder is different between these instructions, the quotient obtained either
by dividing a positive integer by a negative integer or by dividing a negative integer by a positive
integer using the DIV instruction is different from that obtained using the DIVX instruction.
For example, dividing 10 by –3 using the DIV instruction yields –3 and leaves +1, while doing the
same using the DIVX instruction yields –4 and leaves –2.
Dividing –10 by +3 using the DIV instruction yields –3 and leaves –1, while doing the same using the
DIVX instruction yields –4 and leaves +2.
quotient + remainder
Q&A-6
CPU

Advertisement

Table of Contents
loading

Table of Contents