Function Declaration

The function declaration describes, in C syntax, the function call that is to be applied by the code generator in place of the standard operation. If, for example, a function is defined in C as

int Add (int operand1, int operand2) {...},

then the corresponding function call would be

Add (operand1, operand2);

Because the concrete character strings for operand1 and operand2 are not known for the declaration of the function in the services.ini file, formal arguments are used in place of these. These placeholders are recognized by the code generator, which replaces them by corresponding character strings during the code generation process. The function call above would appear as follows in the services.ini file:

Add(%i1%, %i2%);

Tab. 3 provides a list of all formal arguments for the Mul and Div (with and without shift and limitation), Add, Sub, Muldiv (with and without limitation), Mod, Neg, Abs, getHighPart operations.

Argument  

Meaning

%i1%

Expression for the 1st operand

%i2%

Expression for the 2nd operand

%i3%

Expression for the 3rd operand

%t1%

Short type (e.g. u8) for the 1st operand

%t2%

Short type (e.g. u8) for the 2nd operand

%t3%

Short type (e.g. u8) for the 3rd operand

%ft1%

Long type (e.g. uint8) for the 1st operand

%ft2%

Long type (e.g. uint8) for the 2nd operand

%ft3%

Long type (e.g. uint8) for the 3rd operand

%tr%

Short type (e.g. u8) for the result

%ftr%

Long type (e.g. uint8) for the result

%c1%

Automatically determined type-cast of the first operand

%c2%

Automatically determined type-cast of the second operand

%c3%

Automatically determined type-cast of the third operand

%op%

Name of the operation

%il%

Bit length of input

Tab. 3: Formal arguments for the operations

The multitude of possible arguments is based on the syntax of possible C function calls:

(%ftr%)functionname(%i1%, %i2%, %i3%);

Additionally, the code generator can generate the concrete function names as long as these follow this syntax:

%op%_%t1%%t2%%t3%_%tr%

Function names can be selected in any manner, though it is recommended that you use the syntax described above.