Keil Logo

GENERAL: USING REGISTERS WHEN CALLING AN ASSEMBLER FUNCTION


Information in this article applies to:

  • C51 Version 5.50
  • C251 Version 2.14

QUESTION

I am calling an assembler function foo from the main function in C and the compiler avoids using registers in the main function for operating on local variables. When I comment out the function call it uses the registers.

How can I make the compiler use the registers to obtain smaller and faster code?

ANSWER

In your assembler function you need to specify which registers are modified by the function. In addition you need to turn global register optimization on.

Modify your assembler code to use the REGUSE directive. For example:

$REGUSE foo (ACC, R0)

will specify that the function foo only modifies the accumulator and R0.

To turn on Global Register Optimization, choose Make from the Options menu in µVision. Click on the Misc tab and check the 'Register Optimization' option.

MORE INFORMATION

  • Refer to the A51 Assembler/A251 Assembler User's Guide for more information on the REGUSE directive.
  • Refer to the C51 Compiler User's Guide for more information on Global Register Optimization with C51.
  • Refer to the C251 Compiler User's Guide for more information on Global Register Optimization with C251.

FORUM THREADS

The following Discussion Forum threads may provide information related to this topic.

Last Reviewed: Friday, July 27, 2001


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.