On this page:
shri
shli
sari
roti
shrr
shlr
sarr
rotr
shrp
shlp
sarp
rotp
shr
shl
sar

6 0111 - Shifter🔗

opcode

(shri n i)

 
n = bb68-gpr
 
  n : (integer-in 0 15)
  i : (integer-in 0 15)

image

 mask: ff00

value: 7000

This is a more general version of bsl which allows shifting register n to the left by i.

It uses bitwise/logical shift which shifts-in zeroes from the left.

opcode

(shli n i)

 
n = bb68-gpr
 
  n : (integer-in 0 15)
  i : (integer-in 0 15)

image

 mask: ff00

value: 7100

A more general version of bsr which shifts register n to the right by i.

opcode

(sari n i)

 
n = bb68-gpr
 
  n : (integer-in 0 15)
  i : (integer-in 0 15)

image

 mask: ff00

value: 7200

A generic version of sbsr which shifts register n to the right by i keeping the most significant (sign) bit intact.

opcode

(roti n i)

 
n = bb68-gpr
 
  n : (integer-in 0 15)
  i : (integer-in 0 15)

image

 mask: ff00

value: 7300

Rotates register n to the left by i.

Rotation to the right can be achieved by rotating by 16-1i to the left using this instruction.

opcode

(shrr n m)

 
n = bb68-gpr
     
m = bb68-gpr
 
  n : (integer-in 0 15)
  m : (integer-in 0 15)

image

 mask: ff00

value: 7400

Like shri but it is shifted by the value in register m. If m is greater than 15, the result is always 0.

opcode

(shlr n m)

 
n = bb68-gpr
     
m = bb68-gpr
 
  n : (integer-in 0 15)
  m : (integer-in 0 15)

image

 mask: ff00

value: 7500

Like shli but it is shifted by the value in register m. If m is greater than 15, the result is always 0.

opcode

(sarr n m)

 
n = bb68-gpr
     
m = bb68-gpr
 
  n : (integer-in 0 15)
  m : (integer-in 0 15)

image

 mask: ff00

value: 7600

Like shri but it is shifted by the value in register m. If m is greater than 15, the result is always 0 for nonnegative values of m and -1 for its negative values.

opcode

(rotr n m)

 
n = bb68-gpr
     
m = bb68-gpr
 
  n : (integer-in 0 15)
  m : (integer-in 0 15)

image

 mask: ff00

value: 7700

Rotates register n to the left by the value in register m modulo 16.

opcode

(shrp N i)

 
N = bb68-gprp
 
  N : (integer-in 0 7)
  i : (integer-in 0 31)

image

 mask: ff00

value: 7800

Shifts a pair of registers N to the right by i. This is a bitwise/logical shift which shifts-in zeroes from the left.

opcode

(shlp N i)

 
N = bb68-gprp
 
  N : (integer-in 0 7)
  i : (integer-in 0 31)

image

 mask: ff00

value: 7900

Shifts a pair of registers N to the left by i.

opcode

(sarp N i)

 
N = bb68-gprp
 
  N : (integer-in 0 7)
  i : (integer-in 0 31)

image

 mask: ff00

value: 7a00

Shifts a pair of registers N to the right by i. As an arithmetic shift it keeps the most significant bit (sign) intact.

opcode

(rotp N i)

 
N = bb68-gprp
 
  N : (integer-in 0 7)
  i : (integer-in 0 31)

image

 mask: ff00

value: 7b00

Rotates register pair N to the left by i.

Rotation to the right can be achieved by rotating by 32-1i to the left using this instruction.

macro opcode

(shr variant)

 
variant = r:bb68-gpr i:bb68-word
  | r:bb68-gpr q:bb68-gpr
  | p:bb68-gprp i:bb68-word
Shifts to the right either the register r by immediate value i, or the register r by the value in register q, or the register pair p by the immediate value i.

macro opcode

(shl variant)

 
variant = r:bb68-gpr i:bb68-word
  | r:bb68-gpr q:bb68-gpr
  | p:bb68-gprp i:bb68-word
Shifts to the left either the register r by immediate value i, or the register r by the value in register q, or the register pair p by the immediate value i.

macro opcode

(sar variant)

 
variant = r:bb68-gpr i:bb68-word
  | r:bb68-gpr q:bb68-gpr
  | p:bb68-gprp i:bb68-word
Shifts to the right either the register r by immediate value i, or the register r by the value in register q, or the register pair p by the immediate value i.

If the shift amount is greater than 15 for registers and 31 for pairs, the result is always 0 for nonnegative values of m and -1 for its negative values.