11.07.2015 Views

PICBASIC PLUS LITE Manual - Profe Saul

PICBASIC PLUS LITE Manual - Profe Saul

PICBASIC PLUS LITE Manual - Profe Saul

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

4.8. Bitwise operators.<strong>PICBASIC</strong> <strong>PLUS</strong> Compiler4.9. And ‘&’The And operator (&) returns the bitwise AND of two values. Each bit of the values issubject to the following logic: -0 AND 0 = 00 AND 1 = 01 AND 0 = 01 AND 1 = 1The result returned by & will contain 1s in only those bit positions in which both inputvalues contain 1s: -DIM Value1 as BYTEDIM Value2 as BYTEDIM Result as BYTEValue1 = %00001111Value2 = %10101101Result = Value1 & Value2PRINT bin Result ' Display AND result (%00001101)orPRINT bin ( %00001111 & %10101101 ) ' Display AND result (%00001101)4.10. Or ‘|’The OR operator (|) returns the bitwise OR of two values. Each bit of the values is subjectto the following logic: -0 OR 0 = 00 OR 1 = 11 OR 0 = 11 OR 1 = 1The result returned by | will contain 1s in any bit positions in which oneor the other (or both) input values contain 1s: -DIM Value1 as BYTEDIM Value2 as BYTEDIM Result as BYTEValue1 = %00001111Value2 = %10101001Result = Value1 | Value2PRINT bin Result ' Display OR result (%10101111)orPRINT bin ( %00001111 | %10101001 ) ' Display OR result (%10101111)18Copyright Crownhill 2001

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!