Hardware manual

The 8051 Instruction Set
Atmel 8051 Microcontrollers Hardware Manual 1-5
4316A–8051–01/04
The DA A instruction is for BCD arithmetic operations. In BCD arithmetic ADD and
ADDC instructions should always be followed by a DA A operation, to ensure that the
result is also in BCD. Note that DAA will not convert a binary number to BCD. The DA A
operation produces a meaningful result only as the second step in the addition of two
BCD bytes.
1.4 Logical
Instructions
Table 1-3 shows the list of logical instructions. The instructions that perform Boolean
operations (AND, OR, Exclusive OR, NOT) on bytes perform the operation on a bit-by-
bit basis. That is, if the Accumulator contains 00110101B and <byte> contains
01010011B, then
ANL A,<byte>
will leave the Accumulator holding 00010001B.
The addressing modes that can be used to access the <byte> operand are listed in
Table 1-3. Thus, the ANL A, <byte> instruction may take any of the following forms.
ANL A, 7FH(direct addressing)
ANL A, @ R1(indirect addressing)
ANL A, R6(register addressing)
ANL A, # 53H(immediate constant)
All of the logical instructions that are Accumulator specific execute in 1 µs (using a
12 MHz clock and X1 mode). The others take 2 µs.
Table 1-3. A list of the Atmel 8051 Logical Instructions
Mnemonic Operation Addressing Modes
Execution Time
@ 12MHz (µs)
Dir Ind Reg Imm
ANL A, <byte>A = A AND <byte> XXXX 1
ANL <byte>, A <byte> = <byte> AND A X 1
ANL <byte>, #
data
<byte> = <byte> AND # data X 2
ORL A, <byte>A = A OR <byte> XXXX 1
ORL <byte>, A <byte> = <byte> OR A X 1
ORL <byte>, #
data
<byte> = <byte> OR # data X 2
XRL A, <byte>A = A XOR <byte> XXXX 1
XRL <byte>, A <byte> = <byte> XOR A X 1
XRL <byte>, #
data
<byte> = <byte> XOR # data X 2
CLR A A = 00H Accumulator only 1
CLP A A = NOT A Accumulator only 1
RL A Rotate ACC Left 1 bit Accumulator only 1
RLC A Rotate Left through Carry Accumulator only 1
RR A Rotate ACC Right 1 bit Accumulator only 1
RRC A Rotate Right through Carry Accumulator only 1
SWAP A Swap Nibbles in A Accumulator only 1