X86 Assembly/Logic

Logical instructionsEdit

The instructions on this page deal with bit-wise logical instructions. For more information about bit-wise logic, see Digital Circuits/Logic Operations.


and src, dest GAS Syntax
and dest, src Intel syntax


Performs a bit-wise AND of the two operands, and stores the result in dest. For example:

movl $0x1, %edx
movl $0x0, %ecx
andl %edx, %ecx
; here ecx would be 0 because 1 AND 0 = 0


or src, dest GAS Syntax
or dest, src Intel syntax


Performs a bit-wise OR of the two operands, and stores the result in dest. For example:

movl $0x1, %edx
movl $0x0, %ecx
orl  %edx, %ecx
; here ecx would be 1 because 1 OR 0 = 1


xor src, dest GAS Syntax
xor dest, src Intel syntax


Performs a bit-wise XOR of the two operands, and stores the result in dest. For example:

movl $0x1, %edx
movl $0x0, %ecx 
xorl %edx, %ecx 
; here ecx would be 1 because 1 XOR 0 = 1

not arg

Performs a bit-wise inversion of arg. For example:

movl $0x1, %edx
notl %edx
; here edx would be 0xFFFFFFFE because a bitwise NOT 0x00000001 = 0xFFFFFFFE
Last modified on 6 December 2011, at 02:13