{LET} Variable = {Value} {Op} Value

Assign a Value or result of an expression to Variable.

LET is an optional keyword an not typcially used. For example,

  LET idx = 25 

... produces the same compiled output as:

  idx = 25 

so using LET is of no advantage. Note that when assigning a bit variable the value of a byte variable, the bit variable will be set to zero if the byte variable is zero, otherwise it will be set to one.

  myByte = 0
  myBit = myByte                                ' myBit = 0
  myByte = 4
  myBit = myByte                                ' myBit = 1

Using Operators in Assignments
Note that SX/B supports only simple expressions, that is, just one operator per line of code. The following line will produce an error:

  idx = count / 2 + 1                           ' illegal in SX/B! 

The error is corrected by splitting the operators across separate lines:

  idx = count / 2                               ' okay now
  idx = idx + 1

The tables below show available operators for SX/B assignments:

Unary Operator Definition
-  Negate
~  Bitwise inversion
NOT  Bitwise inversion

Binary Operator Definition
+  Addition
-  Subtraction
*  Multiplication
/  Division
//  Modulus
*/  Multiply, return middle 16 bits
**  Multiply, return upper 16 bits
MAX  Set Maximum
MIN  Set Minimum
&  Bitwise AND
AND  Bitwise AND
|  Bitwise OR
OR  Bitwise OR
^  Bitwise Exclusive OR
XOR  Bitwise Exclusive OR
<<  Shift Left
SHL  Shift Left
>>  Shift Right
SHR  Shift Right

See the Operaters section for details.

Configuration Registers
When assigning values to SX configuration registers, the format is limited to:

  {LET} Register = Value

When assigning values to the special registers WKPND_B and CMP_B a variable must be used and that variable will be exchanged with the SX register.

  {LET} Register = ByteVar

  WKPND_B = wakeUp                              ' WKPND_B exchanged with wakeUp
  CMP_B = analog                                ' CMP_B exchanged with analog