Section 7 SUMER Command Language

Section Contents

7. SUMER COMMAND LANGUAGE (SCL)

7.1 Language Definition

7.1.1 Introduction

7.1.1.1 Overview of the SCL Language

The "SUMER Command Language" (SCL) is a problem oriented programming language. It was designed to satisfy the requirements for the formal description of the SUMER measurement tasks. The source code of a SCL written program is converted to a computer independent tokenized metacode. This code may be loaded to the SUMER Computer Unit and there executed by an on-board interpreter. This paper describes the elements and syntax of the SCL language. The alphanumeric symbols used to express the elements of the SCL language are derived from the "C" and the "OCCAM" programming languages.

7.1.1.2 Notational Conventions

This paper uses the following notational conventions:

Convention Meaning


repetition    Vertical ellipsis dots indicate that a portion of program text
              is omitted i.e.:

              main;
                 declaration
                 .
                 .
                 statement
                 .
                 .
              end;

...           Horizontal ellipsis dots following an item indicate that more
              items of the same form may appear, i.e.
              { value, value, ... };

||optional items||pairs of "||" enclose optional items in syntax descriptions.

7.1.2 Elements of SCL

7.1.2.1 Introduction

This chapter describes the elements of the SCL language, including the names, numbers and characters used to construct a SCL program.

7.1.2.2 Character Sets

Letters and Digits

The SCL character set consists of the uppercase and lowercase letters of the English alphabet, the 10 decimal digits of the Arabic number system and the underscore character.

- Uppercase English letters
  A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

- Lowercase English letters
  a b c d e f g h i j k l m n o p q r s t u v w x y z

- decimal digits
  0 1 2 3 4 5 6 7 8 9

- Underscore character "_"

These characters are used to form the constants, identifiers, and keywords described later.

The SCL converter treats uppercase and lowercase letters as distinct characters.

White-Space Characters

Space, tab, line-feed, carriage-return, form-feed, vertical tab and new-line characters are used to separate the items in a program. White space characters are ignored by the converter. Therefore they can be used to make a program more readable.

Punctuation The punctuation and special characters in the SCL character set have various uses, from organizing program text to defining the tasks that the converter or the interpreter will carry out. The following table lists all punctuation and special characters used as elements in the SCL language. All other characters do not have any meaning and are ignored or rejected with a message if used in a program text. If used in comments or string literals they are valid.



,   comma                   separator of identifiers and parameters
.   period                  decimal point in floating point constants
;   semicolon               delimiter of declarations and statements
()  parentheses             used in expressions
[]  brackets                encloses the index of arrays and the number of
                            elements in array declarations
{}  braces                  encloses initializers in declarations
<   left angle bracket      used in operators
>   right angle bracket     used in operators
!   exclamation mark        used in expressions
|   vertical bar            used in operators
~   tilde                   used in expressions
+   plus sign               used in expressions
%   percent sign            used in expressions
&   ampersand               used in expressions
^   caret                   used in expressions
-   minus sign              used in expressions
=   equal sign              used in expressions 

Operators

Operators are symbols that specify how values are to be manipulated. Each symbol is converted to a single unit, a token.


Unary Operators

!   logical NOT
~   bitwise complement
-   arithmetic negation
&   address of
*   indirection


Binary Operators

+   addition
-   subtraction
*   multiplication
/   division
%   remainder (modulo)
<<  left shift
>>  right shift
&   bitwise AND
|   bitwise inclusive OR
^   bitwise exclusive OR

&&  logical AND
||  logical OR

<   less than
<=  less than or equal to
>   greater than
>=  greater than or equal to
==  equality
!=  inequality

=   assignment

7.1.2.3 Constants and Abbreviations

Integer Constants


-- Syntax

    idigits, 0odigits, 0Xhdigits

The group of "Integer Constants" consists of:

decimal constants: formed with the digits 0 - 9, the first of which may never be a 0 octal constants: formed with the digits 0 - 7. A leading zero is required. hexadecimal constants: formed with the digits 0 - 9 and the uppercase or lowercase letters a - f. The leading 0X is required.



Floating-Point Constants

-- Syntax

    ||+|-||||digits||||.digits|| || E|e ||+|-|| digits||

A floating-point constant is a decimal number that represents a signed real number. The value of a signed real number includes an integer portion, a fractional portion, and an exponent. Either the digits before the decimal point or the digits after the decimal point can be omitted, but not both. The decimal point could be left out only if an exponent is included. The constant is formed with the digits 0 - 9 and the symbol "E" or "e" for the exponent.

According to the fundamental data types, described in detail in chapter 7.1.4.2, numerical constants can internally be represented in different forms. The type of a constant is expressed by stating the type explicitly.


(uINT8)0X40          hexadecimal 40 represented as a 8 bit value
(INT32)32460         decimal signed integer represented with 32 bit
(REAL32)637.4E-3     32 bit floating point value. 

IMPORTANT!

The maximum number of different constants in an SCL program is 255.

Abbreviations

It is sometimes useful to express a constant in a program with a symbolic name. From that name the purpose of the constant may be seen, e.g.: PI = (REAL32)3.14159 On the other hand, a constant that is often used in a program must be changed only once in the definition of its abbreviation.

Expressions that are used multiple and are not executed as a called function may also be abbreviated.

The name specified in an abbreviation is an alias for the value or expression. The SCL converter will substitute all occurrences of the abbreviation with the alias Constant or Expression.


-- Syntax

    abbreviation ALIAS : Constant | Expression :

All abbreviations must be declared in the declaration part of the main program. Declarations of abbreviations in functions are not allowed. For that the scope of all abbreviations is global.

7.1.2.4 Identifiers


-- Syntax

    letter|_||letter|digit|_||....

Identifiers are the names supplied for variables, functions and labels in a program. An identifier is created by specifying it in the declaration of a variable or function. An identifier is a sequence of one or more letters, digits, or underscores that begins with a letter or underscore. Identifiers can contain any number of characters, but only the first 8 characters are significant to the converter. An identifier cannot have the same spelling and case as a keyword of the SCL language. Since uppercase and lowercase letters are considered distinct characters, each of the following identifiers is unique:


    index
    INDEX
    Index

7.1.2.5 Keywords

Keywords are predefined identifiers that have special meaning to the SCL converter.


The SCL language has the following keywords:

ALIAS      for       ifend      REAL32     uINT32
do         forend    INT16      return     void
else       goto      INT32      uINT8      while
end        if        main       uINT16     whileend

7.1.2.6 Comments



-- Syntax

    /* characters */

A comment is a sequence of characters enclosed in start "/*" and end delimiter "*/". Comments are ignored by the converter and used as user explanations of the program.

7.1.3 Program Structure

An SCL Program consists of at least one block. Every block has the following principal form.


    "header"
    "constants [and abbreviations]"         [] not allowed in functions
    "variable declarations"
    "program body"
    "end"

The main program is mandatory. It starts with the keyword "main;" and ends with the keyword "end;":


    main;

    "constants and abbreviations"
    "variable declarations"

    "program body"

    end;

The sequence constants - variables is mandatory. Function declarations themselves are blocks as they may consist of the same elements as the main program. Blocks cannot be nested. Functions must be declared before they are referenced. The principal structure of a SCL Program has the form:


    "function declaration"
    "function declaration"
    "function declaration"
    "function declaration"
     .
     .
    "main"

7.1.4 Declarations

7.1.4.1 Introduction

This chapter describes the form of SCL declarations for variables. Any declaration has the principle form :

-- Syntax

    ||intgbl-spec||  type-spec identifier  ||= initializer||,

                             identifier  ||= initializer||,
                             .
                             .
                             identifier  ||= initializer||;

The optional specifier "intgbl-spec" determines the storage area where the variable is to be allocated. It is allocated in the local program workspace.

IMPORTANT!

The maximum number of variable declarations in one SCL program block is 255.

7.1.4.2 Fundamental Data Types

The SCL may act upon variables of the following types. In the declaration the identifier of a certain variable is associated with one of these data types. The fundamental types are:


type   data type and range
===============================================================
uINT8  unsigned integer, 8 bit representation,
       range: 0 ... 255
INT16  signed integer, 16 bit representation,
       range: -32768 ... +32767
uINT16 unsigned integer, 16 bit representation,
       range: 0 ... 65535
INT32  signed integer, 32 bit representation in two's complement,
       range: -2147483648 ... +2147483647
uINT32 unsigned integer, 32 bit representation,
       range: 0 ... 4294967295
REAL32 floating point numbers stored using a sign bit, 8 bit excess 127 exponent
       and 23 bit fraction in ANSI/IEEE standard 754-1985 format. If sign bit
       is 0, value is positive, else negative.
       range : q(3.4E-38 ... 3.4E+38)

7.1.4.3 Declarators

A declarator is an identifier that may be modified by brackets ([]), parentheses (()), or asterisks (*).

-- Syntax

    identifier
    declarator[constant-expression]
    declarator()
    *declarator

When a declarator consists of an unmodified identifier, the item being declared has one of the fundamental data types.

    
    uINT16  xyz;   /* a 16 bit unsigned integer variable */
    REAL32  fpv;   /* a 32 bit floating point variable */
If asterisks appear to the left of an identifier, the type is modified to a pointer type, that is an address in memory of a variable of the declared type.
    uINT16  *p_xyz;
Arrays of elements of a certain data type are declared by joining the number n of required elements enclosed in brackets. The elements in the array are accessed with indices 0 ... n-1.
    INT32  ary[5];  /* array with five elements 0 ... 4 */
Function declarations consist of a declarator and a pair of parentheses that normally enclose the formal parameter set of the function.
    REAL32  function( paramdec1, paramdec2, ...);
where paramdec1, paramdec2, ... are declarations of any type themselves. The function evaluates a result from the parameters param1, param2, ... and returns it as a REAL32 value.

7.1.4.4 Variable Declarations

Introduction

The Sumer On-Board system is able to execute so called POPs (Predefined Opera tional Programs) and UDPs (User Defined Programs) by means of interpreting the converted SCL language code. Every POP and UDP owns its own area of data where tables and lists of parameters are held.

The interpreter itself holds an area in RAM memory where it allocates the data elements declared in any program. After execution of the program has terminated all variables are lost.

IMPORTANT!

The maximum number of variable declarations in one SCL program block is 255.

Local Variables

All variables declared with a declaration syntax with the "intgbl-spec" omitted are allocated as local variables that are lost after program execution.

The Scope of local variables:

Local variables may only be referenced on the level of program nesting on which they are declared. A variable which is declared in the main program is visible through the entire program but not in the functions called from it. A declaration within a function reduces the scope of the variable to that function. Variables whose values are to be used in a called function should be passed through the parameter list.

The SCL language allows the declaration of the following types of variables:

simple variablesingle-value variable of one of the fundamental data types 
array          variable composed of a collection of elements with the same data type
pointer        address of a variable


Simple variables

-- Syntax

    type-spec  identifier ||,identifier || .... ;

The declaration of a simple variable specifies the variables's name and data type. A list of identifiers separated by commas (,) specifies several variables in the same declaration.


Arrays

-- Syntax

    type-spec  declarator [const-expr]||[const-expr]||....;

An array declaration names the array and specifies the type of its elements. The constant expression (const-expr) specifies the number of elements in the array. Each element has the type given by type-spec which is one of the fundamental data types.

Multidimensional arrays are declared by a list of bracketed constant expressions.

Storage

The storage associated with an array type is the storage required for all of its elements. The elements are stored in contiguous and increasing memory locations, from the first element to the last. The most right specified subscript varies most quickly. The subscript for the elements starts with 0.

-- Example

    uINT8 xyz[3][4];
                      address -->
xyz[j][i] in memory:  00 01 02 03  10 11 12 13  20 21 22 23
                      ji  i  i  i  ji  i  i  i  ji  i  i  i


Pointers

-- Syntax

    type-spec  *declarator;

This specifies a pointer. This is a variable that may be used to point to a variable of the type specified in type-spec. With the address operator "&", a value can be assigned to a pointer variable.


-- Example

    uINT16  v_xyz;   /* declare a simple variable */
    uINT16  *p_int;  /* declare a pointer to an uINT16 variable */
    .
    p_int  = &v_xyz; /* assign address of v_xyz to p_int */
    *p_int = 300;    /* this assignment is equivalent ... */
    v_xyz  = 300;    /* ... to this assignment */

Global Variables

The usage of global variables as described in earlier versions of this document (keywords CREATE, USE, DELETE) has been discontinued. Instead, global variables are situated in the system parameter memory area and can be accessed using SCL library functions (SystemR, SystemS, SystemU, PutSystemR, PutSystemS, PutSystemU).

7.1.4.5 Initialization

As mentioned before, the declaration of a variable may have an initializer. This is to preset a variable with an initial value, without an assignment statement. Programs that use this feature become more readable.

-- Syntax

    declaration = initializer; |
                 {initializer,initializer,...,initializer};

The declaration and initializers must be of the same type.

A normal variable is initialized by adding an assignment to the declaration.

    REAL32 zvar = 3.8E-05;   /* the variable zvar has the
                                 initial value of 3.8E-05 */

An array needs as much initializers as elements are declared. To facilitate this procedure, most important when initializing large arrays, the following abbreviations are possible:

    uINT8  b_arr[3]  = {1,2,3};     /* one initializer per element*/

    uINT16 s_arr[10] = {0,1,2,3,4}; /* the first 5 elements are preset
                                       with individual values, the rest
                                       (5 ... 9) are preset to 0 */

    INT32  l_arr[20] = { 5\ };      /* to all the 20 elements the
                                       value 5 is assigned */

    uINT16 a_arr[10] = { 1,2,5\ };  /* the first 2 elements are preset
                                       with individual values, the rest
                                       (2 ... 9) is preset to 5 */

An array may be initialized with a series of simple initializers followed by exactly one complex initializer. The complex initializer fills the remaining elements of the array. If the complex initializer is omitted, the remaining elements are filled with 0.

7.1.4.6 Function Declaration

A function declaration establishes the name, return type, formal parameter list, and the program text to be executed on a call of the function.

-- Syntax

    type-spec  declarator ( ||formal-parameter-list|| );YR

        "constants"
        "variable declarations"

        "program body"
    end;

The type-spec gives the function's return type and is one of the fundamental data types, or the type "void" if the function never returns a value.

The declarator names the function.

Formal parameters describe the arguments that can be passed to the function. Each element of the list is a complete variable declaration separated by commas. Parameters may be passed in two modes: simple variables and specified elements of arrays are passed as values. The parameters must not be used on the left side of an assignment expression.

    /* function declaration */
    REAL32 func_name ( uINT16 para1, REAL32 para2);
        .
        REAL32 res;

        res = para1 + para2;

        para2 = para1 * 2;      /* forbidden */
        .
    end;

    main;
    .
    xyz = 3;
    a_zx[5] = 3.4;
    /* function call */
    rv = func_name( xyz, a_zx[5]);
                            /* the values of 3 and 3.4 are passed. */

If an array is declared in the parameter list, the address of the array is passed in the actual function call.

    /* function declaration */
    uINT16 func_name( uINT16 array[]);
      .
      .
    end;


    main;
    .
    /* Variable declaration */
    uINT16 a_xyz[5];
     .
    /* function call */
     ri = func_name(a_xyz);
    /* the pointer to the array is passed */

Examples and Restrictions

In order to enable modification of a variable in a function, a pointer to the location of the variable must be passed. The value of the pointer must not be modified! Use a local pointer definition.

    /* function declaration */
    uINT16 func_name( uINT16 *ptr);

      *ptr = *ptr + 1;    /* correct */
      ptr  = ptr + 1;     /* forbidden */
      .
    end;

but:

    /* function declaration */
    uINT16 func_name( uINT16 *ptr);
      uINT16 *lptr;

      lptr = ptr;           /* get value of pointer */
      *lptr = *lptr + 1;    /* correct */
      lptr  = lptr + 1;     /* correct */
      .
    end;

The address of a variable that is passed as a value to the function is not available in the function:

    /* function declaration 1 */
    uINT16 func_1( uINT16 *ptr);

    end;

    /* function declaration 2 */
    uINT16 func_2( uINT16 para1, REAL32 para2);
    uINT16 res;

    res = func_1( ¶1);  /* forbidden, the value of the parameter
                               is available, not its address */
    end;

If a function is provided to return a result, the last statement before the end must be a "return" statement with the value or variable to be returned in parentheses.

    .
    .
    return(xyz);
    end;

If the function is declared with the type "void", the return statement may be omitted. The end statement implies the return of program control to the main program.

Program execution will run to unpredictable conditions if both the calling function and the

called function do not handle the return values correctly:
--  a function that does not return a value can't be called in an expression that expects a
    return value,
--  a function that returns a value must be called in an appropriate way.

7.1.5 Expressions and Assignments

7.1.5.1 Introduction

This chapter describes how to form expressions and make assignments in the SCL language. An expression is a combination of operands and operators that yields a single value.

An operand is a constant or variable value that is manipulated in the expression. Every operand can be seen as expression itself as it is a single value. Operators specify how the operand or operands of the expression are manipulated.

7.1.5.2 Operands

Operands in the SCL language are constants, and results of functions, variables, and subscript expressions.

Constants

A constant operand has the value and type of the constant value it represents. (Chapter 7.1.2.3)

Function Calls

A function call consists of an expression including a function identifier followed by an optional expression list in parentheses.


-- Syntax

    expression ( ||expression-list|| )

-- Example

    xyz = do_sum ( para1*5 , para2);


Subscript Expressions

-- Syntax

    expression1 [ expression2 ]

Subscript expressions are generally used to refer to array elements. Expression1 must include the identifier of an array of any data type. Expression2 is evaluated and must yield an integer value, otherwise a type-cast to an integer is done. Expression2 is not checked whether it lies within the valid range of subscripts of the array expression1.

-- Example

    xyz =  5* ary [i*2+j];

7.1.5.3 Operators

SCL language operators take one operand (unary operator), or two operands (binary operator).

Unary Operators

Unary operators appear before their operand and associate from right to left.

! Logical NOT

The operand may be of any type, but not a pointer. The result will be TRUE if the value of the operand is unequal to zero, else it will be FALSE.

- arithmetic negation

The operand may be of any type but not a pointer type. The application of the "-" operator to operands of type "unsigned" is questionable as the MSB of the operand is seen as a sign bit.

~ bitwise complement

The operand must be of integral type, but not a pointer. The application of the "~" operator to operands of type "signed" is questionable as no sign bit preservation will be done.

& Address of

The result of the address operation is a pointer to the operand. The type addressed by the pointer is the type of the operand.

    uINT16  v_xyz;   /* declare a simple variable */
    uINT16  *p_int;  /* a pointer variable of type uINT16 is declared*/
    .
    p_int = &v_xyz;  /* assign address of v_xyz to p_int */

* Indirection

The indirection operator accesses a value indirectly, through a pointer. The operand must be a pointer value. The result of the operation is the value addressed by the operand. The type of the result is is the type that the operand addresses.

    uINT16  v_xyz;   /* declare a simple variable */
    uINT16  *p_int;  /* pointer variable of type uINT16 is declared */
    .
    p_int  = &v_xyz; /* assign address of v_xyz to p_int */
    *p_int = 300;    /* v_xyz has the value 300 */


-- Example for the right to left association:

    uINT16 a,b,c;
    .
    a = 2;
    b = !~a;   /* b = 0  -> ~2 = 0XFFFD, !0XFFFD = 0 */
    c = ~!a;   /* c = -1 -> !2 = 0, ~0 = 0XFFFF = -1 */

Binary Operators

Binary operators associate from left to right. Exept for addition, the operand may not be a pointer type.


Additive Operators

+   Addition
-   Subtraction

Both operands may be of any type. Usual arithmetic conversions are performed on the operands. The type of the result is the type of the operands after conversion.

Multiplicative Operators

*   Multiplication
/   Division

Both operands may be of any type but not a pointer type. Usual arithmetic conversions are performed on the operands. The type of the result is the type of the operands after conversion.

%   Remainder ( Modulo)/* 17 % 5 = 2 */

Both operands must be of integral type. For operands of type REAL32, the "fmod" library function shall be applied.

Shift Operators

<<  Left shift       /* (xyz<<4)  xyz is shifted left by 4  */
>>  Right shift      /* (vxz>>2)  vxz is shifted right by 2 */
                     /*           equivalent to vxz / 4     */

Both operands must be of unsigned integral types. Bits vacated by the shift become 0. Bits shifted out of the variable are lost. Usual arithmetic conversions are performed on the operands. The type of the result is the type of the operands after conversion.

Bitwise Operators

&   Bitwise AND      /* 0x4500 & 0x2533 = 0x0500 */
|   Bitwise inclusive OR/* 0x0204 | 0x2040 = 0x2244 */
^   Bitwise exclusive OR/* 0xA2A2 ^ 0x5252 = 0xF0F0 */

Both operands in bitwise operations must be of integral types. Usual arithmetic conversions are performed on the operands. The type of the result is the type of the operands after conversion.

Logical Operators

&&  Logical AND
||  Logical OR

Both operands must be of unsigned type. The operands of logical expressions are evaluated from left to right. Logical operators do not perform the usual arithmetic conversions. Instead, they evaluate each operand in terms of its equivalence to 0; the result of a logical operation is either 0 (FALSE) or 1 (TRUE).

Relational Operators

The binary relational operators compare their first operand to their second operand to test the validity of the specified relationship.

<    Less than
<=   Less than or equal to
>    Greater than
>=   Greater than or equal to
==   Equality
!=   Inequality

Both operands may be of any type. Usual arithmetic conversions are performed on the operands. The type of the result is of integral type. It is 1 (TRUE) if the tested relationship is true and 0 (FALSE) if it is false.

7.1.5.4 Assignment Operators

= Simple Assignment

The simple-assignment operator assigns its right operand to its left operand. The conversion rules for assignments apply. The operands must be of integral or real type. Normal conversion is performed on the operands. The addition assignment operators may have pointer type on the left with an integral right hand operand. The right operator is interpreted as the number of objects that should be added or subtracted.

-- Example

    REAL32 *pointer;
    .
    pointer = pointer + 4;  /* 16 Bytes (4*4) is added to pointer */

7.1.5.5 Precedence and Order of Evaluation

The precedence and associativity of SCL operators affect the grouping and evaluation of operands in expressions. An operators precedence is meaningful only if other operators with higher or lower precedence are present. Higher-precedence operators are evaluated first. Operators with same level of precedence are handled according to their associativity.


Precedence and Associativity of SCL operators

operator      level     type         associativity
===============================================================
() []            11     expr.        left to right
- ~ ! * &        11     unary        right to left
typecast         11     unary        right to left
* / %            11     mult         left to right
+ -              10     add          left to right
<< >>             9     shift        left to right
< > <= >=         8     rel.         left to right
== !=             7     rel.         left to right
&                 6     AND          left to right
^                 5     EXOR         left to right
|                 4     OR           left to right
&&                3     log. AND     left to right
||                2     log. OR      left to right
=                 1     assignm.     right to left

7.1.5.6 Type Conversions

Assignment Conversions

Type conversions are performed in the following cases:
--  when a value of a certain type is assigned to a variable of a different type.
--  when an explicit type cast operation is performed
--  when an operator converts the type of its operand or operands before performing an
    operation.
--  when a value is passed as an argument to a function.

Conversions

from     to        Method
===============================================================
uINT8     INT16    preserve bit pattern, zero extend
uINT8    uINT16    preserve bit pattern, zero extend
uINT8     INT32    preserve bit pattern, zero extend
uINT8    uINT32    preserve bit pattern, zero extend
uINT8    REAL32    sign extend to INT32, convert INT32 to REAL32

 INT16   uINT8     preserve low-order byte
 INT16   uINT16    copy
 INT16    INT32    preserve bit pattern, zero extend
 INT16   uINT32    preserve bit pattern, zero extend
 INT16   REAL32    sign extend to INT32, convert INT32 to REAL32

uINT16   uINT8     preserve low-order byte
uINT16    INT16    copy
uINT16    INT32    preserve bit pattern, zero extend
uINT16   uINT32    preserve bit pattern, zero extend
uINT16   REAL32    sign extend to INT32, convert INT32 to REAL32

 INT32   uINT8     preserve low-order byte
 INT32    INT16    preserve low-order word
 INT32   uINT16    preserve low-order word
 INT32   uINT32    copy
 INT32   REAL32    convert INT32 to REAL32

uINT32   uINT8     preserve low-order byte
uINT32    INT16    preserve low-order word
uINT32   uINT16    preserve low-order word
uINT32    INT32    copy
uINT32   REAL32    convert INT32 to REAL32

REAL32   uINT8     convert to INT32, preserve low-order byte
REAL32    INT16    convert to INT32, preserve low-order word
REAL32   uINT16    convert to INT32, preserve low-order word
REAL32    INT32    convert to INT32
REAL32   uINT32    convert to INT32, set type to uINT32

With conversions from REAL32, one has to keep in mind that if the value is too large to be represented in the other type, the result will be undefined. For implicit assignment conversions SCL follows the following convention: In expressions, typecast conversions are handled from left to right.

IMPORTANT NOTE:

The type of the left operand determines the typecast of the right one if necessary.

-- Example

    REAL32 = uINT16;          /* result is of type REAL32 */
    ....  Real32/2 + uINT16   /* 2 --> REAL32, uINT16 --> REAL32,
                                 result is REAL32 */

Type-Cast Conversions

Type casts can be used to explicitly convert types.

-- Syntax

    (type-spec) operand

The conversion rules for assignments apply to type casts as well.

7.1.6 Statements

7.1.6.1 The goto and Labeled Statements

-- Syntax

    goto name;
    .
    .
    .
    name: statement;

The goto statement transfers control directly to the statement that is labeled with name. A given label must reside in the same block as the goto statement that references that label. A given label can not appear more than once in a block.

The statement may be empty.

-- Example

   name: ;
   statement;

Labels are only meaningful to a goto statement.

7.1.6.2 The if Statement

-- Syntax

    if (expression)
        statement_i
        statement_i
        .
        .
  : else
        statement_e
        statement_e
        .
        .  ||
    ifend;

The body of an if statement is executed selectively, depending on the value of expression as described below:

-- The expression is evaluated.
-- If expression is TRUE, statement_i are executed.
-- If expression is FALSE, statement_e are executed.
-- If expression is FALSE and the else clause is omitted, statement_i are ignored. 

7.1.6.3 The Expression Statement


-- Syntax

    expression;

When an expression statement is executed, the expression is evaluated according to the rules outlined in chapter 7.1.5.

-- Example

    value = value1 * value2;
    result = func(value);

7.1.6.4 The do Statement


-- Syntax

    do
        statement
        statement
        .
        .
    while (expression);

The body of a do statement is executed one or more times until expression becomes FALSE.

expression is evaluated after the execution of the statement body that therefore is executed at least once, regardless of the initial value of the expression.

A do-while loop can be left with a goto to a label outside the loop.

7.1.6.5 The for Statement


-- Syntax

    for (init-expression to constant || step loop-constant||)
        statement
        statement
        .
        .
    forend;

The body of a for statement is executed zero or more times determined by the parameters.

Execution proceeds as follows:
  1.The init-expression is evaluated. This is a preset of a variable with an initial value.
  2.The variable's value is compared to the constant.
    -- If the variable is less than the constant, statement is executed, then the value of the
       loop-constant is added to the variable. Then the process starts again with the
       comparison of variable and constant. If the loop-constant is omitted, the value of +1
       is assumed.
    -- If the variable is greater or equal to the constant, execution of the for statement
       terminates and control passes to the next statement in the program.

The loop constant must be unsigned; there are no other restrictions for the use of the different data types as constant, loop constant and variable. They should be of equal type to minimize type-cast operations.

7.1.6.6 The return Statement


-- Syntax

    return ||(expression)|| ;

The return statement terminates the execution of the function in which it appears and returns control to the calling program. Execution resumes in the calling program at the point immediately following the call.

The return statement is mandatory if the given function has to return a value evaluated from expression to the calling program. Termination of execution of the function may be initiated with a return statement at any point in the function body.

If the return statement is omitted, control is returned to the calling program after the last statement of the body, which is the end; statement.

7.1.6.7 The while Statement


-- Syntax

    while(expression)
       statement
       statement
       .
       .
    whileend;

The body of the while statement is executed zero or more times until expression becomes FALSE.

Execution proceeds as follows:
  1.The expression is evaluated.
  2.If expression is initially FALSE the body of the while statement is never executed and
    control passes to the next statement in the program. If expression is TRUE the body of
    the while statement is executed and the process is repeated beginning at step 1.

A while loop can be left with a goto to a label outside the while statement body.

7.1.7 Calls to Library, Level 3 and 4 Functions

This chapter has been removed as the library, level 3, and level 4 functions are described in depth in Section 8.

7.1.8 Direct Command Handling

This chapter has been removed as the direct command handling no longer needs to use the SCL facilities. The direct command handling is performed via simple telecommands.

7.2 Token Code Definition

7.2.1 Introduction

This document describes the structure of the output of the SCL language converter. The input of the converter is the SCL source language code described in its appropriate document. The output of the converter is an interpretable tokenized code that is either fixed in PROMs and installed in the SUMER system or sent to the spacecraft via the telecommunication.

There a several competitive aims to be reached.
  --The converted code should be compact to minimize timeconsuming telecommunication.
  --The code should be debugable.
  --The code should consist of very little different elements to minimize the program code
    of the on-board interpreter. 

7.2.2 Fundamentals

The SCL source language is tokenized by the converter in the following principle structure:

         MSB            LSB
          ________________ 
low      | token   $##    |   token number address
         |________________|
         |    data 1      |   token specific data
         |________________|
         ||                ||
         ||                ||   1 to
          ________________ 
high     |    data n      |   n bytes
addr     |________________|

The next token is found by adding the number of data bytes to the address of the actual token.


For a principle SCL program of the form ...

    REAL32 f_1(........);
        uINT16 m,n,o;
        .
        .
    end;   /* end f_1 */

    INT32 f_2(.........);
        uINT8 b1,b2,b3;
        .
        .
    end;   /* end func_02 */

    INT32 f_x(.........);
        uINT8 a1,a2,a3;
        .
        .
    end;   /* end f_x */

    main;
        uINT8 i,j,k;
        .
        .
        .
    end;   /* end main */


... the converter shall generate the following principle memory allocation:

addr:
0000 -->  ________________ 
         | goto  " main:" |
         |________________|
         |index 1         |   all constants
         |  ..  2         |
         |  ..  ..        |
         |  ..  m         |
         |________________|
         |index 1         |   variables of main
         |  ..  2         |
         |  ..  ..        |
         |  ..  m         |
         |________________|
         |index 1         |   variables of f_1
         |  ..  2         |
         |  ..  ..        |
         |  ..  n         |
         |________________|
         ||                ||
         ||                ||
          ________________ 
         |index 1         |   variables of f_x
         |  ..  2         |
         |  ..  ..        |
         |  ..  l         |
         |________________|
         |entry token f_1 |
         |program body    |
         |________________|
         :                :
         :                :


                           
         |entry token f_x |
         |program body    |
"main:"->|________________|
         |entry token main|
high     |program body    |
addr     |________________|

7.2.3 Summary of Token Codes

This chapter gives a brief summary of all token codes used. The first table shown is sorted by functions, the second by token number and size.


Sorted by Function:

Token  Function                                        Size
===========================================================
program control:
0x35   function entry                                     3

control of constant and variables:
0x01   initialize a variable - general form               7
0x12   initialize an element of an array variable         5
0x31   initialize a simple variable                       2
0x40   reference to declared constant                     2
0x41   load data from a declared variable                 2
0x42   load address of a declared variable                2

function control:
0x32   call user defined function                         3
0x44   call library function                              2
0x45   call level 3 function                              2
0x46   call level 4 function                              2
0x43   get actual parameter                               2
0x49   return from function                               2
0x51   store a function's return value                    1

control statements:
0x33   goto                                               3
0x34   if                                                 3

operators and expressions:
0x48   typecast                                           2

0x81
:
0x87   operators (see 7.2.8)                              1

0x8A
:
0x9E   operators (see 7.2.8)                              1


Sorted by Token:

Token  Function                                        Size
===========================================================
0x01   initialize a variable - general form               7

0x12   initialize an element of an array variable         5

0x31   initialize a simple variable                       3
0x32   call user defined function                         3
0x33   goto                                               3
0x34   if                                                 3
0x35   function entry                                     3

0x40   reference to declared constant                     2
0x41   load data from a declared variable                 2
0x42   load address of a declared variable                2
0x43   get actual parameter                               2
0x44   call library function                              2
0x45   call level 3 function                              2
0x46   call level 4 function                              2
0x48   typecast                                           2
0x49   return from function                               2

0x51   store a function's return value                    1

0x81
:
0x87   operators (see 7.2.8)                              1

0x8A
:
0x9C   operators (see 7.2.8)                              1

7.2.4 Program Entry

The header statement "main" and the function declaration header are converted to the "entry" token.

         MSB            LSB
          ________________ 
low      | token   0x35   |   token 0x35 for " entry"
addr     |________________|
         | low byte       |
         |________________|
high     | high byte      |   address of the first variable
addr     |________________|   declaration

This token marks the beginning of a program block and establishes a pointer to the variable area of that block.

7.2.5 Constants

Constants are declared in the declaration part of a program when the ALIAS statement is used or at any point within a program or function when its numerical value is used. Both constant declarations are handled identical by the converter. It installs a list of all constants that are declared, in the header part of the converted program. If a certain constant value is found twice in the program, both occurrences will reference the same constant declaration. The principle representation of a constant declaration in the converted form is as follows:

         MSB             LSB
low       _________________ 
addr.    |  | | | |type id.|   see list of type identifications
         |_________________|
         | 1               |
         |_________________|   one to four data bytes
         | 2               |   see below
         |_________________|
         | 3               |
         |_________________|
high     | 4               |
addr     |_________________|


Type Identifications

type     type spec.  ident. code  data bytes
____________________________________________
integer     INT16        2            2
           uINT8         3            1
           uINT16        4            2
            INT32        5            4
           uINT32        6            4
float      REAL32        7            4


Representation of values in binary notation
(S is the sign bit)


uINT8:
MSB             LSB
 _________________ 
|                 |
|_________________|


INT16:
MSB             LSB MSB             LSB
 _________________  _________________ 
|    low byte     || S3  high byte   |
|_________________||_________________|


uINT16:
MSB             LSB MSB            LSB
 _________________  _________________ 
|    low byte     ||   high byte     |
|_________________||_________________|


INT32:
MSB             LSB MSB         LSB     MSB             LSB
 _________________  ______________       _________________ 
|least sign.byte  ||              | ... | S3most sign.byte|
|_________________||______________|     |_________________|
      byte 1            byte 2                 byte 4


uINT32:
MSB             LSB MSB         LSB     MSB             LSB
 _________________  ______________       _________________ 
|least sign.byte  ||              | ... |   most sign.byte|
|_________________||______________|     |_________________|
      byte 1            byte 2                 byte 4


REAL32: (sign bit, 8 bit exponent, 23 bit fraction)
MSB             LSB   MSB           LSB MSB             LSB
 _________________     _______________   _________________ 
| f f f f f f f f |...| e| f f f f f f| | S| e e e e e e e|
|_________________|   |_______________| |_________________|
      byte 1                byte 3            byte 4

Constants are used in expressions. Their principal representation when referenced in the body of a converted program is as follows:

         MSB             LSB
          ________________ 
         | token    0x40  |   token 0x40 for "constant"
         |________________|
         |     index      |   the number of the constant in the
         |________________|   list of declarations

For the entire SCL program, the constants will be merged in a common block. This block will follow immediately to the "jump to main token". Within a SCL program a total of 255 constants may be declared.

7.2.6 Variables

Variables are declared in the declaration part of a program or function. The converter installs a list of all variables that are declared in a certain SCL program in the header part of the converted program. The principle representation of a variable declaration in the converted form is as follows:

         MSB             LSB
low       _________________    see list of type identifications
addr.    | | | |p| type id.|   "p" is described below
         |_________________|
         |  low address    |
         |_________________|
high     |  high address   |   of the data of the variable
addr     |_________________|


Type Identifications

type     type spec.   ident code  data bytes
============================================
integral    INT16         2            2
           uINT8          3            1
           uINT16         4            2
            INT32         5            4
           uINT32         6            4
floating   REAL32         7            4

pointer    ptr to INT16   2 + p bit    4
           ptr to uINT8   3 + p bit    4
           ptr to uINT16  4 + p bit    4
           ptr to INT32   5 + p bit    4
           ptr to uINT32  6 + p bit    4
           ptr to REAL32  7 + p bit    4


p bit

This bit is set when the variable is a pointer type variable. The variable then is seen as a pointer to a variable of the type indicated by the type identification.

Variables are declared in the declaration part of a SCL program or function. The converter allocates these variables sequentially in memory starting with address 0000 for the first variable in the first program block. According to the type of variable and the number of bytes it needs, the address of the next variable is calculated. For variables that are declared in functions, the address is updated as described above. Memory space is allocated for the sum of all variables declared anywhere in a program.

If the variable is an array type variable, the amount of space in memory is calculated from the type of each element and the number of elements declared. A reference to a variable of the array type is done with the same format as to a simple variable. The address in the variable representation is the address of the first element of the array. The subscript to elements in the array is explained in the Section "7.2.3.6 Operands and Operators".

Variables are used in expressions. Their principal representation when referenced in the body of a converted program is as follows:

The declaration in the program header is referenced by an index. This index is generated by the SCL converter and starts at 0 with every new program block. In every program block, 255 variables may be referenced.

When the actual value of the variable is asked in an expression, the variable is referenced on the "left" side of an expression :

         MSB             LSB
          ________________ 
         | token    0x41  |   token " load data from variable"
         |________________|
         |     index      |   the number of the variable in the list
         |________________|   of declarations.

When the result of an evaluated expression has to be stored to a variable, the variable is referenced on the "right" side of an expression, or when the address "&" or the subscript operator "[]" will be applied, the load address token is used to reference the variable rather than the load data token:

         MSB             LSB
          ________________ 
         | token    0x42  |   token "load address of variable"
         |________________|
         |     index      |   the number of the variable in the list
         |________________|   of declarations.


-- Example of the memory allocation of a program:

SCL source listing:

    REAL32 func_01(........);
        uINT16 m,n,o;
        .
        .
    end;   /* end func_01 */

    INT32 func_02(.........);
        uINT8 b1,b2,b3;
        .
        .
    end;   /* end func_02 */

    main;
        uINT8 i,j,k;
        .
        .
        .
    end; /* end main */


memory allocation of converter for variables declaration:

          ________________ 
         |index 1         |   variables of main
         |  ..  2         |
         |  ..  ..        |
         |  ..  m         |
         |________________|
         |index 1         |   variables of func_01
         |  ..  2         |
         |  ..  ..        |
         |  ..  n         |
         |________________|
         |index 1         |   variables of func_02
         |  ..  2         |
         |  ..  ..        |
         |  ..  i         |
         |________________|
         :
         :
          ________________ 
         |index 1         |   variables of func_xx
         |  ..  2         |
         |  ..  ..        |
high     |  ..  l         |
addr     |________________|

7.2.7 Variable Initialization

Variable initialization is a tool to preset variables with a certain value when they are declared in the SCL program. Programs become more readable as the declaration of a variable and its initial value may be seen from the same statement. As the initialization may be done with simple variables as well as with array type variables the initialization token has the form:

The converter has to care about compatibility of declaration and initializers they must be of same type. Typecasts are not possible.

         MSB             LSB
low       _________________ 
addr.    |token    0x01    |   token 0x01 "initialize variable"
         |_________________|
         |low offset       |
         |_________________|
         |high offset      |   first element to be preset
         |_________________|
         |low item count   |
         |_________________|
         |high item count  |   number of elements to be preset
         |_________________|
         |index to variable|
         |_________________|
high     |index to constant|
addr     |_________________|

The variable that shall be initialized is indicated by its index to the declaration list. Same is done with the constant value that should be assigned to the variable initially. The value is held in the constant declaration list and referenced by its index. The number of items that should be initialized is indicated by the item count. This value is the number of elements of an array to whom is assigned the same initial value. In the case of simple variables the item count is 1. It is possible that elements of arrays are initialized with different values. For that, the offset indicates the first element in the array that should be initialized. For simple variables the offset is 0.

As for the initialization of simple variables and for single elements only little of the token 0x01 structure is necessary, the tokens 0x31 and 0x12 are established:

         MSB             LSB
          _________________
low      |token    0x|1    |  token 0x31 "initialize simple variable"
addr.    |_________________|
         |index to variable|
         |_________________|
high     |index to constant|
addr     |_________________|

This token may also be used whenever a constant value is assigned to a simple variable.

         MSB             LSB
          _________________ 
low      |token     0x12   |   token 0x12  "initialize one element in
addr.    |_________________|                an array variable"
         |low offset       |
         |_________________|
         |high offset      |   the element to be preset
         |_________________|
         |index to variable|
         |_________________|
high     |index to constant|
addr     |_________________|

This token may also be used whenever a constant value is assigned to an element of an array variable.


-- Examples

SCL source listing:

    REAL32 zvar = 3.8E-05;  /* the variable zvar has the initial value
                               of 3.8E-05 */


Converter output:

    .
    1 - constant declaration 3.8E-05
    2 - ....
    .
    .
    1 - variable declaration zvar
    2 - ....
    .
    .


          _________________ 
         | token    0x|1   3   token "initialize simple variable"
         |_________________|
         |        1        |   first declared variable
         |_________________|
         |        1        |   first declared constant
         |_________________|


SCL source listing:

    uINT8  b_array[3] = {1, 2, 3};  /* one initializer per element */


Converter output:

    1 - constant declaration 1
    2 - constant declaration 2
    3 - constant declaration 3
    4 - ....
    .
    .
    1 - variable declaration b_array
    2 - ....
    .
    .


          _________________ 
         | token    0x12   |   token "initialize one element in
         |_________________|          an array variable"
         |        0        |
         |_________________|
         |        0        |   the first element
         |_________________|
         |        1        |   first declared variable
         |_________________|
         |        1        |   first declared constant
         |_________________|
                            
          _________________ 
         | token     0x12  |   token  "initialize one element in
         |_________________|           an array variable"
         |        0        |
         |_________________|
         |        1        |   the second element
         |_________________|
         |        1        |   first declared variable
         |_________________|
         |        2        |   second declared constant
         |_________________|

          _________________ 
         | token    0x12   |   token "initialize one element in
         |_________________|          an array variable"
         |        0        |
         |_________________|
         |        2        |   the third element
         |_________________|
         |        1        |   first declared variable
         |_________________|
         |        |        |   third declared constant
         |_________________|


SCL source listing:

    INT32 l_array[2000] = { 5\ };  /* to all the 2000 elements, the
                                      value of 5 is assigned */


Converter output:

    1 - ....
    2 - ....
    3 - constant declaration 5
    4 - ....
    .
    .
    1 - variable declaration l_array
    2 - ....
    .
    .


          _________________ 
         | token    01     |   token  "initialize variable"
         |_________________|
         |        0        |
         |_________________|
         |        0        |   from first element
         |_________________|
         |       0x07      |
         |_________________|
         |       0xD0      |   2000 elements (0x7d0) of an array
         |_________________|
         |        1        |   first declared variable
         |_________________|
         |        |        |   third declared constant
         |_________________|

7.2.8 Operands and Operators

Operands may be variables, constants, arrays, and results of functions. Their representation is described in detail in separate paragraphs.

Token codes for operators starts at 0x81. Following is the list of operators and their token codes:

expression operators
[]       0x81      array subscript

unary operators
-        0x82      negation
~        0x83      bitwise complement
!        0x84      logical NOT
*        0x85      indirection - pointer
&        0x86      address operator
*        0x87      Lvalue assignment (indirection - pointer)

binary operators
*        0x8A      multiply
/        0x8B      divide
%        0x8C      remainder
+        0x8D      add
-        0x8E      subtract
<<       0x8F      left shift
>>       0x90      right shift

relational operators
<        0x91      less than
>        0x92      greater than
<=       0x93      less or equal
>=       0x94      greater or equal
==       0x95      equality
!=       0x96      inequality

bitwise operators
&        0x97      AND
^        0x98      EXOR
|        0x99      OR

logical operators
&&       0x9A      logical AND
||       0x9B      logical OR

assignment operators
=        0x9C      simple assignment
(type)   0x48      type cast

7.2.9 Expressions

Expressions in SCL language are written in infix notation, where the operators are in between the operands. The SCL converter will convert this infix notation to postfix notation, also called Reverse Polish Notation (RPN). In this notation, operators are written after their operands.

-- Example

             SCL source  a + b * c
             RPN         a b c * +

In the preceding chapters, the elements of expressions were explained. In this chapter we will use them and give sample conversions of expressions.

We use the following notational convention, symbols:

 ___  
|C##|        Symbol for constant element token with
|___|        value indication

 _____ 
|pL id|      Symbol for token "load data from variable" with
|_____|      indication of p-bit and the variable's name.

 _____ 
|pS id|      Symbol for token "load address of variable" with
|_____|      indication of p-bit and the variable's name.

 ___  
| L |        Symbol for "load data at address" operator
|___|

 ___ 
| * |        operator element
|___|


Evaluation of subscribed array elements

[]     0x81      array subscript


SCL source listing:

    uINT16  ra[5],i;
    .
    .
    ..... ra[i*4]....


Converter output:
 ___  _____  ___  ___  ___  _____  ___  ___ 
|C04||.L _i|| * ||C02|| * ||.S ra|| []|| L |
|___||_____||___||___||___||_____||___||___|

                   |__ uINT16 = 2byte element2
                       converter created


SCL source listing:

    uINT16  ra[5][3],i,j;
    .
    .
    ..... ra[i*4][j+2]....


Converter output:
 ___  _____  ___  ___  ___  ___  _____  ___ 
|C04||.L _i|| * ||C0||| * ||C02||.L _j|| + |
|___||_____||___||___||___||___||_____||___|--->

                   |__ size of 2nd subscript 
                       converter created     
 ___  ___  ___  _____  ___  ___ 
| + ||C02|| * ||.S ra|| []|| L |
|___||___||___||_____||___||___|

       |__ uINT16 = 2byte elements
           converter created     


SCL source listing:

    uINT16  ra[5][3],i,j,k;
    .
    .
    ra[i*4][j+2] = k;


Converter output:
 _____  ___  _____  ___  ___  ___  ___  _____  ___ 
|.L _k||C04||.L _i|| * ||C0||| * ||C02||.L _j|| + |
|_____||___||_____||___||___||___||___||_____||___|--->

                          |__ size of 2nd subscript
                              converter created
 ___  ___  ___  _____  ___  ___
| + ||C02|| * ||.S ra|| []|| = |
|___||___||___||_____||___||___|

       |__ uINT16 = 2byte elements
           converter created


SCL source listing:

    uINT16  ra[5][|],i,j;
    uINT16  *p;
    .
    p = &ra[i*4][j+2];    /* the element's address is loaded to
                             pointer p */


Converter output:
 ___  _____  ___  ___  ___  ___  _____  ___ 
|C04||.L _i|| * ||C0||| * ||C02||.L _j|| + |
|___||_____||___||___||___||___||_____||___|--->

                   |__ size of 2nd subscript
                       converter created
 ___  ___  ___  _____  ___  _____  ___
| + ||C02|| * ||.S ra|| []||.S p || = |
|___||___||___||_____||___||_____||___|

       |__ uINT16 = 2byte elements
           converter created

The converter has to evaluate the size of all subscripts and the size of the array elements and
has to insert according elements into the converted expression.


unary operators

-        0x82      negation
~        0x83      bitwise complement
!        0x84      logical NOT

SCL source listing:

    uINT16  i,j;
    .
    .
    ..... ~(i -(-j)) ....


Converter output:
 _____  _____  ___  ___  ___ 
|.L _i||.L _j|| - || - || ~ |
|_____||_____||___||___||___|

                |    |__ subtraction
                |
                |__ negation


*        0x85      indirection - pointer
&        0x86      address operator


SCL source listing:

    uINT16  i,j;
    uINT16  *p,*q;
    .
    .
    p = &i;
    j = *p;
    *q = *p;
    .


Converter output:
 _____  _____  ___  _____  ___  _____  ___ 
|.S _i||pS _p|| = ||pL _p|| * ||.S _j|| = |
|_____||_____||___||_____||___||_____||___|
 _____  ___  _____  ___  ___ 
|pL _p|| * ||pS _q|| * || = |
|_____||___||_____||___||___|


(type)   0x48      typecast

In expressions, typecast conversions are handled from left to right. The type of the left operand determines the typecast of the right one, if necessary.

          _________________ 
         | token    0x48   |   token  "typecast"
         |_________________|
         | type_id         |   type ID of typecast result
         |_________________|   (see 7.2.5 Constants)

In the following symbolized with:
 _______ 
| tc|I16|     Symbol for typecast token with type ID
|_______|


SCL source listing:

    INT32  i;
    REAL32 r;
    .
    .
    i = r;


Converter output:
 _____  _______  _____  ___ 
|.L _r|| tc|I|2||.S _i|| = |
|_____||_______||_____||___|

With respect to precedence and order of evaluation, the typecast operator belongs to the group of unary operators. But as the typecast is a conversion, one needs a parameter that determines the type of the result.


binary operators

*        0x8A      multiply
/        0x8B      divide
%        0x8C      remainder
+        0x8D      add
-        0x8E      subtract
<<       0x8F      left shift
>>       0x90      right shift


SCL source listing:

    uINT16  i,j;
    REAL32 r;
    .
    .
    .... i*4 + r/2 * j<<2 .....


Converter output:
 _____  ___  ___  _____  ___  _______  ___ 
|.L _i||C04|| * ||.L _r||C02|| tc|R|2|| / |
|_____||___||___||_____||___||_______||___| --->
 _____  ___  ___  _______  ___  _______  ___ 
|.L _j||C02|| <<|| tc|R|2|| * || tc|I16|| + |
|_____||___||___||_______||___||_______||___|


relational operators

<        0x91      less than
>        0x92      greater than
<=       0x93      less or equal
>=       0x94      greater or equal
==       0x95      equality
!=       0x96      inequality


SCL source listing:

    uINT16  i,j;
    REAL32 r;
    .
    .
    .... (i+3) < (r*j) .....


Converter output:
 _____  ___  ___  _____  _____  _______ 
|.L _i||C0||| + ||.L _r||.L _j|| tc|R|2|
|_____||___||___||_____||_____||_______|--->
 ___  _______  ___ 
| * || tc|I16|| < |
|___||_______||___|


bitwise operators

&        0x97      AND
^        0x98      EXOR
|        0x99      OR


SCL source listing:

    uINT16  i,j,k,l;
    .
    .
    .... i+3 | j ^ k & l .....


Converter output:
 _____  ___  ___  _____  _____  _____  ___  ___  ___ 
|.L _i||C0||| + ||.L _j||.L _k||.L _l|| & || ^ || | |
|_____||___||___||_____||_____||_____||___||___||___|


logical operators

&&       0x9A      logical AND
||       0x9B      logical OR


SCL source listing:

    uINT16  i,j,k,l;
    .
    .
    .... i < j || j != k && l== 0


Converter output:
 _____  _____  ___  _____  _____  ___ 
|.L _i||.L _j|| < ||.L _j||.L _k|| !=|
|_____||_____||___||_____||_____||___|--->
 _____  ___  ___  ___  ___ 
|.L _l||C00|| ==|| &&|| |||
|_____||___||___||___||___|


assignment operator

=        0x9C      simple assignment


SCL source listing:

    uINT16  i,j;
    .
    .
    i = j + 3;


Converter output:
 _____  ___  ___  _____  ___ 
|.L _j||C0||| + ||.S _i|| = |
|_____||___||___||_____||___|


7.2.10 Function Calls



Use of a function call within a program passes 5 steps :
   1.   passing of the actual parameters to the Function
   2.   calling the function
   3.   executing the function
   4.   returning the functions result
   5.   returning control to the calling program.

Each of these steps must have a representation in the converted SCL program.

1. Passing the actual parameters to the Function

The actual parameters listed in the function call are passed to the called functions in order from left to right by pushing them onto the stack. Enumeration shall be in opposite order: The right most parameter gets the number 1. The index increases towards the left most parameter.

Expressions that must be evaluated before passing the result as parameter are converted as described in Chapter 7.2.9. A special token for passing parameters is not needed.

2. Calling the function

After passing all actual parameters the function is called. This is done using the following structure:

         MSB            LSB
          ________________ 
         |  token  0x|2   |   user defined function token code
         |________________|  
         |  low byte      |
         |________________|
         |  high byte     |   of address of function entry
         |________________|  

The address points to the "entry" token of the function.

3. Executing the function

There is no difference between the execution of a function and that of a main program.

But the access to variables and parameters differs. A reference to a parameter in expressions in the function is done with the "get parameter" token that is similar to the variable token:

         MSB             LSB
          ________________ 
         | token   0x4|   |   token "get parameter"
         |________________|
         |     index      |   the number of the parameter
         |________________|

symbolized with :
 ___ 
|p##|
|___|


The index is described above when parameters where passed to the function.


-- Example


SCL source listing:

    uINT16 func( uINT16 pa, INT32 pb ,uINT16 pc );

    uINT16  i,j;
    .
    .
    j = (i+pc)*5;
    .
    .


Converter output:
 _____  ___  ___  ___  ___  _____  ___
|.L _i||p01|| + ||C05|| * ||.S _j|| = |
|_____||___||___||___||___||_____||___|

         |__ load function's parameter pc


4. Returning the function's result

         MSB            LSB
          ________________
         | token    0x51  |   token "return result"
         |________________|

symbolized with:
 ___ 
|<->|
|___|

The converter has to care about correct handling of returned values.
  --a function that does not return a value can't be called in an expression that expects a
    return value.
  --a function that returns a value must be called in an appropriate way.


5. Returning control to the calling program

          ________________
         | token    0x49  |   token "return from function"
         |________________|
         | number of param|   the number of the parameters of
         |________________|   the function call.

symbolized with :
 ___ 
| r |
|___|

The return of control and results from a function to the calling program is initiated in SCL language with the return statement. This can be done at any point in the function's body. The return statement is converted to the "return result", if necessary, and the "return from function" token. If the return statement is omitted, the converter has to create a "return from function" token when the end; statement is found. If the function does not return a result but the return statement is used, it is converted just to the "return from function" token.

The number of parameters in the parameter list of the function call shall be the parameter for the token.


-- Example

SCL source listing:

    uINT16 func( uINT16 pa, INT32 pb ,uINT16 pc );

    uINT16  i,j;
    .
    .
    return( (i+pc)*5 );
    .
    .
    end;


Converter output:
.
.
 _____  ___  ___  ___  ___  ___  ___ 
|.L _i||p01|| + ||C05|| * ||<->|| r |  return( (i+pc)*5);
|_____||___||___||___||___||___||___|
.
.
 ___ 
| r |    /* end; */
|___|

7.2.11 Statements

7.2.11.1 The goto Statement

In SCL source, the "goto" statement has the following form:

    goto name;
    .
    .
    .
    name: statement;


This is converted to the following structure:


            MSB            LSB
             ________________ 
            |  token  0x||   |   goto token code
            |________________|
            |  low byte      |
            |________________|
            |  high byte     |   of address of labeled
            |________________|   statement

             ________________ 
            |                |
            :                :
                              
            |________________|

address of
label  -->  statement

7.2.11.2 The if Statement


In SCL source the "if .. else" statement has the following form:

    if (expression)
       statement_i
       .
       statement_i
  || else
       statement_e
       .
       statement_e ||
    ifend;

This is converted to the following structure:
             __________________________ 
            |      |       |   |       |
            |   e x p r e s s i o n    |
            |__________________________|

            MSB            LSB
             ________________ 
            |  token  0x34   |   if token code
            |________________|
            |  low byte      |
            |________________|
            |  high byte     |   of address of FALSE
            |________________|

            statement_i
            .
            statement_i
             ________________ 
            |  token  0x|3   |   goto token code
            |________________|
            |  low byte      |
            |________________|
            |  high byte     |   of address of next token
            |________________|

address of
FALSE  -->  statement_e
            .
            statement_e

address of next
token -->    _______________
            |               |

The address in the if token points to that location where control of program is directed when the evaluation of the expression results in the value FALSE. This could be the beginning of the else clause, if any, or the address of "next token" if else is omitted. If expression is TRUE, all statements down to the else are executed, and control is passed to the address of "next token" by means of a goto.

7.2.11.3 The Expression Statement

The expression statement consists of an expression and an assignment of the result of the evaluated expression. This includes function calls and assignment operations.


-- Example

SCL source listing:

    uINT16  i,j;
    .
    .
    i = j + 3;


Converter output:
 _____  ___  ___  _____  ___ 
|.L _j||C03|| + ||.S _i|| = |
|_____||___||___||_____||___|

7.2.11.4 The do Statement

In SCL source, the "do ... while" statement has the following form:

    do
        statement
        statement
        .
        .
    while(expression);


This is converted to the following structure:

address of
    do -->  statement
            .
            .
            statement

             ________________________  ___ 
            |      |       |   |     ||   |
            |   e x p r e s s i o n  || ! |
            |________________________||___|
             ________________
            |  token  0x|4   |   if token code
            |________________|
            |  low byte      |
            |________________|
            |  high byte     |   of address of start of do loop
            |________________|

address of next
token -->    ________________
            |                |

The body of the do .. while loop is executed at least once. Then the expression is evaluated. The result is negated so that use of an if token is possible to control program execution. If the result is FALSE, program is executed from the address of do loop start. If the result is TRUE, program continues execution at the address of the next token.

The converter is responsible that the logical NOT operator token is inserted.

7.2.11.5 The for Statement

In SCL source, the "for" statement has the following form:

    for (init-expression to constant || step loop-constant ||)
        statement
        statement
        .
        .
    forend

This is converted to the following structure:
(where   "v"  means the control variable,
         "iv" means the initial value of the variable,
         "ie" means the terminating constant,
   and   "il" means the loop-constant)

To the control variable is assigned its initial value:
             ________________ 
            | token    0x31  |   token "initialize simple
            |________________|   variable"
            |        v       |   for loop control variable "v"
            |________________|
            |       iv       |   constant of the initial value
            |________________|

The value of the control variable is compared to the value of constant which is the terminating value. As long as the variable is less than the value of constant, the for loop body is executed.

address of
     for-->  _____  ___  ___ 
            |.L _v||Cie|| <=|
            |_____||___||___|
             ________________ 
            |  token  0x|4   |   if token code
            |________________|
            |  low byte      |
            |________________|
            |  high byte     |   of address of next token
            |________________|

loop body--> statement
             .
             .
             statement

To the control variable, the value of the loop-constant is added. If loop-constant is omitted, the variable is just incremented.

address of
  forend --> _____  ___  ___  _____  ___
            |.L _v||Cil|| + ||.S _v|| = |   calculate next
            |_____||___||___||_____||___|   value of loop
                                control variable and save it
             ________________ 
            |  token  0x33   |   goto token code
            |________________|
            |  low byte      |
            |________________|
            |  high byte     |   of address of for token
            |________________|

address of next
token -->    ________________ 
            |                |


7.2.11.6 The return Statement

The return of control and results from a function to the calling program is in SCL language initiated with the return statement. This can be done at any point in the function's body. The return statement is converted to the "return from function" token. If the return statement is omitted, the converter has to create a "return from function" token when the end; statement is found. If the function does not return a result but the return statement is used, it is converted just to the "return from function" token.

Returning control to the calling program.
             ________________ 
            | token    0x49  |   token "return from function"
            |________________|
            | number of param|   the number of the parameters
            |________________|   of the function call.

symbolized with :
 ___ 
| r |
|___|


-- Example


SCL source listing:

    uINT16 func( uINT16 pa, INT32 pb ,uINT16 pc );
    uINT16  i,j;
    .
    return( (i+pc)*5 );
    .
    end;


Converter output:
.
 _____  ___  ___  ___  ___  ___  ___ 
|.L _i||p01|| + ||C05|| * ||<->|| r |  return( (i+pc)*5);
|_____||___||___||___||___||___||___|
.
.
 ___ 
| r |    /* end; */
|___|

7.2.11.7 The end Statement

The end; statement indicates the end of source code text of a program or a function. It is converted to the "return from function" token. If at the end of a function an explicit return statement was found and converted, conversion of the end may be omitted. At the end of the program main usually no return will be written, then the converter has to create a "return from function" token when the end; statement is found.

Returning control to the calling program or termination of main program:

             ________________
            | token    0x49  |   token "return from function"
            |________________|
            |      00        |   the number of the parameters
            |________________|   of the function call = 0.

7.2.11.8 The while Statement


In SCL source, the "while" statement has the following syntax:

    while(expression)
        statement
        statement
        .
        .
    whileend;


This is converted to the following structure:

address of
   while---> __________________________ 
            |      |       |   |       |
            |   e x p r e s s i o n    |
            |__________________________|
             ________________
            |  token  0x|4   |   if token code
            |________________|
            |  low byte      |
            |________________|
            |  high byte     |   of address of next token
            |________________|

while
loop body--> statement
             .
             .
             statement

address of
whileend---> ________________
            |  token  0x33   |   goto token code
            |________________|
            |  low byte      |
            |________________|
            |  high byte     |   of address of while token
            |________________|

address of next
token -->    ________________ 
            |                |

The while loop is converted to an "if .. then" and "goto start" structure. The expression is evaluated and if it results in TRUE, the while loop body is executed. At the end of the loop body, a goto token returns control of execution back to the beginning of the while loop, that means the expression is evaluated another time.

7.2.12 Library Calls

The call of library functions follows the same rules as do the user defined function calls:

   1.   passing of actual parameters to the function
   2.   calling the function
   3.   (execution) user does not care about
   4.   (return result) user does not care about
   5.   (return control) user does not care about

Passing of parameters is explained in chapter 7.2.10.

The call to the desired function is made by means of a specific token code (see the table below), not with a branch to the function's address. For a detailed description of the functions refer to Section 8.

The command tokens for calls to library functions are 0x44 followed by the function identifier (subtoken).


 sub  function   |   sub  function   |   sub  function    
_________________|___________________|____________________
0x10  abs        |  0x20  ParamS     |  0x30  WaitImage
0x11  atan       |  0x21  ParamU     |  0x31  GetPixelB2
0x12  atan2      |  0x22  ParamR     |  0x32  PutPixelB2
0x13  ceil       |  0x23  SystemS    |  0x33  PutPixelB1
0x14  cos        |  0x24  SystemU    |  0x34  PutPixelI2
0x15  exp        |  0x25  SystemR    |  0x35  PutPixelR4
0x16  fabs       |  0x26  PutSystemS |  0x36  SendImage
0x17  floor      |  0x27  PutSystemU |  0x37  GetImageMax
0x18  fmod       |  0x28  PutSystemR |  0x38  PutConstSpatVectorB2
0x19  log        |                   |  0x39  PutConstSpecVectorB2
0x1A  log10      |                   |  0x3A  PutSpatVectorB2
0x1B  pow        |                   |  0x3B  PutSpatVectorB2
0x1C  sin        |                   |  0x3C  GetSpatVectorB2
0x1D  sqrt       |                   |  0x3D  GetSpatVectorB2
0x1E  tan        |                   |  0x3E  Wait
                 |                   |  0x3F  FilesInRamDisk


-- Example

SCL source listing:

    REAL32  ret,x;
    .
    .
    ret = sqrt(x);


Converter output:
 _____
|.L _x|          pass actual variable
|_____|
 ___  ___
| 44|| 1D|       call library function "sqrt"
|___||___|
 _______  ___
|.S _ret|| = |   assignment of result to variable "ret"
|_______||___|

7.2.13 Level 3 Software Calls

For a detailed description of the functions refer to Section 8.

The command tokens for calls to level 3 functions are 0x45 followed by the function identifier (subtoken).

 sub  function             |   sub  function
___________________________|_________________________________
0x00  AFT                  |  
0x01  IIM_mode             |  0x31  Do_DET_Cmd
0x02  IIM_div              |  0x32  StandBy
0x0C  lambda11             |  0x33  ShutDown
0x0D  lambda21             |  0x35  SetMCPHighVoltage
0x0E  lambda13             |  0x36  PowerUp
0x0F  lambda23             |  0x37  SaveSettings
0x10  lambda18             |  0x38  RestoreSettings
0x11  lambda28             |  0x39  SwitchOFF_PSU
0x12  flag                 |  0x3A  SwitchON_PSU
0x13  cont                 |  0x3B  MCInitPos
0x14  slit                 |  0x3C  MCMove
0x15  spectrohelio1        |  0x3D  MCPos2
0x17  point                |  0x3E  StandBy_PSU
0x19  ref_spec             |  0x3F  ReadImage
0x1A  compression          |  0x40  Set_SphelPointCenter
0x1B  expl_event_search    3  0x41  Set_SphelDirection
0x1C  rot_comp             |  0x42  spectrohelio|
0x1E  RSC                  |  0x43  spectrohelio4
0x1F  RSC_scan             |
0x20  full_disk            3
0x21  contY                |
0x22  contZ                |
0x2|  binning              |
0x24  sphel_mode           |
0x25  spectrohelio2        |
0x26  celestial_obj        |
0x27  FF_mode              |
0x28  FlatField            |


-- Example

 _____ 
|.L dt|      pass actual value of variable dt
|_____|
 ___  ___
| 45|| 1C|   call level|  function rot_comp
|___||___|

7.2.14 Level 4 Software Calls

For a detailed description of the functions refer to Section 8.

The command tokens for calls to level 4 functions are 0x46 followed by the function identifier (subtoken).

 sub  function             |   sub  function
___________________________|__________________________________
0x00  IIM_AutoClear        |  0x60  RSC_ReadImage
0x01  IIM_InputGate        |  0x61  RSC_On
0x02  IIM_ChannelSelect    |  0x62  RSC_Off
0x03  IIM_SetPowerSwitch   |  0x63  RSC_PowChk
0x04  IIM_PowerCommandA    |
0x05  IIM_PowerCommandB    |
0x06  IIM_LUStrobeA        |  0x80  POW_ReadHK
0x07  IIM_LUStrobeB        |  0x81  POW_Execute
0x08  IIM_Status           |  0x82  POW_WAXrequest
0x09  IIM_Clear            |  0x83  POW_WAXpulse
0x0A  IIM_Chk              |  0x85  POW_WAXTest
0x0B  IIM_HMrequest        |
0x0C  IIM_LatchUpTest      |
                           |  0xA0  SYS_GetHKrecord
                           |  0xA1  SYS_ReadStatus
0x20  MC_Reset             |  0xA2  SYS_IO_Select
0x21  MC_Power             |  0xA3  SYS_ClrError
0x22  MC_Selftest          |  0xA4  SYS_GetError
0x23  MC_ReadHK            |  0xA5  SYS_GetBankSelect
0x26  MC_ScanStep          |  0xA6  SYS_GetBankStatus
0x27  MC_ScanMotion        |  0xA7  SYS_CCBStatus
0x28  MC_GetSteps          |  0xA8  SYS_CU_Monitor
0x29  MC_GetFreq           |  0xA9  SYS_CU_Stop
0x2A  MC_GetErr            |  0xAA  SYS_Config
0x2B  MC_SetVariable       |  0xAB  SYS_RamDisk
0x2C  MC_GetIRAMValue      |  0xAC  SYS_Peek
0x2D  MC_SetIRAMValue      |  0xAD  SYS_Poke
0x2E  MC_GetERAMValue      |  0xAE  SYS_Dump
0x2F  MC_SetERAMValue      |  0xAF  SYS_Operator
0x30  MC_TST_RelPos        |  0xB0  SYS_GetVersion
0x31  MC_MC1Qualify        |
0x32  MC_SetMoveVars       |  
                           |  0xC0  TST_CRCPatternTest
                           |  0xC1  TST_MoviTest
0x40  DET_Readout          |  0xC2  TST_WalkTest
0x41  DET_QualifyHV        |
0x42  DET_HighV            |  
0x43  DET_X_Timing         |  0xE0  HEA_Manual
0x44  DET_Y_Timing         |  0xE1  HEA_Auto
0x45  DET_MCPHigh          |  0xE2  HEA_Bias     
0x46  DET_X_Charge         |  0xE3  HEA_Interval
0x47  DET_Y_Charge         |  0xE4  HEA_Mode
0x48  DET_X_UpperThreshold |
0x49  DET_Y_UpperThreshold |

-- Example

 _______ 
|.L dev |    pass actual value of variable dev
|_______|
 _______ 
|.L addr|    pass actual value of variable addr
|_______|
 ___  ___ 
| 46|| 2C|   call level4 function MC_GetIRAMValue
|___||___|

7.3 SCL Converter User's Guide

7.3.1 Introduction

7.3.1.1 Purpose

This document describes the user interface of the SUMER command language converter (SCC) for the operating system MS-DOS. The SCC program is a full implementation of the SUMER command language as defined Chapter 7.1.

7.3.1.2 Scope

The SCC is used to translate predefined observational programs (POPs) and user definable observational programs (UDPs) from the human readable SUMER command language form (SCL) into the computer independent SUMER token code form (SXF).

A detailed description of the SUMER command language is given in Chapter 7.1, a description of the SUMER token code in Chapter 7.2.

7.3.2 Getting Started

7.3.2.1 Software/Hardware Resources

To operate the SCC under the operating system MS-DOS, the following hardware and software resources must be available:

- operating system MS-DOS, version 3.3 or higher
- sufficient memory for creation of temporary files used for data processing. The space
  required is approximately eight times the size of the SCL source file
- the SCC program should be installed on a hard disk

7.3.2.2 Disk Backup

First, you should make working copies of the original SCC software disk using the MS-DOS "COPY" command or "DISKCOPY" command. Save the original disks for making future working copies.

7.3.2.3 Disk Contents


On the original SCC software disk, you will find the following file:
    SCC.EXE        The executable SUMER Command Language Converter

7.3.2.4 Installation on Hard Disk

Create a subdirectory where you want to install the SCC software using the MS-DOS command "MD". Copy all files from the original SCC disk to the specified directory.

7.3.2.5 Setting Up the Environment

The SCC does not look for a MS-DOS environment variable. If you want to start the SCC program in any directory of MS-DOS, the PATH variable must be assigned to the directory where the SCC software is installed. If the "file=xx" line in your CONFIG.SYS file specifies a number less than 20, replace the line number with 20.

7.3.3 The SCC Input and Output Files

7.3.3.1 The SCC Input File

The SCC program processes a single input SCL source file at a time. A SCL source file is a collection of directives, definitions, expressions, and statements according to the SCL. These constructions are listed in Chapter 7.1.

7.3.3.2 The SCC Output Files

The following output files are generated by the SCC software:

   - object file
   - source list file
   - map list file
   - token list file

Object File

The SCC software generates an output file containing the computer independent token code form relating to the internal representation of the SCL source. This output file is named object file. The generated token code of the SCC is a full implementation of the SUMER command language token code as defined in Chapter 7.2. The object file is a binary format and is not humanly readable. The object file can be executed only by the SUMER token code interpreter.

Source List File

The SCC generates a source list output file, when specified. Source listings are useful for documenting the structure of a finished program. The first line of each page includes the name of the SCL source file, a date-time stamp "mm/dd/yy-hh:mm:ss" of runtime, the version of the SCC program and the page number. The source listing contains the numbered source code lines of each procedure, along with any diagnostic messages that were generated.

Map List File

The SCC generates a map list output file, when specified. The map listing is helpful in analyzing the memory requirements of the converted program. The first line of each page includes the name of the source file, a date-time stamp "mm/dd/yy- hh:mm:ss" of runtime, the version of the SCC program and the page number. At first, all constants used in the SCL source code are listed in the map. Afterwards, all functions declared in the SCL source code are listed followed by their related arguments and local variables.

The following information is covered:
   - for constants: name, type, internal number, address
   - for functions: name, return type
   - for arguments: name, type, argument number
   - for variables: name, type, internal number, address

The "name" column gives the name of an identifier.

The "type" column gives the type of an identifier (uINT8, uINT16, INT16, uINT32, INT32, REAL32) including the type class "indirection" (*) or "array" ([]). The "number" column gives the internal number of an identifier. The internal number starts with 1 and ends with a maximum of 255. The "address" column gives the address of an identifier in hexadecimal format.

Token List File

The SCC generates a token list output file, when specified. The token list file helps to debug the SCL program during development, because it is a combined source and object listing. It shows each line of SCL source followed by the corresponding line (or lines) of token codes. The first line of each page includes the name of the source file, a date-time stamp "mm/dd/yy- hh:mm:ss" of runtime, the version of the SCC program and the page number. The start address of each token is shown in hexadecimal format. The contents of each token are shown in hexadecimal format as well as in a logical format. If a program address is referenced in a token, the logical representation of the address is a numbered label which is shown in the form "xxxx:".

7.3.4 Converting SCL Programs

7.3.4.1 The SCC command

The SCC is started under the operating system MS-DOS either interactively on the user's console or non-interactively in a batch file.

The SCC command has the following form:

   SCC [options] sourcefile [options]

The command line may consist of several items, one of which must be the name of the SCL source file. Command line items are separated by spaces. Items beginning with a minus sign are interpreted as option selections. The argument "sourcefile" indicates the SCL source file to be processed. If no extension is defined in the SCL source file, the default extension ".SCL" is used. No specification of the argument "sourcefile" will result in an error message and program termination. If no options are defined, the SCL source file is processed, but no output files will be created. Warning and error messages are displayed on the screen.

Specifying Object File

With the "o" option, the SCC produces an object file (see 7.3.3.2.). -o[path]

The SCC creates the object file using the actual pathname, the basename of the specified source file plus the extension ".OBJ". The argument "path" determines any other pathname of the object file.

Example:       SCC -o test

In the example above, the source file "test.scl" is processed and its token code is stored into the object file "test.obj".

Specifying Source List File

With the "l" option, the SCC produces a source list file (see 7.3.3.2.). -l[path]

The SCC creates the source list file using the actual pathname, the basename of the specified source file plus the extension ".LST". The argument "path" determines any other pathname of the source list file.

Example:       SCC test -l

In the example above, the source file "test.scl" is processed and its list is stored into the source list file "test.lst".

Specifying Map List File

With the "m" option, the SCC produces a map list file (see 7.3.3.2.). -m[path]

The SCC creates the map list file using the actual pathname, the basename of the specified source file plus the extension ".MAP". The argument "path" determines any other pathname of the map list file.

Example:       SCC e:\kt\test -me:\kayser

In the example above, the source file "e:\kt\test.scl" is processed and its map is stored into the map list file "e:\kayser\test.map".

Specifying Token List File

With the "t" option, the SCC produces a token list file (see 7.3.3.2.). -t[path]

The SCC creates the token list file using the actual pathname, the basename of the specified source file plus the extension ".TOK". The argument "path" determines any other pathname of the token list file.

Example:       SCC -t test

In the example above, the source file "test.scl" is processed and its token list is stored into the token list file "test.tok".

Specifying Line Width

With the "sw" option, the default line width for all list output files may be changed. -sw linewidth

The argument "linewidth" determines the character width of lines. The number given must be an integer between 40 and 132. If a number outside this range is specified, the SCC program generates a warning message and the default line width of 79 columns is used. Each output line which exceeds the line width is wrapped into the next line.

Example:       SCC e:\kayser\test -sw90

In the example above, the line width of the output list files is set to 90 characters.

Specifying Page Length

With the "sp" option, the default page length for all list output files may be changed. -sp pagelength

The argument "pagelength" determines the number of lines per page. Page breaks are accomplished via the formfeed character. The number given must be an integer between 40 and 200. If a number outside this range is specified, the SCC program generates a warning message and the default page length of 50 lines is used.

Example:       SCC e:\kayser\test -sp55

In the example above, the page length of the output list files is set to 55 lines.

Specifying Empty Time Stamp

With the "d" option, the date and time stamp in the header of all output files is left blank. -d

7.3.4.2 Program Termination

After processing a SCL source file, the SCC terminates with or without warnings or error messages. The SCC program may be interrupted and stopped by the operator before normal termination by pressing the ESC key.

7.3.5 The SUMER Command Language

The SUMER command language is a problem oriented programming language. It was designed to satisfy the requirements for the formal description of the SUMER measurement tasks. The source code of a SCL written program is converted to a computer independent tokenized metacode.

A detailed description of the SUMER command language is given in chapter 7.1, a description of the SUMER token code in chapter 7.2. The following chapters describe only special SCL converter features which are not explained in chapter 7.1.

7.3.5.1 Data Type of Constants

As listed below, the data type of a constant depends on its value:

    value            data type
    ====================================
    < 0xFF           uINT8
    < 0x7FFF         uINT16
    < 0x7FFFFFFF     uINT32
    floating point   REAL32

When a constant value is assigned to a variable, the data types of the variable and the constant must be identical. Otherwise the SCL converter inserts a token to make the data types compatible.

To avoid automatic type casting, the data type of a constant can be expressed explicitly (see Chapter 7.1.2.3.).

Example:

       Line      Source

       1         uINT16 e;
       2         e = (uINT16)1;
       3         e = 1;
       4         f = 1;

Converting the source line (2), the constant "(uINT16)1" is registered as an uINT16 type, therefore no type conversion is necessary. Converting the source line (3), the constant "1" is registered as an uINT8 type, therefore one more token must be inserted to make both types compatible.

In the example above, the SCL converter generates two different constants, one for the value "1" and one for the value "(uINT16)1". To avoid the repetition of casting the same constant, use the ALIAS feature of the SCL converter.

Example:

    CONST_1 ALIAS (uINT16)1

    e = CONST_1;
    f = CONST_1;

If a floating point constant is expressed as an integral type, the fraction of the floating point
value is cut, i.e.
    (uINT16)3.12     is identical to  (uINT16)3
otherwise
    (REAL32)3        is identical to  3.0


Attention:

All the explanations above are not valid for variables.

Example:

       Line      Source

       1         uINT16 e;
       2         uINT8 f;
       3         e = (uINT16)f;
       4         e = f;

There is no difference in the token code for the source lines (3) and (4). When the source line (4) is converted, the casting of the variable "f" is inserted by the SCL converter.

7.3.5.2 Data Type of Array Subscripts

The data type of an array subscript must be an uINT16 type, otherwise the SCL converter inserts a type conversion into the token code. The data type of a pointer or a variable with the "&" operator is registered as an uINT16 type.

Example:

       Line      Source

       1         uINT16 *p, x;
       2         uINT32 a;
       3         x = &a + 3;
       4         p = p + 1;

The expression "&a" (source line 3) is registered as an uINT16 type, therefore the SCL converter converts the constant "3" to an uINT16 type before executing the "+" operation.

The variable "p" (source line 4) is registered as an uINT16, therefore the SCL converter converts the constant "1" to an uINT16 type before executing the "+" operation.

7.3.6 Error Handling

When the SCC program encounters an error or a warning situation, a message is issued to the standard output device of the operating system. The line number given in the message corresponds to the number of the source line at the approximate location of the error.

SCL syntax errors may produce a variety of warning or error messages depending on the situation. In some cases, a single error may actually produce more than one message. Invalid characters in symbols will confuse the parser, so that error messages will vary depending on the context in which the symbol is found. The error message may be for invalid operands, invalid expressions or both. Sometimes an error message will appear because of conditions other than those anticipated by the SCC software. So the text of a message will not always be exactly appropriate to the situation.

When warnings are found, the SCC program continues the conversion of the SCL source file. The object file, map file, list file, and token file are generated. When errors are found, the SCC program continues the conversion of the SCL source file, if possible. Only the list file is generated, all the other output files are purged.

7.3.6.1 Exit Codes

The SCC returns an exit code that can be used by MS-DOS batch files or other programs such as MAKE. The values returned by the SCC are

    value  meaning

    0      no warning or errors issued
    2      warnings were issued
    4      errors were issued.

7.3.6.2 List of Error and Warning Messages


number     command line error message

A01        nested function

           A function declaration is made in the declaration phase of another function.

A02        'x' not a function

           The given identifier 'x' is not declared as a function, but an attempt is made
           to use it as a function.

A03        'x' is a function

           The given identifier 'x' is declared as a function, but an attempt is made to use
           it as a non function.

A04        function 'main' missing

           The SCL source file does not include the main function.

A05        too few arguments

           The number of arguments specified in a function call is less than the number
           of parameters specified in the function declaration.

A06        too many arguments

           The number of arguments specified in a function call is greater than the number
           of parameters specified in the function declaration.

A07        incompatible types on argument 'x'

           The type of the given argument number 'x' does not agree with the
           corresponding type in the function declaration.

A08        no return value

           A function declared to return a value does not do so.

B01        'x' undefined

           The type of the given identifier 'x' is not defined.

B02        'x' multiply defined

           The given identifier 'x' is multiply defined.

B04        label expected

           After the "goto" statement, a label is expected.

B05        too much symbols or constants

           The number of constants or local symbols exceeds the maximum of 255.

B06        code size overflow

           The code size of the SCL token code exceeds 0xff00 bytes.

B07        RAM size overflow

           The RAM size of the SCL token code exceeds 0xff00 bytes.

C01        division by zero

           The second operand in a division operation is evaluated to zero.

C02        left operand must be lvalue

           The left operand of an expression must be an lvalue.

           Examples for invalid syntax:
               a + b = c;
               &a = 3;

C03        'x' missing before 'y'

           The SCC expects the given identifier / keyword / operator 'x' before the given
           identifier / keyword / operator 'y'.

C04        'x' unexpected

           The given identifier / keyword /  operator  'x' appeared illegal in an SCL
           context.

C05        invalid expression

           An expression contains invalid operators or operands.

C06        invalid indirection

           The indirection operator "*" is applied to a nonpointer value.

C07        incompatible types

           An expression contains incompatible types.

C08        lvalue required

           The address operator "&" must be applied to an lvalue. 

           Example for an invalid syntax:
               a = &(b+c);

C09        unknown character 'x'

           The given character 'x' does not correspond to a valid SCL character.

C10        assignment missing

           An expression without an assignment is only valid, when a void function is
           called.

           Examples for invalid syntax:
               a;
               test1(a, b);   /* function test1() is a REAL32 */

C11        expression too complex

           The SCC program does not set a limit to the complexity of declarations,
           definitions, and statements in an individual program. The expression complexity
           is limited by the space allocated for an operator stack, an operand stack and a
           result string. If the SCC software encounters a function that is too large or too
           complex to be processed, an error message is issued.

D01        can't open file 'x'

           The given file 'x' can't be opened.

D02        out of memory

           The SCC program can't allocate more memory for internal use.

D03        invalid command line

           The SCC command line contains invalid options.

D04        unexpected EOF

           The end of the SCL source file is found but is not expected.

D05        internal error

           An internal error is encountered by the SCC. Contact your software hot line.

E01        expecting integral type

           A nonintegral expression is used in an array subscript.

E02        subscript on non array

           A subscript is used on an identifier that is not an array.

E03        invalid array size

           A value defining an array size is evaluated zero.

E04        invalid array dimension

           More than four array dimensions were specified in the declaration phase.

           More array dimensions were applied than specified.

F01        width of preprocessed line overflows

           The replacement of an abbreviation by its value causes an overflow of the line
           width. The line width of the SCL source file is limited to 256 characters.

G01        missing trailing in character constant

           The trailer of a character constant is missing.

           Example for invalid syntax:
               a = '1;

W01        type conversion, possible loss of data

           The SCC converted the data type of a variable or a constant which possibly
           causes loss of data.

           Example:
               uINT8 e;
               e = 1000;


7.3.7 Converter Limits

7.3.7.1 Source Line Width

The line width of the SCL source file is limited to 256 characters. If more than 256 characters are found in any source line by the SCC program, an error message will be displayed and the SCC program terminates.

7.3.7.2 Control Structure Nesting

The SCC does not set a limit to the number of control structure nesting. The maximal number of nestings is limited by the space allocated for the program stack. If the SCC software encounters a function that is too large or too complex to be processed, and the runtime error message "stack overflow" is issued.

7.3.7.3 Identifier Length

User defined identifiers (names for variables, functions, and labels) may be any length, but only the first 31 characters will be significant to the SCC software.


Authors:

Last revised: March 20, 1997 Dietmar Germerott


[Home Page] SUMER Home Page