ARM Technical Support Knowledge Articles

USING REGISTERS WHEN CALLING AN ASSEMBLER FUNCTION

Applies to: General Topics

Answer


Information in this article applies to:


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 uVision. Click on the Misc tab and check the 'Register Optimization' option.

MORE INFORMATION

Article last edited on: 2001-07-27 00:00:00

Rate this article

[Bad]
|
|
[Good]
Disagree? Move your mouse over the bar and click

Did you find this article helpful? Yes No

How can we improve this article?

Link to this article
Copyright © 2011 ARM Limited. All rights reserved. External (Open), Non-Confidential