Keil Logo

BIT

Memory locations in the memory class BIT are addressed with the bit instructions of the 8051. The Special Function Registers (SFR) that are located in bit-addressable memory locations can be addressed with bit instructions. Bit-addressable SFR locations are: 80H, 88H, 90H, 98H, 0A0H, 0A8H, 0B0H, 0B8H, 0C0H, 0C8H, 0D0H, 0D8H, 0E0H, 0E8H, 0F0H, and 0F8H.

Example for all 8051 variants
?BI?mybits SEGMENT BIT          ; define a SEGMENT of class BIT
           RSEG    ?BI?mybits
FLAG:      DBIT    1            ; reserve 1 Bit in BIT space
P1         DATA    90H          ; 8051 SFR PORT1
GREEN_LED  BIT     P1.2         ; GREEN LED on I/O PORT P1.2

?PR?myprog SEGMENT CODE         ; define a segment for program code
           RSEG    ?PR?myprog
           SETB    GREEN_LED    ; P1.2 = 1
           JB      FLAG,is_on   ; direct memory access to DATA
           SETB    FLAG
           CLR     ACC.5        ; reset bit 5 in register A
            :
is_on:     CLR     FLAG
           CLR     GREEN_LED     ; P1.2 = 0
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.