0% found this document useful (0 votes)
71 views9 pages

12.logical Instruction

Logic instructions in microcontrollers include bitwise logic operations like AND, OR, XOR, and NOT. They can be used to force individual bits low or high without affecting other bits. Examples provided show using ANL for AND, ORL for OR, and XRL for exclusive OR on bytes and registers. The CLR instruction clears all bits to 0. Rotate instructions shift bits left (RL) or right (RR), and RLC/RRC shift with carry. SWAP exchanges the high and low nibbles of a register.

Uploaded by

Abhradeep
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
71 views9 pages

12.logical Instruction

Logic instructions in microcontrollers include bitwise logic operations like AND, OR, XOR, and NOT. They can be used to force individual bits low or high without affecting other bits. Examples provided show using ANL for AND, ORL for OR, and XRL for exclusive OR on bytes and registers. The CLR instruction clears all bits to 0. Rotate instructions shift bits left (RL) or right (RR), and RLC/RRC shift with carry. SWAP exchanges the high and low nibbles of a register.

Uploaded by

Abhradeep
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 9

Logic Instructions

Bitwise logic operations (AND, OR, XOR, NOT)


Clear
Rotate
Swap

Logic instructions do NOT affect the flags in PSW


Bitwise Logic
Examples:
ANL – AND 00001111
ANL 10101100
ORL – OR 00001100

XRL – eXclusive OR
00001111
CPL – Complement ORL 10101100
10101111

00001111
XRL 10101100
10100011

CPL 10101100
01010011

Prof. Marimuthu R, Asst Prof,


SELECT
Address Modes with Logic
ANL – AND a, byte
ORL – OR direct, reg. indirect, reg, immediate
XRL – eXclusive oR
byte, a
direct

byte, #constant

CPL – Complement a ex: cpl a

Prof. Marimuthu R, Asst Prof,


SELECT
Uses of Logic Instructions
• Force individual bits low, without affecting other bits.
anl PSW, #0xE7 ;PSW AND 11100111
anl PSW, #11100111b ; can use “binary”

• Force individual bits high.


orl PSW, #0x18 ;PSW OR 00011000

• Complement individual bits


xrl P1, #0x40 ;P1 XRL 01000000

Prof. Marimuthu R, Asst Prof,


SELECT
Other Logic Instructions
• CLR - clear
• RL – rotate left
• RLC – rotate left through Carry
• RR – rotate right
• RRC – rotate right through Carry
• SWAP – swap accumulator nibbles

Prof. Marimuthu R, Asst Prof,


SELECT
CLR – Set all bits to 0
CLR A
CLR byte (direct mode)
CLR Ri (register mode)
CLR @Ri (register indirect mode)

Prof. Marimuthu R, Asst Prof,


SELECT
Rotate

• Rotate instructions operate only on a

rl a

mov a, #0xF0 ; a 11110000


rl a ; a 11100001

Prof. Marimuthu R, Asst Prof,


SELECT
Rotate through Carry

C
rrc a

mov a, #0A9h ; a  A9
add a, #14h ; a  BD (10111101), C0
rrc a ; a  01011110, C1

Prof. Marimuthu R, Asst Prof,


SELECT
Swap
swap a

mov a, #72h
swap a ; a  27h

Prof. Marimuthu R, Asst Prof,


SELECT

You might also like