EasyManua.ls Logo

Parallax BASIC Stamp 2e - Reverse (REV); And (&)

Default Icon
353 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
4: BASIC Stamp Architecture REV, &, |
BASIC Stamp Programming Manual 2.0c www.parallaxinc.com Page 73
value right n number of times has the same effect as dividing that number
by 2 to the n
th
power. For instance 100 >> 3 (shift the bits of the decimal
number 100 right three places) is equivalent to 100 / 2
3
. Here's an example:
Value VAR WORD
Idx VAR BYTE
Value = %1111111111111111
FOR Idx = 1 TO 16 ' Repeat with Idx = 1 to 16.
DEBUG BIN ? Value >> Idx ' Shift Value right Idx places.
NEXT
The Reverse operator (REV) returns a reversed (mirrored) copy of a
specified number of bits of a value, starting with the rightmost bit (lsb).
For instance, %10101101 REV 4 would return %1011, a mirror image of the
first four bits of the value. Example:
DEBUG BIN ? %11001011 REV 4 ' Mirror 1st 4 bits (%1101)
The And operator (&) returns the bitwise AND of two values. Each bit of
the values is subject to the following logic:
0 AND 0 = 0
0 AND 1 = 0
1 AND 0 = 0
1 AND 1 = 1
The result returned by & will contain 1s in only those bit positions in
which both input values contain 1s. Example:
SYMBOL Value1 = B0
SYMBOL Value2 = B1
SYMBOL Result = B2
Value1 = %00001111
Value2 = %10101101
Result = Value1 & Value2
DEBUG %Result ' Show AND result (%00001101)
-- or --
DEBUG BIN ? %00001111 & %10101101 ' Show AND result (%00001101)
The OR operator (|) returns the bitwise OR of two values. Each bit of the
values is subject to the following logic:
2
e
2
sx
2
p
2
2
e
2
sx
2
p
2
1
REVERSE
: REV
AND
: &
OR: |
1
2
e
2
sx
2
p
2
1
2
e
2
sx
2
p
2

Table of Contents

Related product manuals