m <- sm + 1
RT <- (n[m:XLEN-1] || [0]*m) + (RA)
+Pseudo-code (shaddw):
+
+ shift <- sm + 1 # Shift is between 1-4
+ n <- EXTS((RB)[XLEN/2:XLEN-1]) # Only use lower XLEN/2-bits of RB
+ RT <- (n << shift) + (RA) # Shift n, add RA
+
Pseudo-code (shadduw):
n <- ([0]*(XLEN/2)) || (RB)[XLEN/2:XLEN-1]
return (RB << (sm+1)) + RA;
}
+uint_xlen_t shaddw(uint_xlen_t RA, uint_xlen_t RB, uint8_t sm) {
+ uint_xlen_t n = (int_xlen_t)(RB << XLEN / 2) >> XLEN / 2;
+ sm = sm & 0x3;
+ return (n << (sm+1)) + RA;
+}
+
uint_xlen_t shadduw(uint_xlen_t RA, uint_xlen_t RB, uint8_t sm) {
uint_xlen_t n = RB & 0xFFFFFFFF;
sm = sm & 0x3;