Declaration of SFR (Special Function Register) declaration

Language reference ›› Variables ››
Parent Previous Next

The SFR type is a special case of the standard BYTE type, designing a processor Special Function Register, at an absolute address.

The SFR keyword allows the programmer to declare and manipulate an alias of a SFR.

To the program, an SFR appears to be an ordinary RAM variable.  

The syntax for an SFR declaration is:

sfr-declaration = VAR identifier ":" SFR "@" address-constant-expression ";" .

Mainly, this is equivalent to declaring a VOLATILE BYTE variable, but there's some differences:

<identifier> is treated as a variable name and <address-constant-expression> is the file register address of the particular SFR.

User-declared SFR variables are always treated as bankable by PMP. The compiler will automatically handle bank switching as needed.


It is possible to declare a pointer to an SFR:


VAR MySfrPtr : ^SFR;