Keil Logo

C51: Register Variables


Information in this article applies to:

  • C51 Version 5.50a and later

SYMPTOMS

I'm trying to use the register keyword to declare variables I want to be stored in registers. However, the C51 C compiler seems to ignore this.

CAUSE

This is by design. The 8051 only has 8 general purpose registers. Each of them is a single byte register. So, declaring 2 unsigned long register variables would consume all of the available registers if this feature were supported.

RESOLUTION

There is no way to declare register variables with the C51 Compiler. If you must use registers, you should consider writing an assembly routine for the function that requires register variables.

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.