4.4 Precautions for Creation of Sources
(1) Place a tab stop every 4 characters wherever possible. Source display/mixed display with the gdb debugger of a
source set at a tab interval other than 4 characters may result in displaced output of the source part.
(2) When compiling/assembling a C source or assembly source that includes debugging information, do not
include other source files (by using #include). It may cause a debugger operation error. This does not apply
to ordinary header files that do not contain sources.
(3) When using C and assembler modules in a program, pay attention to the interface between the C functions and
assembler routines, such as arguments, size of return values and the parameter passing conventions.
(4) The C compiler assumes that the address size is 24 bits by default or 20 bits when the -mshort-offset option
only is specified. Therefore, be aware that the expected results may not be obtained from an operation using an
unsigned int/unsigned short type variable and a pointer, as int type variables are 16-bit size, as
shown below.
int* ip_Pt;
unsigned int i = 1;
ip_Pt += (-1)*i;
The code above is written to expect "ip_Pt += (-1);", however it will be processed as "ip_Pt +=
0xffff;".
Although it will be processed normally when the address space is 16-bit size, an invalid address will result if
the address space is 24- or 20-bit size.
To perform a pointer operation correctly when the C compiler is under the default condition or when the -ms-
hort-offset option only is specified, avoid using unsigned int/unsigned short type variables, or
add the suffix 'L' to the constant as shown below so that it will be handled as a long type constant.
ip_Pt += (-1L)*i;
(5) In C sources, function names can be used as the pointer to the function, note, however, that the pointer values
cannot be assigned to real type (float/double) variables and arrays using the function names.
They can be assigned to integer type variables and arrays.
However, if assigning a value to a global variable/array using a function name at the same time the variable/
array is declared, the types of variables/arrays are limited depending on the address space size.
In 24-bit address space (default condition) or 20-bit address space (when -mshort-offset only is specified)
The long/unsigned long type variables/arrays only allow substitution with a function name.
In 16-bit address space (when -mpointer16 is specified)
The short/unsigned short/int/unsigned int type variables/arrays only allow substitution with
a function name.
If it is not at declaration, global variables/arrays in any integer type can be substituted with a function name.
Integer type local variables/arrays always allow substitution with a function name regardless of whether it is at
declaration or not.
Examples: In 16-bit address space (when -mpointer16 is specified)
1) short s_Global_Val = (short)boot;
→ A function name can be used to assign the pointer to the s h o r t type global variable
s_Global_Val when it is declared.
2) long l_Global_Val = (long)boot;
→ An error occurs if a function name is assigned to the long type global variable l_Global_Val
when it is declared.
error: initializer element is not constant
3) short s_local_val = (short)boot;
→ A function name can be used to assign the pointer to the s h o r t type local variable
s_local_val.
S5U1C17001C ManUal
(C COMPilEr PaCkagE fOr S1C17 faMily) (Ver. 1.5.0)
EPSOn
4 SOUrCE filES
4
SrcFiles
4-13
Need help?
Do you have a question about the S5U1C17001C and is the answer not in the manual?