Pseudocode:
```
- prod[0:127] <- (RA) * (RB) # Multiply RA and RB, result 128-bit
- sum[0:127] <- EXTZ(RC) + prod # Zero extend RC, add product
- RT <- sum[64:127] # Store low half in RT
- RS <- sum[0:63] # RS implicit register, equal to RC
+prod[0:127] <- (RA) * (RB) # Multiply RA and RB, result 128-bit
+sum[0:127] <- EXTZ(RC) + prod # Zero extend RC, add product
+RT <- sum[64:127] # Store low half in RT
+RS <- sum[0:63] # RS implicit register, equal to RC
```
Special registers altered:
Pseudo-code:
- if ((RA) <u (RB)) & ((RB) != [0]*XLEN) then # Check RA<RB, for divide-by-0
- dividend[0:(XLEN*2)-1] <- (RA) || (RC) # Combine RA/RC, zero extend
- divisor[0:(XLEN*2)-1] <- [0]*XLEN || (RB) # Extend to 128-bit
- result <- dividend / divisor # Division
- modulo <- dividend % divisor # Modulo
- RT <- result[XLEN:(XLEN*2)-1] # Store result in RT
- RS <- modulo[XLEN:(XLEN*2)-1] # Modulo in RC, implicit
- else # In case of error
- RT <- [1]*XLEN # RT all 1's
- RS <- [0]*XLEN # RS all 0's
+```
+if ((RA) <u (RB)) & ((RB) != [0]*XLEN) then # Check RA<RB, for divide-by-0
+ dividend[0:(XLEN*2)-1] <- (RA) || (RC) # Combine RA/RC, zero extend
+ divisor[0:(XLEN*2)-1] <- [0]*XLEN || (RB) # Extend to 128-bit
+ result <- dividend / divisor # Division
+ modulo <- dividend % divisor # Modulo
+ RT <- result[XLEN:(XLEN*2)-1] # Store result in RT
+ RS <- modulo[XLEN:(XLEN*2)-1] # Modulo in RC, implicit
+else # In case of error
+ RT <- [1]*XLEN # RT all 1's
+ RS <- [0]*XLEN # RS all 0's
+```
Special registers altered:
instructions. `cmpi` will need to be used to detect overflow conditions:
the saving in instruction count is that both RT and RS will have already
been set to useful values (all 1s and all zeros respectively)
-needed as part of implementing Knuth's
-Algorithm D*
+needed as part of implementing Knuth's Algorithm D*
For Scalar usage, just as for `maddedu`, `RS=RC`
Examples: