Texas Instruments MSC1210 User Manual

Page 218

Advertising
background image

Bit-Wise Logical Instructions (ANL, ORL, XRL)

16-24

16.22 Bit-Wise Logical Instructions (ANL, ORL, XRL)

The 8052 instruction set offers three instructions to perform the three most
common types of bit-level logic: logical AND (ANL), logical OR (ORL), and log-
ical exclusive OR (XRL). These instructions are capable of operating on the
accumulator or an internal RAM address.

Some examples of these instructions are:

ANL A,#35h

;Performs logical AND between accumulator
;and 35h, result in accumulator

ORL 20h,A

;Performs logical OR between IRAM 20h and
;accumulator, result in IRAM 20h

XRL 25h,#15h ;Performs

logical

exclusive

OR

between

;IRAM

25h

and

15h

ANL (logical AND) looks at each bit of parameter1 and compares it to the same
bit in parameter2. If the bit is set in both parameters, the bit remains set; other-
wise, the bit is cleared. The result is left in parameter1.

ORL (logical OR) looks at each bit of parameter1 and compares it to the same
bit in parameter2. If the bit is set in either parameter, the bit remains set; other-
wise, the bit is cleared. The result is left in parameter1.

XRL (logical exclusive OR) looks at each bit of parameter1 and compares it to
the same bit in parameter2. If the bit is set in one of the two parameters, the bit
is set; otherwise, the bit is cleared. That means if the bit is set in both parameters,
it is cleared. If it is set in one of the two parameters, it remains set. If it is clear
in both parameters it remains clear. The result is left in parameter1.

Table 16−2, Table 16−3, and Table 16−4 show the results of each of these log-
ical instructions when applied to each possible bit combination.

Table 16−2.Results of ANL

ANL

0

1

1

0

0

0

0

1

Table 16−3.Results of ORL

ORL

0

1

0

0

1

1

1

1

Table 16−4.Results of XRL

XRL

0

1

0

0

1

1

1

0

Advertising