User`s manual

50 digi.com Language
4.23.2 Module Sample Code
There are many examples of modules in the Lib directory of Dynamic C. The following code will illus-
trate proper module syntax and show the scope of directives, functions and variables.
There are three modules defined in this code. The first one is responsible for the variable ticks, the sec-
ond and third modules define functions Get_Ticks() and Inc_Ticks that access the variable.
Although Inc_Ticks is an assembly language routine, it has a function prototype in the module header,
allowing the compiler to check calls to it.
If the application program calls Inc_Ticks or Get_Ticks() (or both), the module bodies corre-
sponding to the called routines will be compiled. The compilation of these routines triggers compilation of
the module body corresponding to ticks because the functions use the variable ticks.
/*** BeginHeader ticks*/
extern unsigned long ticks;
/*** EndHeader */
unsigned long ticks;
/*** BeginHeader Get_Ticks */
unsigned long Get_Ticks();
/*** EndHeader */
unsigned long Get_Ticks(){
...
}
/*** BeginHeader Inc_Ticks */
void Inc_Ticks( int i );
/*** EndHeader */
#asm
Inc_Ticks::
or a
ipset 1
...
ipres
ret
#endasm