NeoLoch Home Page
Home

Products
Inquisitor IC Tester
4-Dig 7-Seg Display Module

Learning Lab
Assembly Cmds

Consulting
Shipping Policy

About us

Contact us

Support
Knowledgebase

Secured by PayPal
Official PayPal Seal
ANDWF Command:
Syntax:
Status Flags Effected:
ANDWF
ANDWF f,d
Z
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.)

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 TEMP.
MOVLW    0X03
MOVWF    TEMP
MOVLW    0x0F
ANDWF     TEMP,F
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:

Z (zero flag)

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.
Home Consulting Products About us Contact us
All contents of this website are copyrighted 2010-2011 NeoLoch, LLC