A | Result |
---|---|

0 | 1 |

1 | 0 |

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

i.e.

bit 7_{result} = NOT bit 7_{input} ,

bit 6_{result} = NOT bit 6_{input} ...

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

Bit | ||||||||
---|---|---|---|---|---|---|---|---|

7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | |

Input | 1 | 0 | 1 | 1 | 0 | 0 | 1 | 1 |

Result | 0 | 1 | 0 | 0 | 1 | 1 | 0 | 0 |

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

A | B | Result |
---|---|---|

0 | 0 | 0 |

0 | 1 | 0 |

1 | 0 | 0 |

1 | 1 | 1 |

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

i.e.

bit 7_{result} = bit 7_{input A} AND bit 7_{input B} ,

bit 6_{result} = bit 6_{input A} AND bit 6_{input B} ...

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

Bit | ||||||||
---|---|---|---|---|---|---|---|---|

7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | |

Input A | 1 | 0 | 1 | 1 | 0 | 0 | 1 | 1 |

Input B | 1 | 1 | 1 | 0 | 1 | 0 | 1 | 0 |

Result | 1 | 0 | 1 | 0 | 0 | 0 | 1 | 0 |

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)

A | B | Result |
---|---|---|

0 | 0 | 0 |

0 | 1 | 1 |

1 | 0 | 1 |

1 | 1 | 1 |

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

i.e.

bit 7_{result} = bit 7_{input A} OR bit 7_{input B} ,

bit 6_{result} = bit 6_{input A} OR bit 6_{input B} ...

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

Bit | ||||||||
---|---|---|---|---|---|---|---|---|

7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | |

Input A | 1 | 0 | 1 | 1 | 0 | 0 | 1 | 1 |

Input B | 1 | 1 | 1 | 0 | 1 | 0 | 1 | 0 |

Result | 1 | 1 | 1 | 1 | 1 | 0 | 1 | 1 |

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)

A | B | Result |
---|---|---|

0 | 0 | 0 |

0 | 1 | 1 |

1 | 0 | 1 |

1 | 1 | 0 |

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

i.e.

bit 7_{result} = bit 7_{input A} XOR bit 7_{input B} ,

bit 6_{result} = bit 6_{input A} XOR bit 6_{input B} ...

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

Bit | ||||||||
---|---|---|---|---|---|---|---|---|

7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | |

Input A | 1 | 0 | 1 | 1 | 0 | 0 | 1 | 1 |

Input B | 1 | 1 | 1 | 0 | 1 | 0 | 1 | 0 |

Result | 0 | 1 | 0 | 1 | 1 | 0 | 0 | 1 |

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)