Masking | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Setting a bit Example : Suppose a control system consists of 8 switches. These may be either OFF (0) or ON (1). It is possible to turn switches on by using the OR instruction. Eg If switches 1, 6 and 8 are already ON and we want to turn on switches 3 and 4...
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Exercise | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
In this same example, the switches can be switched OFF by using the XOR instruction...
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Masking Another use for logical functions is in masking out bits of a number. For example, a character may be input from the keyboard and it is stored as its ASCII code. The digit 5 for example would be stored as the ASCII pattern 00110101 To convert it into a binary number we need to 'mask out' the first 4 bits of the number. To do this we use the AND function...as shown in this table...
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||