modsw
Modulo Signed Word
modsw RT, RA, RB
Calculates remainder of signed word division.
Encoding
Binary Layout
31
0:5
RT
6:10
RA
11:15
RB
16:20
779
21:30
/
31
Operands
-
RT
Target -
RA
Dividend -
RB
Divisor
Example
modsw r3, r4, r5
Related
More in Base
Reference
View in PowerISA v3.1C Specification ↗
OPF Power ISA v3.1C
Description
The 32-bit dividend is (RA)32:63. The 32-bit divisor is (RB)32:63. The 32-bit remainder of the dividend divided by the divisor is placed into RT32:63. The contents of RT0:31 are undefined.
Operation
dividend = (RA)32:63
divisor = (RB)32:63
if dividend >= 0 then
quotient = floor(dividend / divisor)
else
quotient = ceil(dividend / divisor)
RT32:63 <- dividend - (quotient * divisor)
RT0:31 <- undefined
Programming Note
If an attempt is made to perform any of the divisions 0x8000_0000 % -1 or <anything> % 0, then the contents of register RT are undefined.