You are on page 1of 3

Logical Instructions

...................................................................................................................................

The following table gives the list of 8031's logical instructions. The instructions that perform Boolean operations (AND, OR, Exclusive OR, NOT) on bytes perform the operation on a bit by bit basis. All of the logical instructions that are Accumulator specific execute in 1s (using a 12MHz clock). Others take 2s. Boolean operations can be performed on any byte in the lower 128 internal data memory space or the SFR space using direct addressing without having to use the Accumulator. If the operation is in response to an interrupt, not using the Accumulator saves time and effort in the interrupt service routine. Mnemonic ANL A,<byte> ANL <byte>,A ANL <byte>, #data ORL A,<byte> ORL <byte>, A ORL <byte>, #data XRL A,<byte> XRL <byte>, A XRL <byte>, #data CLR A CPL A RL A RLC A RR A RRC A SWAP A Operations A= A .AND. <byte> <byte> = <byte> .AND. A <byte> = <byte> .AND. #data A= A .OR. <byte> <byte> = <byte> .OR. A <byte> = <byte> .OR. #data A= A .XOR. <byte> <byte> = <byte> .XOR. A <byte> = <byte> .XOR. #data A = 00H A = .NOT. A Rotate ACC Left 1 bit Rotate Left through carry Rotate ACC Right 1 bit Rotate Right through carry Swap Nibbles in A Execution Time (s) For 12MHZ Operation 1 1 2 1 1 2 1 1 2 1 1 1 1 1 1 1

4.3. Logical Instructions

Logical instructions microcontroller 8051. Instructions Boolean logic for data processing. ANL destination, origin. AND (AND) logic. And so do it logical operation between the source byte and destination byte.

MOV A,#0F0H ; A<-F0H Mover al acumulador el dato inmediato F0H ANL A,#10H ; A<-(A).10H Realiza la AND lgica entre el acumulador y el dato inmediato.

AND logic. ORL destination, origin. OR (O) logic of bits. So do it logical operation OR between the source byte and destination byte. XRL destination, origin. XOR (exclusive OR) logic bits. So do it exclusive OR logical operation between the source byte and destination byte. A 0 0 1 1 B 0 1 0 1 XOR 0 1 1 0

Accumulator CLR A. A = 0, Remove the battery. CPL A. A = A, Complement the accumulator (add A1). SWAP A. A 3-0 <-> A 7-4, swap the nibbles of the accumulator. Bit rotation RL A. Rotate to the left of the battery. RLC A. Rotate accumulator left through carry. A. RR clockwise rotation of the accumulator. A. RRC Rotate accumulator right through carry.

You might also like