User guide
22
6000 Series Programmer's Guide
Using Binary Variables
The following examples illustrate the 6000 Series product's ability to perform bitwise
functions with binary variables.
Storing binary values. The 6000 Series Language allows you to store binary numbers
in the binary variables (VARB) command. The binary variables start at the left with the least
significant bit, and increase to the right. For example, to set bit 1, 5, and 7 you would issue
the command VARB1=b1xxx1x1. Notice that the letter b is required. When assigning a
binary value to a binary variable, only the bits specified are affected—all unspecified bits are
left in their current state.
Example Response
VARB1=b1101XX1 *VARB1=1101_XX1X_XXXX_XXXX_XXXX_XXXX_XXXX_XXXX
Storing hexadecimal values. Hexadecimal values can also be stored in binary variables
(VARB). The hexadecimal value must be specified the same as the binary value—left is least
significant byte, right is most significant. For example, to set bit 1, 5, and 7 you would
issue the command VARB1=h15. Notice that the letter h is required. NOTE: When
assigning a hexadecimal value to a binary variable, all unspecified bits are set to zero.
Example Response
VARB1=h7FAD
VARB1 *VARB1=1110_1111_0101_1011_0000_0000_0000_0000
Bitwise And (&)
Example Response
VARB1=b1101
VARB1 *VARB1=1101_XXXX_XXXX_XXXX_XXXX_XXXX_XXXX_XXXX
VARB1=VARB1 & bXXX1 1101
VARB1 *VARB1=XX01_XX0X_XXXX_XXXX_XXXX_XXXX_XXXX_XXXX
VARB1=h0032 FDA1 & h1234 43E9
VARB1 *VARB1=0000_0000_1100_0000_0010_1000_0101_1000
Bitwise Or (|)
Example Response
VARB1=h32FD
VARB1 *VARB1=1100_0100_1111_1011_0000_0000_0000_0000
VARB1=VARB1 | bXXX1 1101
VARB1 *VARB1=11X1_1101_1111_1X11_XXXX_XXXX_XXXX_XXXX
VARB1=h0032 FDA1 | h1234 43E9
VARB1 *VARB1=1000_0100_1100_0110_1111_1111_0111_1001
Bitwise Exclusive
Or (^)
Example Response
VARB1=h32FD ^ bXXX1 1101
VARB1 *VARB1=XXX1_1001_XXXX_XXXX_XXXX_XXXX_XXXX_XXXX
VARB1=h0032 FDA1 ^ h1234 43E9
VARB1 *VARB1=1000_0100_0000_0110_1101_0111_0010_0001
Bitwise Not (~)
Example Response
VARB1=~(h32FD)
VARB1 *VARB1=0011_1011_0000_0100_1111_1111_1111_1111
VARB1=~(b1010 XX11 0101)
VARB1 *VARB1=0101_XX00_1010_XXXX_XXXX_XXXX_XXXX_XXXX
Shift Left to Right
(>>)
Example Response
VARB1=h32FD >> h4
VARB1 *VARB1=0000_1100_0100_1111_1011_0000_0000_0000
VARB1=b1010 XX11 0101 >> b11
VARB1 *VARB1=0001_010X_X110_101X_XXXX_XXXX_XXXX_XXXX
Shift Right to Left
(<<)
Example Response
VARB1=h32FD << h4
VARB1 *VARB1=0100_1111_1011_0000_0000_0000_0000_0000
VARB1=b1010 XX11 0101 << b11
VARB1 *VARB1=0XX1_1010_1XXX_XXXX_XXXX_XXXX_XXXX_X000










