Renesas R8C/Tiny Series Software Manual page 287

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
The DIV instruction and the DIVX instruction are both instructions for signed division, but 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, but 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 a remainder of +1,
while doing the same using the DIVX instruction yields –4 and leaves a remainder of –2.
Dividing –10 by +3 using the DIV instruction yields –3 and leaves a remainder of –1, while doing the
same using the DIVX instruction yields –4 and leaves a remainder of +2.
quotient + remainder
Q&A-6
CPU

Advertisement

Table of Contents
loading

Table of Contents