Keil Logo

C51: Locate struct to SFR Space


Information in this article applies to:

  • C51 All Versions

QUESTION

Is there a way to locate a C struct into the 8051's SFR (Special Function Register) area?

ANSWER

Yes. Define the structure in C and declare an external structure.

For example:

struct s  {
  unsigned int  i;
  unsigned char c;
};

extern struct s MySfr;  // struct should be in SFR space

Then, create an Assembly Module to define the starting address of the external structure.

For example:

PUBLIC MySfr

MySfr DATA  095H       ; start address of struct MySfr

END

MORE INFORMATION

SEE ALSO


Last Reviewed: Thursday, February 25, 2021


Did this article provide the answer you needed?
 
Yes
No
Not Sure
 
  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.