Advertisement
Dwack

Shift Right Algebraic Word Immediate

Jun 17th, 2012
267
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.38 KB | None | 0 0
  1. int SRAWI(int RS, int SH)
  2. {
  3.     // n <- SH
  4.     int n = SH;
  5.     // r <- ROTL32((RS)32:63, 64-n)
  6.     int r = (RS << (32-n))|(RS >> (32 - (32-n)));
  7.     // m <- MASK(n+32, 63)
  8.     u32 m = GenerateMask32(n, 31);
  9.     // s <- (RS)32
  10.     // if bit 0 == 1 fill s with all 1's
  11.     // else s is all 0's
  12.     u32 s = ((RS & 0x80000000) == 0x80000000) ? -1:0;
  13.     // RA <- r&m | s&~m
  14.     int RA = r&m | s&~m;
  15.     return RA;
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement