<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 _push_ _pop_
break continue rotate struct structure structures>

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

See also : <link=Default Programming Language (LNG\XS.LDF)=Default Programming Language (LNG\XS.LDF)>
           <link=Pascal language influences=Pascal language influences>

   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) Logical XOR operator

      Syntax : expr^^expr

   6) ? is the same with 'if' keyword

      Example : ?(a>b)a++; /*is equivalent with*/ if(a>b)a++;

   7) The 'absolute value' operator

      Syntax : +variable;

      Computes the absolute value of the operand and updates it.

      Example : long i=-4;
                +i;
                //now i is 4

   8) The 'change-sign' operator

      Syntax : -variable;

      Change the sign of the specified operand.

      Example : long i=-4;
                -i;
                //now i is 4
                -i;
                //now i is -4

   9) Using CPU registers in source code

      Use registers as simple variables :

          EAX=0;
          int b=CX;


  10) _push_ and _pop_ instructions

      Syntax : _push_(expression);
               _pop_(variable);

      _push_ pushes into the system stack the result of the specified
             expression (4 bytes);

      _pop_  pops from the system stack a 4 byte value and initialise with it
             the specified variable.


  11) 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(...)       
                                     < 
                  }                      
                                      <

  12) inline instruction

      Inserts a list of bytes directly into code.

      Example :  inline 0xc3;
                 inline(0xe8,4,0,0,0,0xc3);

  13) Multiple pointers

      Syntax : type *p1;
               type **p2;
               type ***p3;
               type ****p4;
               ....

  14) Absolute address variables

      Syntax : var_decl=[address];

      Example : byte screen[200][320]=[0xa0000];

      The 'screen' address will be 0xa0000.
      screen[10][20]=30; => mem(0xa0000+10*320+20)=30;

  15) Variables initialized from files

      Syntax: var_decl=<filename>;
              var_decl=<filename[offset]>;

      Initialize the specified variable with data from the specified file,
      starting from the specified file offset.

      Example 1 : char palette[768]=<pal.256>;

        Initialize palette vector with the first 768 bytes of the
        'pal.256' file.

      Example 2 : char gifbuf[]=<test.gif>;

        Initialize the 'gifbuf' vector with 'test.gif' file.
        The size of gifbuf vector will be the size of 'test.gif' file.

  16) <link=with=with> instruction

      Syntax : with structure_variable [do] <instruction>


  17) Floating-point variables can be used in traditional integer operations :
        ++ -- & | ^ << >> <<< >>> && || ^^ etc.

  18) <link=private=Local file declarations>

      Declarations can be made local. Local declarations are not visible
      from another file. This is usefull if your program is divided into
      multiple files.

      Example : in C, if you use in one file the 'i' variable you cannot use
                the 'i' variable in another file. On linking phase, there will
                be 2 different variables with the same name.

                If you make the declarations of the 'i' variable local,
                then that declarations are not visible for the linker,
                so everything will be O.K.

      In conclusion, this is very useful if you want to have some
      variable or function declarations in a file that are visible only in
      their file (only for the functions from the same file).

      Syntax : local var_decl;  //variable will be local
               local func_decl; //function will be local

               private var_decl;  //variable will be local
               private func_decl; //function will be local

               public var_decl; //variable will be public
               public func_decl; //function will be public

               local:    //all the following declarations will be local
               private:  //all the following declarations will be local

               public:   //all the following declarations will be public

  19) 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'.


  20) 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 normal variable declaration :

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

              or

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


  21) Variable declarations

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

          long a b c;


  22) Results returned by a function

      A function can return multiple results :

          //declarations
          int,int func(){return x,y;}
          int a,b;

          //...

          //program
          a,b=func();

  23) Structure declaration

      You don't have to use 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;
                  }


  24) 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.


  25) 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).

  26) functions with no parameters and no results can be called like pascal
      procedures

      Eg.   myfunc()
            {
               //do some stuff
            }

            main()
            {
              //...
              myfunc;  //call myfunc function
              //...
            }

  27) 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.


  28) typedef does not exist

  29) floating-point numbers

      Only 'float' type is supported.

  30) You cannot declare a pointer to a vector (or matrix)

      If you still want to do this, you can declare a structure containing
      the vector (or matrix) and use a pointer to it.

      Example:

              image{
                buf[200][320];
              }

              image *ptr;

              ptr->buf[x][y]=10;

  31) The effect of <link=continue=continue> and <link=break=break>
      instructions is extended over <link=switch=switch> and <link=case=case>
      instructions.

      Eg. :

            while(i)               <Ŀ
            {                          
               switch(i)           <  
               {                      
                  case x:continue;   
                  case y:continue(1); 
               }
            }
            




