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          typedef unsigned char  uchar;
   2
   3          #pragma disable   /* Disable Interrupts */
   4          uchar dfunc (uchar p1, uchar p2)  {
   5   1        return (p1 * p2 + p2 * p1);
   6   1      }
        ; FUNCTION _dfunc (BEGIN)
0000 D3         SETB  C
0001 10AF01     JBC   EA,?C0002
0004 C3         CLR   C
0005  ?C0002:
0005 C0D0       PUSH  PSW
;---- Variable 'p1' assigned to register 'R7' ----
;---- Variable 'p2' assigned to register 'R5' ----
                ; SOURCE LINE # 4
                ; SOURCE LINE # 5
0007 ED         MOV   A,R5
0008 8FF0       MOV   B,R7
000A A4         MUL   AB
000B 25E0       ADD   A,ACC
000D FF         MOV   R7,A
                ; SOURCE LINE # 6
000E  ?C0001:
000E D0D0       POP   PSW
0010 92AF       MOV   EA,C
0012 22         RET
        ; FUNCTION _dfunc (END)
  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.