ARM Technical Support Knowledge Articles

SELECTING DIFFERENT REGISTER BANKS IN A FUNCTION

Applies to: C51 C Compiler

Answer

QUESTION

How do I force the compiler to use a different register bank for a specific function?

ANSWER

Use the USING directive to specify which register bank a function uses.

For example:

void serial_isr (void) interrupt 4 using 1 { ... }

creates an interrupt function for the serial port and switches to register bank 1 (address 0x08 - 0x0F). Now the interrupt may switch to RB 1 and start using R0-R7 without saving and restoring. This makes the interrupt entry and exit code shorter and faster.

You may specify the USING directive for any function. You may specify register banks 0, 1, 2, and 3. However, you should check to make sure that what you do is actually more efficient than what the compiler does by default.

Article last edited on: 2004-06-07 08:23:15

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