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 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
and | a = %11001001 arg1 = %10101010 a = %10001000 |