Page 138 of 229 Start Back Next End ZBasic Language Reference 128 ZBasic Microcontrollers 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 6.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 and, instead, generate a call to the subroutine or function. 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. "Alias:name" subroutine function Instructs the compiler to create an alias for the procedure having the specified name. This is useful on native mode devices to allow external code to refer to a ZBasic procedure by a pre- determined name. Static variable Instructs the compiler allocate space for the variable statically. This attribute is redundant for variables defined at the module level since that is the default for those. In contrast, variabled defined within a procedure are normally dynamically allocated, i.e. they exist only while the procedure is executing.