ME Labs, Inc. 719-520-5323 |
Bitwise (Boolean) logic operatorWhen you use byte or word sized data as inputs for Bitwise operators, the result can be as long as your longest input. The operator will perform a comparison of each bit in both input variables, and store the result in the corresponding bit location of the result variable. A common example is the AND operator used to mask certain bits in a byte. It works as a mask because it always returns 0 when one of the inputs is 0. Therefore, when we use "bytevar & %00001111", the top 4 bits of the result will always be 0. The lower 4 bits won't change, because ANDing something with a logic 1 makes the result equal to the input. Here's a modified truth table showing 8-bits being ANDed all at once.
Here are some example equations using the input values above: %10110110 | %00001111 = %10111111 'use OR to mask bits with logic 1 %10110110 ^ %00001111 = %10111001 'use XOR to invert selected bits |
Copyright 2019 ME Labs, Inc. PO Box 8250 Asheville NC 28814 (719) 520-5323 (719) 520-1867 fax email: support@melabs.com |
|