/* To create a new library function, follow these steps : *Define your own library function body : - Write a new function (void 'my_func'(void) { } - Write FC_HEADER at first line if you use extern arguments retrieving ('ARG*') or extern value returning ('RETURN value;') - Write your instructions. Use 'ARG*' for retrieving externs arguments and 'RETURN value;' for extern value returning *Declare your function in the 'func[]' C list (by replacing a 'void_fc' to 'my_func' statement). The position in this list will fix the number reference (in a newprog program, launch this function by writing : exelibX(,number_reference,{arg1,...}) ) *Now compile with GTC_IDE() (press F5 to launch the compilation) *If no error occured, the output file is OUTBIN(). You can rename it. You can now use this library in your newprog programs */ #define MIN_AMS 200 // Compile for AMS 2.00 or higher #define ARG1 data_ptr[0] //retrieve first argument passed to the lib #define ARG2 data_ptr[1] //and so on #define ARG3 data_ptr[2] #define ARG4 data_ptr[3] #define ARG5 data_ptr[4] #define ARG6 data_ptr[5] #define ARG7 data_ptr[6] #define ARG8 data_ptr[7] #define RETURN data_ptr[8]= //for returning a value #define ANSWER data_ptr[8] //do not use #define FC_LIST data_ptr[9] //do not use #define EXECHDL2 data_ptr[10] //do not use #define COPIEHDL2 data_ptr[11] //do not use #define FC_HEADER long *data_ptr; data_ptr=*(long*)0x5B04; //put FC_HEADER statement at the beginning of your LIB function if your if you use arguments ARG* or RETURN keywords. #include void void_fc(void) //Let it as is { printf("\nUndefined library function."); ngetchx(); } //WRITE YOUR OWN DATAS HERE BELOW// //WRITE YOUR OWN FUNCTIONS BODYS BELOW long add(long a1, long a2) //Sub function example, don't declare it in 'func ()' list. { return a1+a2; } void add_fc(void) //This is an example { FC_HEADER clrscr(); printf("\nARG1+ARG2=%ld",add(ARG1,ARG2)); ngetchx(); RETURN ARG1+ARG2; } //ADD TO THE LIST HERE BELOW THE NAMES OF YOUR FUNCTIONS //0 1 2 3 4 5 6 7 8 9 void (*func[])(void)={add_fc ,void_fc ,void_fc ,void_fc ,void_fc ,void_fc ,void_fc ,void_fc ,void_fc ,void_fc, //0 void_fc ,void_fc ,void_fc ,void_fc ,void_fc ,void_fc ,void_fc ,void_fc ,void_fc ,void_fc, //1 void_fc ,void_fc ,void_fc ,void_fc ,void_fc ,void_fc ,void_fc ,void_fc ,void_fc ,void_fc};//2 //END OF YOUR DATAS// // Main Function - Write nothing below void _main(void) { unsigned int ii; long *data_ptr; if(*(long*)0x5B04!=123456) { clrscr(); printf("\nNot intended to be launched !"); ngetchx(); return; } data_ptr=malloc(12*4); if(data_ptr==0) { printf("\nNot enough memory when launching LIB."); ngetchx(); *(long*)0x5B04=0; return; } FC_LIST=func; *(long*)0x5B04=data_ptr; }