Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Boolean Instructions

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 2

Boolean Instructions

• 8051 contains a complete Boolean processor for single-bit

operations.

• All bit accesses use direct addressing

• Bits may be set or cleared in a single instruction

• Example: SETB P1.7 CLR P1.7

• Carry bit in PSW is used as a single-bit accumulator for Boolean

operations.

• Bit instructions that refer to carry bit as C are assembled as carryspecific


instructions

• Carry also has a mnemonic representation (CY) which can be used

in connection with non-carry-specific instructions.

• Example:

CLR C

CLR CY

Both do the same. First one is 1 byte and the second one is 2-bytes

Boolean Instructions

• Example: Compute the logical AND of the input signals on

bits 0 and 1 of Port 1 and output the result to bit 2 of Port 1.

LOOP: MOV C, P1.0 (1 cycle)

ANL C,P1.1 (2 cycle)

MOV P1.2,C (2 cycle)

SJMP LOOP (2 cycle)

– Worst case delay is when one of the inputs changes right

after the first instruction. The delay will be 11 CPU cycles

(for a 12 MHZ clock, this is 11 us)


There are three versions of JMP instruction: SJMP, LJMP and

AJMP.

• SJMP instruction specifies destination address as a relative

offset. This instruction is 2 bytes and jump distance is limited

to -128 to 127.

• LJMP specifies the destination address as a 16-bit constant.

The destination address can be anywhere in the 64K program

memory space

• AJMP specifies the destination address as an 11-bit constant.

Destination must be within a 2K block of AJMP.

• In all cases, programmer specifies the destination address to

the assembler (using label or a 16-bit constant) and the

assembler puts destination address into correct format.

You might also like