Crossware

Table of Contents        Previous topic       Next topic       

C COMPILER->Accessing the 8051 Internal Registers->SFR Words

The _sfrword keyword is used to declare an identifier which accesses a 16 bit wide location in sfr data space.  The format for the declaration is:

_sfrword <identifier name> = <address>;

For example:

_sfrword  Counter = 0XCA;

declares Counter to be address CA hex in sfr address space.

When you assign a value to Counter the least significant byte is written to address CA and the most significant byte is written to address CB.

When you assign Counter to another variable, or use Counter in an expression, the least significant byte is read from address CA and the most significant byte is read from address CB.

When you OR Counter with a variable (or a constant), the value is read from addresses CA and CB, ORed with the variable and written back to addresses CA and CB.