menu_top_normal
NeoLoch Home Page
Home Inquisitor Tester Learning Lab Consulting Shipping Policy Contact us Support ----------------------
News
Coming soon! 9060 Blade.
ANDLW Command:
Syntax:
Status Flags Effected:
ANDLW
ANDLE k
Z
The ANDLW command will AND the contents of the w (working) register to the literal specified in the command line. The result of the AND operation is stored in the working register. This command is useful for filtering out unwanted bits from a byte. For example: purging unwanted bits from a port register.

Code Example 1: If we have the value 0x1F loaded in the working register and then AND the working register with the value 0x0F. The result would leave the working register holding the value 0x0F. The code for this would looking something like the following.
MOVLW    0X1F
ANDLW    0X0F  
Move the binary value b'00011111' into w.
AND the binary value b'00001111' with the contents of w, this effectively filters out the upper 4 bits of the byte and leaves w holding the binary value b'00001111'.

After the ANDLW command has executed, the Z flag will be set or cleared depending on the result of the AND operation:

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.









All contents of this website are copyrighted 2010-2018 NeoLoch