Bit results and related special behaviors

Language reference ›› Statements ›› Assignments and expressions ››
Parent Previous Next

Relations generate boolean-wide results (FALSE = 0, TRUE = 1).

PMP has a special internal Boolean accumulator / stack, so it can deal with pure Boolean operators.

A means to set/clear/test a bit within a variable also exists, through the "dot notation": the <identifier>.<bit> form allows the program to test or assign a single bit in any integer variable.  

<bit> is a numeric constant value or an identifier that was declared as a numeric constant and <identifier> may be either of type variable or constant.  

<bit> must be between 0 and the maximum bit number of the variable (7..31),  where 0 is the LSB.  For bit tests, if the bit is set, the factor evaluates as TRUE (1), else it evaluates as FALSE (0).


<variable>.<bit> := <expression>

<expression> is reduced to a BOOLEAN type (anything other than zero is considered as TRUE), the state of <bit> within <variable> will be set to match the outcome of <expression>.

Usually <bit> may be an integer literal or constant.

PMP allows referring to a boolean variable for <bit>; the code generated will use the bit number of the boolean variable. PMP does not check the pertinence of such construction…



VAR
 Input1: boolean @ PORTC.4;
...
 TRISC.Input1 := true; // set input mode for PORTC.4


Relations produce bit Booleans; the NOT instruction will invert a bit Boolean. For other types of variables, the NOT operator will invert the whole value so consider the differences:



VAR
 Bit1: Boolean;
 Byte1, Byte2: Byte;
...
 Bit1 := TRUE;       // single bit Boolean, set to 1 (Boolean true)
 Byte1 := Bit1;      // byte variable set to 1 (Boolean true)
 Byte2 := NOT Byte1; // byte variable set to $FE (NOT $01)
 Byte2 := NOT Bit1;  // byte variable set to 0 (NOT TRUE)