Wednesday, March 23, 2016

8051 Logical OR for Byte and Bit

Logical-OR for byte variables

ORL performs the bitwise logical-OR operation between the indicated variables, storing the results in the destination byte. No flags are affected.

The two operands allow six addressing mode combinations. When the destination is the Accumulator, the source can use register, direct, register-indirect, or immediate addressing; when the destination is a direct address, the source can be the Accumulator or immediate data.

Note: When this instruction is used to modify an output port, the value used as the original port data is read from the output data latch, not the input pins.

ORL A, Rn
Encoding: 0 1 0 0 1 n n n

ORL A, direct
Encoding: 0 1 0 0 0 1 0 1 direct address

ORL A,@Ri
Encoding: 0 1 0 0 0 1 1 i

ORL A, #data
Encoding: 0 1 0 0 0 1 0 0 immediate data

ORL direct, A
Encoding: 0 1 0 0 0 0 1 0 direct address

ORL direct, #data
Encoding: 0 1 0 0 0 0 1 1 direct address immediate data

ORG 0H
START :
MOV A, #0C3H
MOV R0, #01010101B
ORL A, R0 ; leaves 0D7H (1101011lB) in A
ANL P1,# 00110010B ; sets bits 5, 4, and 1 of output Port 1
END; end of asm source file


ORG 0H
START :
MOV A, #35H
MOV R4, #03H
MOV 40h, #02H
MOV R0, #40H
ORL A, R4
ORL A, P0
ORL A, @R0
ORL A, #0FH
ORL 40h, A
ORL 40h, #77h
END; end of asm source file


Logical-OR for bit variables
Set the carry flag if the Boolean value is a logical 1; leave the carry in its current state otherwise. A slash ( / ) preceding the operand in the assembly language indicates that the logical complement of the addressed bit is used as the source value, but the source bit itself is not affected. No other flags are affected.

ORL C,bit
Encoding: 0 1 1 1 0 0 1 0 bit address

ORL C,/bit
Encoding: 1 0 1 0 0 0 0 0 bit address

Set the carry flag if and only if P1.0 = 1, ACC. 7 = 1, or OV = 0:

ORG 0H
START :
MOV C, P1.0 ;LOAD CARRY WITH INPUT PIN P10
ORL C, ACC.7 ;OR CARRY WITH THE ACC. BIT 7
ORL C, /OV ;OR CARRY WITH THE INVERSE OF OV.
END; end of asm source file


ORG 0H
START :
CLR C
SETB 22h
ORL C, 22h ; C = C | 1
ORL C, /22h ; C = C | 0
END; end of asm source file



Related topics:
8051 Increment Byte and DPTR   |   8051 Decrement Byte   |   8051 Logical AND for Byte and Bit   |   8051 Logical XOR for Byte   |   8051 Addition

List of topics: 8051

No comments:

Post a Comment