Logical Operators
You can easily manipulate
the different bits in a register by using commands called logical
operators. There are three main logical operators: and
,
or
,xor
. Each of these commands resets all
the bits in a
to 0
's before it starts; however,
or
will add in what a
was before execution.
and
and arg1
- Arg1 must be either a register, a register pointing to a
memory address, or a value. This sets the bits of a
only
if those bits are also set in arg1.
and h and a and %10001010
or
or arg1
- Arg1 must be either a register, a register pointing to a
memory address, or a value. This sets the bits of a
if
those bits are set in either arg1 or a
.
or b or a or %10010011
xor
xor arg1
- Arg1 must be either a register, a register pointing to a
memory address, or a value. This sets the bits of a
if
they are only set in either arg1 or a
but not both.
xor a xor %10001101 xor h
Effects
and | a = %11001001 arg1 = %10101010 a = %10001000 |
More from z80 » Intermediate
All the Flags // Debugging // Down-Left Bug // _GetKey Codes // Logical Operators // Memory, ROM, RAM, and Safe Areas // Miscellaneous Instructions // PC and SP // Random Numbers // TI's ROM Calls // Restart Commands // Simulated 16-bit Addition // The Stack // Tables and Arrays // Text Display // Variables