Propeller Manual

Table Of Contents
Operators – Spin Language Reference
Since the nature of binary is base-2, shifting a value right is like performing an integer divide
of that value by powers of two, 2
b
, where b is the number of bits shifted.
Bitwise Shift Right has an assignment form,
>>=, that uses the variable to its left as both the
first operand and the result destination. For example,
X >>= 2 'Short form of X := X >> 2
Here, the value of X is shifted right two bits and is stored back in X. The assignment form of
Bitwise Shift Right may also be used within expressions for intermediate results; see
Intermediate Assignments, page 147.
Bitwise Rotate Left ‘
<-’, ‘<-=
The Bitwise Rotate Left operator is similar to the Bitwise Shift Left operator, except that the
MSBs (leftmost bits) are rotated back around to the LSBs (rightmost bits). Bitwise Rotate
Left can be used in both variable and integer constant expressions, but not in floating-point
constant expressions. Example:
X := Y <- 4
If Y started out as:
%10000000 01110000 11111111 00110101
the Bitwise Rotate Left operator would rotate that value left by four bits, moving the original
four MSBs to the four new LSBs, and setting
X to:
%00000111 00001111 11110011 01011000
Bitwise Rotate Left has an assignment form,
<-=, that uses the variable to its left as both the
first operand and the result destination. For example,
X <-= 1 'Short form of X := X <- 1
Here, the value of X is rotated left one bit and is stored back in X. The assignment form of
Bitwise Rotate Left may also be used within expressions for intermediate results; see
Intermediate Assignments, page 147.
Bitwise Rotate Right ‘
->’, ‘->=
The Bitwise Rotate Right operator is similar to the Bitwise Shift Right operator, except that
the LSBs (rightmost bits) are rotated back around to the MSBs (leftmost bits). Bitwise Rotate
Right can be used in both variable and integer constant expressions, but not in floating-point
constant expressions. Example:
Page 162 · Propeller Manual v1.1