# Source library structure

A source library is an assembly language source file, with special comments interpreted by cpik linker. Each special comment begins with `";<"`, located at first column, and ends with `">"`. Any information inserted after the final `">"` are really comments and will be ignored by the linker.

Source libraries are structured in modules, each module can contains either data or code.

Here is the list of recognized special comments:

1. Begin of module definition : the specified module follows the comment.

       ;<+module_name>

   The module name can be optionally followed by the specification of a program section, with the following syntax:

       ;<+module_name|section_type>

   The `cpik` linker supports 4 types of program sections :

   1. `CDATA`

      This segment is dedicated to const data. Such data will be located at begin of ROM and will not copied to RAM

   2. `IDATA`

      This segment is dedicated to initialized data. The module must contain the «`;<=`» tag (see below) with exact number of bytes to be used for initialization

   3. `UDATA`

      This segment is dedicated to uninitialized data and is filled with nul bytes during boot.

   4. `CODE`

      This segment contains all other kind of modules (code, symbols, etc.)

   A module with no section specification will be included in the `CODE` program section.

2. End of module definition

       ;<->

3. Module reference : the specified module is needed by the current module.

       ;<?module_name>

4. Static initializer : the specified data must be used by the linker to initialize the current module (this module corresponds to an array or structure). A module can contain several static initializers.

       ;<= byte1 byte2 ... >

Example:

    int table[3] = { 1, 2 } ;

    unsigned char x2(unsigned char c)
    {
      return c * 2 ;
    }

will generate:

    ;<+C18_table|IDATA>
      CBLOCK
      C18_table:3
      ENDC
    ;<= 1 2 0 >
    ;<->

    ;<+C18_x2> unsigned char x2(unsigned char c@0)
    C18_x2
    ;         return c * 2 ;
      movff INDF0,PREINC0
      movlw 2
      ICALL mul8u
      movff POSTDEC0,R0
    ; }
    L18_main_x2_0
      return 0
    ;<?mul8u>
    ;<->