Keil Logo

DISABLE Compiler Directive

Abbreviation

None.

Arguments

None.

Default

None.

µVision

This directive may not be specified on the command line.

Description

The DISABLE directive instructs the compiler to generate code that disables all interrupts for the duration of a function. This directive must be specified with #pragma immediately before the function declaration. The DISABLE directive applies to one function only and must be re-specified for each new function.

Note

  • The DISABLE directive must be specified using #pragma only and may not be specified on the command line.
  • The DISABLE directive may be specified more than once in a source file but must be specified for each function that is to execute with interrupts disabled.
  • A function with disabled interrupts may not have a return type of bit.
  • The DISABLE directive has no impact on the main function, since typically all interrupts are disabled and no function return occurs.
Example
stmt level    source
   1          #pragma DISABLE
   2
   3          int function (int a, int b)  {
   4   1        return (a * b);
   5   1      }

ASSEMBLY LISTING OF GENERATED OBJECT CODE

                ; SOURCE LINE # 3
0000 1A88F0F0      BFLDH   PSW,#0F0H,#0F0H

0004 CC00          NOP
0006 CC00          NOP
;---- Variable 'b' assigned to Register 'R9' ----
;---- Variable 'a' assigned to Register 'R8' ----
                ; SOURCE LINE # 4
0008 0B89          MUL     R8,R9
000A F2F40EFE      MOV     R4,MDL
                ; SOURCE LINE # 5
000E 1A8800F0      BFLDH   PSW,#0F0H,#00H
0012 CB00          RET
  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.