Navigation bar
  Start Previous page
 99 of 156 
Next page End 94 95 96 97 98 99 100 101 102 103 104  

93
   Call EnableInt(stat)
End Sub
The disadvantage of using this method is that the compiler does not attempt to verify that the disabling
and enabling are properly paired.  Consequently, you might inadvertently omit the call to EnableInt()
which would prevent any further interrupts, effectively disabling serial I/O, the RTC, etc.
A third method of guaranteeing atomicity is to explicitly disable and re-enable interrupts as depicted
below.
Dim i as Integer
Sub Main()
   Register.SREG = &H00
   i = 200
   Register.SREG = &H80
End Sub
Although this technique may be useful in rare cases, its use is strongly discouraged.  The primary
problem with this method is that it unconditionally re-enables interrupts without regard to whether or not
interrupts were enabled beforehand.  A related technique using inline assembly language code, having
the same disadvantage, is shown below.
Dim i as Integer
Sub Main()
#asm
   cli
#endasm
   i = 200
#asm
   sei
#endasm
End Sub
4.5 Attributes for Procedures and Variables
This section describes several special attributes that you can apply to variables or procedures with native
mode devices to obtain special effects.  To apply special attributes, you list the desired attributes (see the
table below) in a comma-separated list enclosed in parentheses following the keyword Attribute.  This
entire construction is placed at the end of a normal variable, subroutine or function definition as illustrated
in the example below.
Special Attributes
Attribute
Valid For
Description
Inline
subroutine
function
Instructs the compiler to “inline” the code for the subroutine/function
instead of generating a call.  Generally, this yields faster execution,
sometimes at the expense of larger program size.
NoInline
subroutine
function
Instructs the compiler not to “inline” the code for the subroutine/function
instead of generating a call.
Used
subroutine
function
variable
Instructs the compiler to include the variable or procedure in the
executable even if it appears not to be used.  This is useful, for example if
external C or assembly code needs to use a ZBasic data item or
procedure but it is not otherwise used in the program.
Volatile
variable
Instructs the compiler to not make any assumptions about the content of
the variable.  This should be used when another task or an ISR may be
modifying the variable.
Previous page Top Next page