$FRAMEPROTECT
(Created page with "= <span class="f_Header">Action</span> = This directive will enable or disable interrupt frame protection. <span style="font-family: Arial;"> </span> <span style="font...")
Newer edit →
Revision as of 21:28, 6 February 2013
Contents |
Action
This directive will enable or disable interrupt frame protection.
Syntax
$FRAMEPROTECT = value
Remarks
Value must be a constant expression that evaluates to false (0) or true (<>0).
By default the frame protection is off.
When a user function/sub passes parameters with byval, a copy is created and passed to the user sub/function.
When an interrupt is executed, and it calls user sub/functions with parameters passed with byval, the values can get corrupted.
When activated, the compiler disables interrupts before passing variables, and enables interrupts (when they were enabled) inside the user sub/function. This ensures that the values can not get corrupted from an interrupt which is calling other user sub/functions.
When you do not call user sub/functions from inside your interrupt you can omit the $frameprotect directive or set it to 0 in order to reduce code.
In version 2075 the compiler had frame protection as a default, and the $NOFRAMEPROTECT served as an override. While you can still use $NOFRAMEPROTECT, it is off by default in 2076 to the preferred switch is $FRAMEPROTECT = 0|1
When you activate frame protection the internal constant named _FPROTECT will be set to 1.
When you have a user function that calls an ASM library, you must include code to restore the I-flag.
The bcd.lib user lib sample demonstrates this with this code :
- IF _FPROTECT
Out sreg,r3 ; restore I flag
- ENDIF
See also
Example