|Coming soon! 9060 Blade.
The ANDWF command will AND the contents of the w (working) register to
the register specified by the label f. The result of the AND is
either stored in the working register or the register specified by f
(if d = 0 then the result is stored in the working register. If d = 1
the result is stored in the register specified by f.)
Status Flags Effected:
|Code Example 1:
Assume we have a register labeled TEMP. The following
sequence of commands will AND the value 0x0F to the current contents of
|Move the value 0x03 into the working register.
Move the contents of the working register into temp.
load w with the value 0x0F (decimal: 15)
AND the contenst of w with TEMP and store the result in TEMP
The above code will effectively take the binary value b'00000011'
and AND that with the binary value b'00001111' giving us the resulting
binary value of b'00000011'. This is an effective way of filtering
unwanted bits from a byte so that only the desired bits will be
included in code operations later on.
After the ANDWF command has executed, status flags will be set or
cleared depending on the result of the addition, these status flags are:
||0 = The result of the addition result is not zero.
1 = The result of the addition result is zero.
So, by testing the Z flags after the AND operation, we can
determine if the result is zero or not. This could be useful in certain
instances where an AND operation equaling zero could be used to trigger
a sequence of events. However, the best use of the ANDLW command is to
filter out or filter in bits to a final value.