Keil Logo

C51: Using Only One Registerbank


Information in this article applies to:

  • C51

QUESTION

What does the ONEREGBANK compiler directive do?

ANSWER

When the C51 compiler generates code for an interrupt function that is declared without a USING directive, register bank 0 is selected by default. For example:

void ISR (void) interrupt 1
{
func (counter++);
}

generates the following interrupt entry code:

             ; FUNCTION isr1 (BEGIN)
0000 C0E0              PUSH    ACC
0002 C0D0              PUSH    PSW
0004 75D000            MOV     PSW,#00H

Setting the PSW is necessary when you use both high-priority interrupts and low-priority interrupts. If a high-priority interrupt is declared without a using directive, the compiler assumes you want to use registerbank 0. This is required when interrupting low-priority interrupts that HAVE specified a registerbank (with the using directive). By default, the C51 compiler uses this technique to ensure that high-priority interrupts that do not specify a registerbank with the using attribute can interrupt lower priority interrupts that use a different registerbank.

If you only use one registerbank in your program, you can use the ONEREGBANK directive to tell the compiler to avoid selecting registerbank 0 in interrupts that don't specify the using directive.

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.