sbit is a bit variable that defines a special function register. Both bit and sbit are variable types extended by C51.
Typical application is: sbit P0_0=P0^0;//That is, define P0_0 as the first bit of the P0 port for bit operations. (Recommended learning: PHP video tutorial)
bit is similar to int char, except that char=8 bits and bit=1 bit. They are all variables, and the compiler assigns addresses during the compilation process.
Usage
In C language, if you write P1.0 directly, the C compiler will not recognize it, and P1.0 is not a legal C language variable. name, so we have to give it another name. The name here is P1_0, but is P1_0 the same as P1.0? You think so, but the C compiler doesn't think so, so they must be connected. The Keil C keyword sbit is used here to define it. There are three ways to use sbit:
The first method: sbit bit variable Name = address value
The second method: sbit bit variable name = SFR name ^ variable bit address value
The third method: sbit bit variable name = SFR address value ^ variable bit address Value
For example, the following three methods can be used to define OV in PSW:
sbit OV=0xd2 (1) Description: 0xd2 is the bit address value of OV
sbit OV =PSW^2 (2) Note: PSW must be defined with sfr first
sbit OV=0xD0^2 (3) Note: 0xD0 is the address value of PSW
, so sbit is used here P1_0=P1^0; is defined to use the symbol P1_0 to represent the P1.0 pin. If you want, you can also give it a name like P10, as long as you change it in the following program.
sbit must be defined at the outermost level, which means it must be defined as an external variable. sbit defines the bit of the SFR (Special Function Register)
sbit is the corresponding bit A bit in the addressable space, bit addressable area: 20H~2FH. Once a definition like sbit xxx = REGE^6 is used, this sbit quantity determines the address. sbit is mostly used in registers to facilitate operations on a certain bit of the register.
The sbit bit register is a bit-addressable absolute address target. The compiler will not change the location after definition.
For more PHP related technical articles, please visit the PHP Graphic Tutorial column to learn!
The above is the detailed content of What does sbit mean?. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

Notepad++7.3.1
Easy-to-use and free code editor

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

Dreamweaver CS6
Visual web development tools