boolean 8051

12

Upload: vj-aiswaryadevi

Post on 12-May-2015

2.311 views

Category:

Education


0 download

TRANSCRIPT

Page 1: boolean 8051
Page 2: boolean 8051

BOOLEAN INSTRUCTIONSCLR,CPL,SETB,AND,OR

Page 3: boolean 8051

BOOLEAN INSTRUCTIONS

This group of instructions is associated with the single-bit operations of the 8051.

This group allows manipulating the individual bits of bit addressable registers and memory locations as well as the CY flag.The P, OV, and AC flags cannot be directly

altered.This group includes:

Set, clear, and, or complement, move.Conditional jumps.

Page 4: boolean 8051

CLR <bit>

CLR C CLR instruction can

operate on the carry flag

CLR C The CARRY flag is set

to 0

CLR bit CLR instruction can

operate on any directly addressable

bitCLR P2.7 If Port 2 has been

previously written with DCH (11011100),

then the operation leaves the port set to 5CH (01011100)

Page 5: boolean 8051

SETB <bit>

SETB C SETB instruction

operates on the carry flag and sets the specified bit to 1

SETB C sets the carry flag to 1

SETB bit SETB instruction

operates on any directly-addressable

bit and sets the specified bit to 1

SETB P2.0 Port 2 has the value of

24H (00100100), the Port 2 value changes to 25H (00100101)

Page 6: boolean 8051

CPL <bit>

CPL C This operation

complements the carry flag

CPL C

CPL bit CPL instruction

complements any directly addressable Bit

CPL P2.2 If Port 2 has the value

of 53H (01010011) then after the execution the port set to 55H (01010101)

Page 7: boolean 8051

ANL

ANL C, <source-bit> This instruction ANDs

the bit addressed with the carry bit and stores the result in the carry bit itself

ANL C,P2.7 ;AND carry flag with bit 7 of P2

ANL C, /<source-bit> If a slash (/) is used in

the source operand bit, the logical complement of the source bit is used, but the source bit itself is not affected

ANL C,/OV ;AND with inverse of OV flag

Page 8: boolean 8051

ORL

ORL C, <source-bit> This instruction ORs

the bit addressed with the carry bit and stores the result in the carry bit itself

ORL C,P2.5 ;OR carry flag with bit 5 of P2

ORL C, /<source-bit> If a slash (/) is used in

the source operand bit, the logical complement of the source bit is used, but the source bit itself is not affected

ORL C,/OV ;OR with inverse of OV flag

Page 9: boolean 8051

MOV <dest-bit>,<source-bit>

One of the operands must be the carry flag; the other may be any directly-addressable bit

MOV C,P3.3MOV P2.0,C If P2=C5H (11000101), P3.3=0 and

CY=1 initially, after instructions, P2=C4H (11000100) and CY=0

Page 10: boolean 8051

JC / JNC addr

Jump to a relative address if CY is set / cleared.

CLR CSUBB A,R0JC ARRAY1

MOV A,#20H

CLR CSUBB A,R0JNC ARRAY2MOV A,#20H

Page 11: boolean 8051

JB / JNB <bit>,addr

Jump to a relative address if a bit is set / cleared.

JB ACC.7,AR1JB P1.2,AR2

JNB

ACC.6, RY1JNB P1.3,RY2

Page 12: boolean 8051

JBC <bit>,addr

Jump to a relative address if a bit is set and clear the bit.

JBC P1.3,ARRAY1 If P1=56H (01010110), the above

instruction sequence will cause the program to branch to the instruction at ARRAY1, modifying P1 to 52H (01010010)