This document intends to shed some light on the way binary variables are handled in the 6K programming language. Binary variables follow three basic rules:
- Math operations (i.e. + , - , * , / , = , etc.) treat binary variables as 32 bit numbers. This means that all 32 bits are affected by any math operation done to a binary variable. See the truth table below for examples.
NOTE: This means that bits previously set as a "don't care" ('X') will get set to a 1 or a 0 as appropriate to the math operation result.
- Logical operations (i.e. & , | , <> , etc.) treat binary variables as 32 bits. This means that the operation is done bit-wise (bit by bit and only on the bits specified by the operation). See the truth table below for examples.
NOTE: The 6K language will not make assumptions about any "don't care" ('X') bits contained within the binary variable. If the operation's result cannot be determined because of a "don't care" bit, the result will be a "don't care".
Two examples are:
VARB3 ends up with a 1 as the first bit.
In the first example, the 6K knows that since VARB1=B1 the OR operation will be TRUE = 1.
VARB3 ends up with an X as the first bit.
In the second example, the 6K does not have enough information to evaluate it so the result is an X.
- Conditionals will always evaluate a "don't care" bit ('X') as true. Three examples are:
IF(VARB1=BX) will always evaluate as TRUE.
IF(VARB1=B1) will also always evaluate as TRUE since you are comparing a 1 against a don't care.
IF(VARB1=BX0) will evaluate as FALSE. The first bit evaluated as TRUE but the comparison of the second bit evaluated as FALSE. Multiple bit comparisons are ANDed.
|0||0||| (OR)||0XXX_XXXX_XXXX_XXXX_ XXXX_XXXX_XXXX_XXXX|
|0||0||& (AND)||0XXX_XXXX_XXXX_XXXX_ XXXX_XXXX_XXXX_XXXX|
|0||1||| (OR)||1XXX_XXXX_XXXX_XXXX_ XXXX_XXXX_XXXX_XXXX|
|0||1||& (AND)||0XXX_XXXX_XXXX_XXXX_ XXXX_XXXX_XXXX_XXXX|
|1||0||| (OR)||1XXX_XXXX_XXXX_XXXX_ XXXX_XXXX_XXXX_XXXX|
|1||0||& (AND)||0XXX_XXXX_XXXX_XXXX_ XXXX_XXXX_XXXX_XXXX|
|1||1||| (OR)||1XXX_XXXX_XXXX_XXXX_ XXXX_XXXX_XXXX_XXXX|
|1||1||& (AND)||1XXX_XXXX_XXXX_XXXX_ XXXX_XXXX_XXXX_XXXX|
|0||X||| (OR)||XXXX_XXXX_XXXX_XXXX_ XXXX_XXXX_XXXX_XXXX|
|0||X||& (AND)||0XXX_XXXX_XXXX_XXXX_ XXXX_XXXX_XXXX_XXXX|
|X||0||| (OR)||XXXX_XXXX_XXXX_XXXX_ XXXX_XXXX_XXXX_XXXX|
|X||0||& (AND)||0XXX_XXXX_XXXX_XXXX_ XXXX_XXXX_XXXX_XXXX|
|1||X||| (OR)||1XXX_XXXX_XXXX_XXXX_ XXXX_XXXX_XXXX_XXXX|
|1||X||& (AND)||XXXX_XXXX_XXXX_XXXX_ XXXX_XXXX_XXXX_XXXX|
|X||1||| (OR)||1XXX_XXXX_XXXX_XXXX_ XXXX_XXXX_XXXX_XXXX|
|X||1||& (AND)||XXXX_XXXX_XXXX_XXXX_ XXXX_XXXX_XXXX_XXXX|
|X||X||| (OR)||XXXX_XXXX_XXXX_XXXX_ XXXX_XXXX_XXXX_XXXX|
|X||X||& (AND)||XXXX_XXXX_XXXX_XXXX_ XXXX_XXXX_XXXX_XXXX|