Rotate Left Word Immediate then AND with Mask

M-Form

  • rlwinm RA,RS,SH,MB,ME (Rc=0)
  • rlwinm. RA,RS,SH,MB,ME (Rc=1)

Pseudo-code:

n <- SH
r <- ROTL32((RS)[XLEN/2:XLEN-1], n)
m <- MASK32(MB, ME)
RA <- r & m

Special Registers Altered:

CR0                    (if Rc=1)

Rotate Left Word then AND with Mask

M-Form

  • rlwnm RA,RS,RB,MB,ME (Rc=0)
  • rlwnm. RA,RS,RB,MB,ME (Rc=1)

Pseudo-code:

n <- (RB)[XLEN-5:XLEN-1]
r <- ROTL32((RS)[XLEN/2:XLEN-1], n)
m <- MASK32(MB, ME)
RA <- r & m

Special Registers Altered:

CR0                    (if Rc=1)

Rotate Left Word Immediate then Mask Insert

M-Form

  • rlwimi RA,RS,SH,MB,ME (Rc=0)
  • rlwimi. RA,RS,SH,MB,ME (Rc=1)

Pseudo-code:

n <- SH
r <- ROTL32((RS)[XLEN/2:XLEN-1], n)
m <- MASK32(MB, ME)
RA <- r&m | (RA) & ¬m

Special Registers Altered:

CR0                    (if Rc=1)

Rotate Left Doubleword Immediate then Clear Left

MD-Form

  • rldicl RA,RS,sh,mb (Rc=0)
  • rldicl. RA,RS,sh,mb (Rc=1)

Pseudo-code:

n <- sh
r <- ROTL64((RS), n)
b <- mb[5] || mb[0:4]
m <- MASK(b, (XLEN-1))
RA <- r & m

Special Registers Altered:

CR0                    (if Rc=1)

Rotate Left Doubleword Immediate then Clear Right

MD-Form

  • rldicr RA,RS,sh,me (Rc=0)
  • rldicr. RA,RS,sh,me (Rc=1)

Pseudo-code:

n <- sh
r <- ROTL64((RS), n)
e <- me[5] || me[0:4]
m <- MASK(0, e)
RA <- r & m

Special Registers Altered:

CR0                    (if Rc=1)

Rotate Left Doubleword Immediate then Clear

MD-Form

  • rldic RA,RS,sh,mb (Rc=0)
  • rldic. RA,RS,sh,mb (Rc=1)

Pseudo-code:

n <- sh
r <- ROTL64((RS), n)
b <- mb[5] || mb[0:4]
m <- MASK(b,  ¬n)
RA <- r & m

Special Registers Altered:

CR0                    (if Rc=1)

Rotate Left Doubleword then Clear Left

MDS-Form

  • rldcl RA,RS,RB,mb (Rc=0)
  • rldcl. RA,RS,RB,mb (Rc=1)

Pseudo-code:

n <- (RB)[XLEN-5:XLEN-1]
r <- ROTL64((RS), n)
b <- mb[5] || mb[0:4]
m <- MASK(b, (XLEN-1))
RA <- r & m

Special Registers Altered:

CR0                    (if Rc=1)

Rotate Left Doubleword then Clear Right

MDS-Form

  • rldcr RA,RS,RB,me (Rc=0)
  • rldcr. RA,RS,RB,me (Rc=1)

Pseudo-code:

n <- (RB)[XLEN-5:XLEN-1]
r <- ROTL64((RS), n)
e <- me[5] || me[0:4]
m <- MASK(0, e)
RA <- r & m

Special Registers Altered:

CR0                    (if Rc=1)

Rotate Left Doubleword Immediate then Mask Insert

MD-Form

  • rldimi RA,RS,sh,mb (Rc=0)
  • rldimi. RA,RS,sh,mb (Rc=1)

Pseudo-code:

n <- sh
r <- ROTL64((RS), n)
b <- mb[5] || mb[0:4]
m <- MASK(b,  ¬n)
RA <- r&m | (RA)& ¬m

Special Registers Altered:

CR0                    (if Rc=1)

Shift Left Word

X-Form

  • slw RA,RS,RB (Rc=0)
  • slw. RA,RS,RB (Rc=1)

Pseudo-code:

n <- (RB)[XLEN-5:XLEN-1]
r <- ROTL32((RS)[XLEN/2:XLEN-1], n)
if (RB)[XLEN-6] = 0 then
     m <- MASK32(0, ((XLEN/2)-1-n))
else m <- [0]*XLEN
RA <- r & m

Special Registers Altered:

CR0                    (if Rc=1)

Shift Right Word

X-Form

  • srw RA,RS,RB (Rc=0)
  • srw. RA,RS,RB (Rc=1)

Pseudo-code:

n <- (RB)[XLEN-5:XLEN-1]
r <- ROTL32((RS)[XLEN/2:XLEN-1], XLEN-n)
if (RB)[XLEN-6] = 0 then
    m <- MASK32(n, ((XLEN/2)-1))
else m <- [0]*XLEN
RA <- r & m

Special Registers Altered:

CR0                    (if Rc=1)

Shift Right Algebraic Word Immediate

X-Form

  • srawi RA,RS,SH (Rc=0)
  • srawi. RA,RS,SH (Rc=1)

Pseudo-code:

n <- SH
r <- ROTL32((RS)[XLEN/2:XLEN-1], 64-n)
m <- MASK32(n, ((XLEN/2)-1))
s <- (RS)[XLEN/2]
RA <- r&m | ([s]*XLEN)& ¬m
carry <- s & ((r&¬m)[XLEN/2:XLEN-1] != 0)
CA    <- carry
CA32  <- carry

Special Registers Altered:

CA CA32
CR0                    (if Rc=1)

Shift Right Algebraic Word

X-Form

  • sraw RA,RS,RB (Rc=0)
  • sraw. RA,RS,RB (Rc=1)

Pseudo-code:

n <- (RB)[XLEN-5:XLEN-1]
r <- ROTL32((RS)[XLEN/2:XLEN-1], XLEN-n)
if (RB)[XLEN-6] = 0 then
    m <- MASK32(n, ((XLEN/2)-1))
else m <- [0]*XLEN
s <- (RS)[XLEN/2]
RA <- r&m | ([s]*XLEN)& ¬m
carry <-  s & ((r&¬m)[XLEN/2:XLEN-1] != 0)
CA    <-  carry
CA32  <-  carry

Special Registers Altered:

CA CA32
CR0                    (if Rc=1)

Shift Left Doubleword

X-Form

  • sld RA,RS,RB (Rc=0)
  • sld. RA,RS,RB (Rc=1)

Pseudo-code:

n <- (RB)[XLEN-6:XLEN-1]
r <- ROTL64((RS), n)
if (RB)[XLEN-7] = 0 then
     m <- MASK(0, XLEN-1-n)
else m <- [0]*XLEN
RA <- r & m

Special Registers Altered:

CR0                    (if Rc=1)

Shift Right Doubleword

X-Form

  • srd RA,RS,RB (Rc=0)
  • srd. RA,RS,RB (Rc=1)

Pseudo-code:

n <- (RB)[XLEN-6:XLEN-1]
r <- ROTL64((RS), XLEN-n)
if (RB)[XLEN-7] = 0 then
    m <-  MASK(n, (XLEN-1))
else m <- [0]*XLEN
RA <- r & m

Special Registers Altered:

CR0                    (if Rc=1)

Shift Right Algebraic Doubleword Immediate

XS-Form

  • sradi RA,RS,sh (Rc=0)
  • sradi. RA,RS,sh (Rc=1)

Pseudo-code:

n <- sh
r <- ROTL64((RS), XLEN-n)
m <- MASK(n, (XLEN-1))
s <- (RS)[0]
RA <- r&m | ([s]*XLEN)& ¬m
carry <- s & ((r& ¬m) != 0)
CA    <- carry
CA32  <- carry

Special Registers Altered:

CA CA32
CR0                    (if Rc=1)

Shift Right Algebraic Doubleword

X-Form

  • srad RA,RS,RB (Rc=0)
  • srad. RA,RS,RB (Rc=1)

Pseudo-code:

n <- (RB)[XLEN-6:XLEN-1]
r <- ROTL64((RS), XLEN-n)
if (RB)[XLEN-7] = 0 then
    m <-  MASK(n, (XLEN-1))
else m <- [0]*XLEN
s <- (RS)[0]
RA <- r&m | ([s]*XLEN)& ¬m
carry <-  s & ((r&¬m) != 0)
CA    <-  carry
CA32  <-  carry

Special Registers Altered:

CA CA32
CR0                    (if Rc=1)

Extend-Sign Word and Shift Left Immediate

XS-Form

  • extswsli RA,RS,sh (Rc=0)
  • extswsli. RA,RS,sh (Rc=1)

Pseudo-code:

n  <- sh
r  <- ROTL64(EXTS64(RS[XLEN/2:XLEN-1]), n)
m  <- MASK(0, XLEN-1-n)
RA <- r & m

Special Registers Altered:

CR0                     (if Rc=1)