IBM PPC440X5 Computer Hardware User Manual


 
divw
Divide Word
Preliminary PPC440x5 CPU Core User’s Manual
instrset.fm.
September 12, 2002 Page 307 of 589
divw
Divide Word
(RT) (RA) ÷ (RB)
The contents of register RA are divided by the contents of register RB. The quotient is placed into register RT.
Both the dividend and the divisor are interpreted as signed integers. The quotient is the unique signed integer
that satisfies:
dividend = (quotient × divisor) + remainder
where the remainder has the same sign as the dividend and its magnitude is less than that of the divisor.
If an attempt is made to perform (0x8000 0000 ÷ –1) or (n ÷ 0), the contents of register RT are undefined; if
the Rc field also contains 1, the contents of CR[CR0]
0:2
are undefined. Either invalid division operation sets
XER[OV, SO] (and CR[CR0]
3
if Rc contains 1) to 1 if the OE field contains 1.
Registers Altered
•RT
CR[CR0] if Rc contains 1
XER[OV, SO] if OE contains 1
Programming Note
The 32-bit remainder can be calculated using the following sequence of instructions:
divw RT,RA,RB # RT = quotient
mullw RT,RT,RB # RT = quotient × divisor
subf RT,RT,RA # RT = remainder
The sequence does not calculate correct results for the invalid divide operations.
divw RT, RA, RB OE=0, Rc=0
divw. RT, RA, RB OE=0, Rc=1
divwo RT, RA, RB OE=1, Rc=0
divwo. RT, RA, RB OE=1, Rc=1
31 RT RA RB OE 491 Rc
0 6 11 16 21 22 31