Lesson 9: Logic Operators

The chip includes a comprehensive set of logic instructions that can perform the NOT, AND, OR and XOR operations between the Working Register and either a constant value, or another memory location. If you come from a high level programming background the usefulness of these is probably not that clear, but they are central to many optimisations and algorithms that are used in assembler programming.

// NOT movlw 11110000b movwf my_var comf my_var, f // my_var contains 00001111b // AND movlw 10101010b andlw 00001111b // working register contains 00001010b // OR movlw 10101010b iorwf 01010101b // working register contains 11111111b // XOR movlw 10101010b xorwf 10100101b // working register contains 00001111b

Remember that these are bitwise operators equivalent to the bitwise (& | ^) operators in the C language.

Next Lesson >>