<title=Differences from standard C>
<keywords=c cpp c++ language difference differences ansi variables variable declaration declarations function functions results arguments syntax typedef quick for switch exchange int long argument programming ldf>

        Ŀ
          What should a person used to standard C compilers  
          (Borland C, Watcom C, DJGPP etc.) know             
        


   1) <link=Compiler Directives=Compiler Directives>

   2) The 'exchange' operator : <->

      Syntax : variable <-> variable

   3) The bitwise rotate operators : <<< and >>>

      Syntax : expr1 <<< expr2

               (rotate expr1 with 'expr2' bits to the left)

               expr1 >>> expr2

               (rotate expr1 with 'expr2' bits to the right)

               variable <<<= expr
               variable >>>= expr

   4) Jump and Call instructions : ^ and ^^

      Syntax : ^label;
               ^variable;
               ^function;
               ^register;
               ^expression;

               ^^label;
               ^^variable;
               ^^function;
               ^^register;
               ^^expression;

   5) Using CPU registers in source code

      Use registers as simple variables :

          EAX=0;
          int b=CX;

               
   6) Extended break and continue instructions

        Syntax : a) break;
                    continue;

                 b) break(const);
                    continue(const);

        The a) form is ansi C compatible.
        The b) form extends the effects of the a) form to 'const'+1 loops.

        Note : break(0) is the same as break;
               continue(0) is the same as continue;

        Example :
                  while (...)        <Ŀ
                  {                      
                    do{                <
                                        
                        for( ....)    <
                        {              
                                       
                           continue; ٳ
                           continue(1);ٳ
                           continue(2);
                           break(2); Ŀ
                           break(1); Ŀ 
                           break; Ŀ   
                        }              
                                   <   
                      }while(...)       
                                     < 
                  }                      
                                      <


   7) void function declarations

      The default function type is 'void', so if you have a declaration
      like this :

          func();

      it will have the 'void' type, not 'int' like in standard 'C'.


   8) The functions' argument list

      You don't have to supply the type of EVERY parameter, like :

           func(int a,int b,int c,long *d);

      Instead, you declare the arguments as a normal variable declaration :

           func(int a,b,c;long *d);

              or

           func(int a,b,c,long *d);


   9) Variable declarations

      In the variable list, the variables can be separated by simple spaces,
      not only by commas :

          long a b c;


  10) Results returned by a function

      A function can return multiple results :

          //declarations
          int,int func();
          int a,b;

          //...

          //program
          a,b=func();

  11) Structure declaration

      You mustn't the 'struct' keyword. The syntax is :

         structure_name{
            structure_variables_declaration;
         }

      Example : definition of a complex number structure;

            standard C:

                  struct complex{
                          float a,b;
                         };

            XSCompiler :

                  complex{
                    float a,b;
                  }

      The 'struct' keyword does not exist in this compiler, so if you use
      'struct name_structure', the compiler will think that 'struct' is
      an identifier and generate some kind of warning message like
      'unexpected symbol'.


  12) The 'quick for' instruction

      This is used for a simple and fast loop. The syntax is :

          const1..const2:instruction;

      The instruction will be executed (const2-const1) times.


  13) Extended switch syntax

      The difference occures at the 'case' substatements :

      Standard C :

           case <constant expression> :

      XSCompiler :

           case <expr> :
           case <expr_1,expr_2, ... ,expr_n> :
           case <expr_1..expr_n> :
           case <expr_11..expr_12,expr_21..expr_22, ... ,expr_n1..exprn2> :

      where expr is any expression (constant or not).

  14) int and long types

      You should use long instead of int (the code generated will be smaller
      and faster, because it's a 32-bit code and you should not use 16-bit
      variables). Anyway, you can modify the programming language so that
      'int' designates the 'long' keyword. To do that, replace the line

             id int     int_k   0

      from the 'xs.ldf' file with the following :

             id int     long_k  0

      If you want to use a 16-bit integer, use the 'shortint' keyword.


  15) typedef does not exist

  16) floating-point numbers

      Only 'float' type is supported.


      See also :
      <link=Pascal language influences=Pascal language influences>


