8051 LOGICAL INSTRUCTIONS 8051 Micro-controller by Ravinder Nath Rajotiya - April 24, 2019April 5, 20200 Share on Facebook Share Send email Mail Print Print Table of Contents Toggle Logical Type InstructionANL InstructionSETB Instruction CPL InstructionCLR InstructionORL InstructionXRL Instruction Logical Type Instruction ANL Instruction ANL Performs bit wise AND operation between the specified byte. When used to modify an output port, the value used as the port data will be read from the output data latch, not the input pins of the port. format example Opcode/Encoding Flags affected ANL A, #data ANL A, #3FH 01010100 (54H) immediate P ANL A, @Ri ANL A, @R0 0101011i (57H) P ANL A, direct ANL A, 4BH 01010101 (55H) direct P ANL A, Rn ANL A, R4 01011nnn (nnn is Rn) P ANL C, /bit ANL C, /22H 10110000 (B0H) bit None ANL C, bit ANL C,22H 10000010 (82H) bit C ANL direct, #data ANL 30H, #77H 01010011 (53H) direct immediate None SETB Instruction SETB instruction sets the bit operand to a value of 1 Can be used to carry flag or any other directly addressable bit No other flags are affected by this instruction. Format Example/ Operation Opcode/ Encoding Next Opcode Byte Flags affected Byte SETB bit SETB 63h 11010010 63h C 2 SETB C SETB C C=1 11010011 — C 1 CPL Instruction CPL instruction is used to logically complement the value of the specified operand Example: MOV A, #55h ; A= 01010101 CPL A ; Answer will be A= 10101010 format Example/ Operation Opcode/ Encoding Flags affected Byte Cycles CPL Acc CPL A A= NOT A 11110100 None 1 1 CPL bit CPL 55h (bit)= NOT (bit) 10110010 bit None 2 1 CPL carry CPL C C= NOT C 10110011 C 1 1 CLR Instruction CLR instruction clears the bit to a value of 0. Example : MOV A, #34h A=00110100 CLR A ; will set A=00 Format Example Operation Opcode/Encoding Flags affected Byte Cycles CLR Acc CLR A A=0 11100100 P 1 1 CLR bit CLR 01h (bit)=0 11000010 bit none 2 1 CLR Carry CLR C C=0 11000011 C 1 1 ORL Instruction ORL instruction performs a bitwise logical OR operation on the specified operands When used to modify an output port, the value used as the port data will be read from the output data latch, not the input pins of the port. Format example Opcode/ Encoding Flags affected Byte Cycles ORL A, #data ORL A,#01h A=A OR #data 01000100, #immediate P 2 1 ORL A, @Ri ORL A, @R0 A=A OR (Ri) 0100011i P 1 1 ORL A, direct ORL A, direct ORL A, P0 01000101 P 2 1 ORL A, Rn ORL A, R5 A=A or R5 01001nnn P 1 1 ORL C, /bit ORL C, /22h C=C or (NOT bit) 10100000 C 2 2 ORL C, bit ORL C, 22h C=C or Bit 01110010 C 2 2 ORL direct, #data ORL P0, #01h (direct)= (direct) OR #data 01000011, direct, #immediate none 3 2 ORL direct, A ORL P0, A (direct)= (ditrect) OR A 01000010, direct none 2 1 XRL Instruction XRL instruction performs a logical exclusive OR operation between the specified operands When used to modify an output port, the value used as the port data is read from the output data latch, not the pins of the port. Format Example/ Operation Opcode/Encoding Flags affected Byte Cycles XRL A, #immd XRL A, #0FFh A=A XOR #immd 01100100 P 2 1 XRL A, @Ri XRL A, @R0 A=A XOR (Ri) 0110011i P 1 1 XRL A, direct XRL A, 34h A=A XOR (direct) 01100101, 8-bit direct addr P 2 1 XRL A, Rn XRL A, R7 A=A XOR Rn 01101nnn P 1 1 XRL direct, #immd XRL 34h, #0FFh (direct)=(direct) XOR #immd 01100011 none 3 2 XRL direct, A XRL 34h, A (direct) =(direct) XOR A 01100010 none 2 1 Share on Facebook Share Send email Mail Print Print