sfr16

Many of the newer 8051 derivatives use two SFRs with consecutive addresses to specify 16-bit values. For example, the 8052 uses addresses 0xCC and 0xCD for the low and high bytes of timer/counter 2. C51 provides the sfr16 data type to access 2 SFRs as a 16-bit SFR.

Access to 16-bit Special Function Registers is possible only when the low byte immediately precedes the high byte. The low byte is used as the address in the sfr16 declaration. For example:
sfr16 T2 = 0xCC;     /* Timer 2: T2L 0CCh, T2H 0CDh */
sfr16 RCAP2 = 0xCA; /* RCAP2L 0CAh, RCAP2H 0CBh */

In this example, T2 and RCAP2 are declared as 16-bit special function registers.

The sfr16 declarations follow the same rules as outlined for sfr declarations. Any symbolic name can be used in an sfr16 declaration. The address specification after the equal sign (=) must be a numeric constant. Expressions with operators are not allowed. The address must be the low byte of the SFR low-byte, high-byte pair.