Truth tables for logic operations

Truth table for "NOT"

AResult
01
10

A bit-wise NOT operation performs the logical NOT operation on each bit of the input.

i.e.
bit 7result = NOT bit 7input ,
bit 6result = NOT bit 6input ...

For the 8-bit value 10110011 (base 2), this table shows the computation:

Bit
76543210
Input10110011
Result01001100

An example in Z80 assembler:

ld a,%10110011        ;; load value into A register
not                   ;; perform bit-wise logical NOT operation on all bits of register A

Truth table for "AND"

ABResult
000
010
100
111

A bit-wise AND operation performs the logical AND operation on each bit position of the input values.

i.e.
bit 7result = bit 7input A AND bit 7input B ,
bit 6result = bit 6input A AND bit 6input B ...

For two 8-bit values: inputA = 10110011 (base 2), inputB = 11101010, this table shows the computation:

Bit
76543210
Input A10110011
Input B11101010
Result10100010

An example in Z80 assembler:

ld a,%10110011        ;; load input A into A register
ld b,%11101010        ;; load input B into B register
and a,b               ;; A = A AND B (each bit of A is logically ANDed with each bit in B
                      ;; and the result is stored back into A)

Truth table for "OR"

ABResult
000
011
101
111

A bit-wise OR operation performs the logical OR operation on each bit position of the input values.

i.e.
bit 7result = bit 7input A OR bit 7input B ,
bit 6result = bit 6input A OR bit 6input B ...

For two 8-bit values: inputA = 10110011 (base 2), inputB = 11101010, this table shows the computation:

Bit
76543210
Input A10110011
Input B11101010
Result11111011

An example in Z80 assembler:

ld a,%10110011        ;; load input A into A register
ld b,%11101010        ;; load input B into B register
or a,b                ;; A = A OR B (each bit of A is logically ORed with each bit in B
                      ;; and the result is stored back into A)

Truth table for "Exclusive-OR (XOR/EOR)"

ABResult
000
011
101
110

A bit-wise XOR operation performs the logical XOR operation on each bit position of the input values.

i.e.
bit 7result = bit 7input A XOR bit 7input B ,
bit 6result = bit 6input A XOR bit 6input B ...

For two 8-bit values: inputA = 10110011 (base 2), inputB = 11101010, this table shows the computation:

Bit
76543210
Input A10110011
Input B11101010
Result01011001

An example in Z80 assembler:

ld a,%10110011        ;; load input A into A register
ld b,%11101010        ;; load input B into B register
xor a,b               ;; A = A XOR B (each bit of A is logically Exclusive-ORed with each bit in B
                      ;; and the result is stored back into A)