AND Immediate

D-Form

  • andi. RA,RS,UI

Pseudo-code:

RA <- (RS) & EXTZ(UI)

Special Registers Altered:

CR0

OR Immediate

D-Form

  • ori RA,RS,UI

Pseudo-code:

RA <- (RS) | EXTZ(UI)

Special Registers Altered:

None

AND Immediate Shifted

D-Form

  • andis. RA,RS,UI

Pseudo-code:

RA <- (RS) & EXTZ(UI || [0]*16)

Special Registers Altered:

CR0

OR Immediate Shifted

D-Form

  • oris RA,RS,UI

Pseudo-code:

RA <- (RS) | EXTZ(UI || [0]*16)

Special Registers Altered:

None

XOR Immediate Shifted

D-Form

  • xoris RA,RS,UI

Pseudo-code:

RA <- (RS) ^ EXTZ(UI || [0]*16)

Special Registers Altered:

None

XOR Immediate

D-Form

  • xori RA,RS,UI

Pseudo-code:

RA <- (RS) ^ EXTZ(UI)

Special Registers Altered:

None

AND

X-Form

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

Pseudo-code:

RA <- (RS) & (RB)

Special Registers Altered:

CR0                    (if Rc=1)

OR

X-Form

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

Pseudo-code:

RA <- (RS) | (RB)

Special Registers Altered:

CR0                    (if Rc=1)

XOR

X-Form

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

Pseudo-code:

RA <- (RS) ^ (RB)

Special Registers Altered:

CR0                    (if Rc=1)

NAND

X-Form

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

Pseudo-code:

RA <- ¬((RS) & (RB))

Special Registers Altered:

CR0                    (if Rc=1)

NOR

X-Form

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

Pseudo-code:

RA <- ¬((RS) | (RB))

Special Registers Altered:

CR0                    (if Rc=1)

Equivalent

X-Form

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

Pseudo-code:

RA <- ¬((RS) ^ (RB))

Special Registers Altered:

CR0                    (if Rc=1)

AND with Complement

X-Form

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

Pseudo-code:

RA <- (RS) &  ¬(RB)

Special Registers Altered:

CR0                    (if Rc=1)

OR with Complement

X-Form

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

Pseudo-code:

RA <- (RS) |  ¬(RB)

Special Registers Altered:

CR0                    (if Rc=1)

Extend Sign Byte

X-Form

  • extsb RA,RS (Rc=0)
  • extsb. RA,RS (Rc=1)

Pseudo-code:

RA <- EXTSXL(RS, XLEN/8)

Special Registers Altered:

CR0                    (if Rc=1)

Extend Sign Halfword

X-Form

  • extsh RA,RS (Rc=0)
  • extsh. RA,RS (Rc=1)

Pseudo-code:

RA <- EXTSXL(RS, XLEN/4)

Special Registers Altered:

CR0                    (if Rc=1)

Count Leading Zeros Word

X-Form

  • cntlzw RA,RS (Rc=0)
  • cntlzw. RA,RS (Rc=1)

Pseudo-code:

n <- (XLEN/2)
do while n < XLEN
   if (RS)[n] = 1 then
       leave
   n <- n + 1
RA <- n - (XLEN/2)

Special Registers Altered:

CR0                    (if Rc=1)

Count Trailing Zeros Word

X-Form

  • cnttzw RA,RS (Rc=0)
  • cnttzw. RA,RS (Rc=1)

Pseudo-code:

n <- 0
do while n < XLEN/2
   if (RS)[XLEN-1-n] = 0b1 then
        leave
   n  <- n + 1
RA <- EXTZ(n)

Special Registers Altered:

CR0                    (if Rc=1)

Compare Bytes

X-Form

  • cmpb RA,RS,RB

Pseudo-code:

do n = 0 to ((XLEN/8)-1)
    if RS[8*n:8* n+7] = (RB)[8*n:8*n+7] then
       RA[8*n:8* n+7] <- [1]*8
    else
       RA[8*n:8* n+7] <- [0]*8

Special Registers Altered:

None

Population Count Bytes

X-Form

  • popcntb RA,RS

Pseudo-code:

do i = 0 to ((XLEN/8)-1)
   n <-  0
   do j = 0 to 7
      if (RS)[(i*8)+j] = 1 then
          n <- n+1
   RA[(i*8):(i*8)+7] <-  n

Special Registers Altered:

None

Population Count Words

X-Form

  • popcntw RA,RS

Pseudo-code:

e <- (XLEN/2)-1
do i = 0 to 1
   s <- i*XLEN/2
   n <-  0
   do j = 0 to e
      if (RS)[s+j] = 1 then
          n <- n+1
   RA[s:s+e] <- n

Special Registers Altered:

None

Parity Doubleword

X-Form

  • prtyd RA,RS

Pseudo-code:

s <- 0
do i = 0 to ((XLEN/8)-1)
    s <- s ^ (RS)[i*8+7]
RA <- [0] * (XLEN-1) || s

Special Registers Altered:

None

Parity Word

X-Form

  • prtyw RA,RS

Pseudo-code:

s <- 0
t <- 0
do i = 0 to ((XLEN/8/2)-1)
    s <-  s ^ (RS)[i*8+7]
do i = 4 to ((XLEN/8)-1)
    t <-  t ^ (RS)[i*8+7]
RA[0:(XLEN/2)-1] <- [0]*((XLEN/2)-1) || s
RA[XLEN/2:XLEN-1] <- [0]*((XLEN/2)-1) || t

Special Registers Altered:

None

Extend Sign Word

X-Form

  • extsw RA,RS (Rc=0)
  • extsw. RA,RS (Rc=1)

Pseudo-code:

RA <- EXTSXL(RS, XLEN/2)

Special Registers Altered:

CR0                    (if Rc=1)

Population Count Doubleword

X-Form

  • popcntd RA,RS

Pseudo-code:

n <- 0
do i = 0 to (XLEN-1)
   if (RS)[i] = 1 then
       n <-  n+1
RA <- n

Special Registers Altered:

None

Count Leading Zeros Doubleword

X-Form

  • cntlzd RA,RS (Rc=0)
  • cntlzd. RA,RS (Rc=1)

Pseudo-code:

n <- 0
do while n < XLEN
  if (RS)[n]  = 1 then
     leave
  n <- n + 1
RA <- n

Special Registers Altered:

CR0                    (if Rc=1)

Count Trailing Zeros Doubleword

X-Form

  • cnttzd RA,RS (Rc=0)
  • cnttzd. RA,RS (Rc=1)

Pseudo-code:

n  <- 0
do while n < XLEN
   if (RS)[XLEN-1-n] = 0b1 then
        leave
   n  <- n + 1
RA <- EXTZ(n)

Special Registers Altered:

CR0                    (if Rc=1)

Count Leading Zeros Doubleword under bit Mask

X-Form

  • cntlzdm RA,RS,RB

Pseudo-code:

count <- 0
do i = 0 to 63
    if (RB)[i] = 1 then
        if (RS)[i] = 1 then leave
        count <- count + 1
RA <- EXTZ64(count)

Special Registers Altered:

None

Count Trailing Zeros Doubleword under bit Mask

X-Form

  • cnttzdm RA,RS,RB

Pseudo-code:

count <- 0
do i = 0 to 63
    if (RB)[63-i] = 1 then
        if (RS)[63-i] = 1 then leave
        count <- count + 1
RA <- EXTZ64(count)

Special Registers Altered:

None

Bit Permute Doubleword

X-Form

  • bpermd RA,RS,RB

Pseudo-code:

perm <- [0] * (XLEN/8)
for i = 0 to ((XLEN/8)-1)
   index <- (RS)[8*i:8*i+7]
   if index <u XLEN then
        perm[i] <- (RB)[index]
   else
        perm[i] <- 0
RA <- [0]*(XLEN*7/8) || perm

Special Registers Altered:

None

Centrifuge Doubleword

X-Form

  • cfuged RA,RS,RB

Pseudo-code:

ptr0 <- 0
ptr1 <- 0
result[0:63] <- 0
do i = 0 to 63
    if (RB)[i] = 0 then
        result[ptr0] <- (RS)[i]
        ptr0 <- ptr0 + 1
    if (RB)[63-i] = 1 then
        result[63-ptr1] <- (RS)[63-i]
        ptr1 <- ptr1 + 1
RA <- result

Special Registers Altered:

None

Parallel Bits Extract Doubleword

X-Form

  • pextd RA,RS,RB

Pseudo-code:

result[0:63] <- 0
mask <- (RB)
m <- 0
k <- 0
do while m < 64
    if (RB)[63-m] = 1 then
        result[63-k] <- (RS)[63-m]
        k <- k + 1
    m <- m + 1
RA <- result

Special Registers Altered:

None

Parallel Bits Deposit Doubleword

X-Form

  • pdepd RA,RS,RB

Pseudo-code:

result[0:63] <- 0
mask <- (RB)
m <- 0
k <- 0
do while m < 64
    if (RB)[63-m] = 1 then
        result[63-m] <- (RS)[63-k]
        k <- k + 1
    m <- m + 1
RA <- result

Special Registers Altered:

None