C Compiler (Fcc911) - Fujitsu MB91150 Series Hardware Manual

32-bit microcontroller
Table of Contents

Advertisement

APPENDIX
D.1

C Compiler (fcc911)

When programming in C, note that the operation result is unpredictable if the following
operations are performed for the little-endian area:
• Allocation of variables having initial values
• Structure insertion
• Manipulation of a non-character type array by using a character-string handling
function
• Specification of the -K lib option during use of a character-string handling function
• Using the double type and long-double type
• Allocating stacks in the little-endian area
I Allocation of variables having initial values
A variable having an initial value cannot be allocated in the little-endian area.
The compiler has no function for generating initial values in the little-endian area. The compiler
can allocate variables in the little-endian area; however, it cannot set initial values in this area.
Perform the processing for setting the initial value at the beginning of the program.
[Example] Setting of an initial value for the variable little_data in the little-endian area
extern int little_data;
void little_init(void) {
little_data = initial-value;
}
void main(void) {
little_init();
...
}
I Structure insertion
For insertion between structures, the compiler selects the optimum transfer method to perform
transfer byte-by-byte, half word-by-half word, or word-by-word. If structure insertion is performed
between structure variables allocated in an ordinary area and those allocated in the little-endian
area, the obtained results will not be correct.
[Example] Structure insertion in the structure variable little_st of the little-endian area
struct tag { char c; int i;} normal_st;
extern struct tag little_st;
#define STRMOVE(DEST,SRC) DEST.c=SRC.c;DEST.i=SRC.i;
void main(void) {
STRMOVE(little_st,normal_st);
}
The location of the structure member differs for each compiler. So, the member location may
differ from that of a structure generated by another compiler. If this occurs, the method
previously explained will not produce correct results.
460

Advertisement

Table of Contents
loading

Table of Contents