FUJITSU MB91F109 FR30 User Manual
Page 421
397
APPENDIX D Notes on Using Little Endian Areas
#define STRMOVE(DEST,SRC) DEST.c=SRC.c;DEST.i=SRC.i;
void main(void) {
STRMOVE(little_st,normal_st);
}
Moreover, as the member allocation for a structure is different for each compiler, it may differ
from that of another compiler. In this a case, the correct result cannot be acquired.
When the member allocations for structures differ, do not allocate the corresponding structure
variables to a little endian area.
■
Manipulating Data Other Than Character Arrays with a Character String Manipulation Function
Character string manipulation functions provided by standard libraries perform processing in
byte-units. Therefore, the character string manipulation function does not produce the correct
results for variables of types other than char, unsigned char, and signed char, which are
allocated to little endian areas. Do not perform such operations.
[Example of incorrect processing] Transfer of word data by memcpy
int big = 0x01020304; /* Big endian area */
extern int little; /* Little endian area */
memcpy(&little,&big,4); /* Transfer by memcpy */
The result of the above transfer is rendered incorrect by word data transfer as follows:
■
Specifying the Option -K Lib when Using a Character String Manipulation Function
When the -K lib option is specified, the compiler performs inline expansion for various character
string manipulation functions. In this case, these functions may employ processing in half-word
or word units to optimize processing. Therefore, the processing for little endian areas is
executed incorrectly.
When processing a little endian area using a character string manipulation function, do not
specify the option -K lib. Also, do not specify the option -04 and -K speed, which include the
option -K lib.
■
Using the Types Double and Long Double
When variables of the types double and long double are accessed, the upper and lower word
are accessed, respectively. Therefore, if double and long double type variables allocated to
little endian areas are accessed, the correct result cannot be acquired.
Variables of the same type allocated to little endian areas can be assigned to each other. As a
result of optimization, however, these assigned variables may be replaced with constants.
01
02
03
04
01
02
03
04
(Big endian area)
(Little endian area)
(Correct result)
memcpy
01
02
03
04