Fujitsu FR60 Hardware Manual page 586

32-bit microcontroller mb91301 series
Hide thumbs Also See for FR60:
Table of Contents

Advertisement

APPENDIX D NOTES ON USING A LITTLE ENDIAN AREA
[Example] Assigning a structure to the structure variable little_st in a little endian area
struct tag { char c; int i; } normal_st;
extern struct tag little_st;
#define
void main(void) {
STRMOVE(little_st,normal_st);
}
Since the allocation of the members of a structure is different from compiler to compiler, the
allocation of members by one compiler will be different from the allocation by another compiler.
If the allocation method is different, it is not possible to obtain the correct result even the method
described above is used.
If the allocation of members of a structure varies, do not allocate any structure variable to a little
endian area.
■ Operations other than the String Arrangement Using a String Manipulation Function
Since string manipulation functions provided as a standard library perform their processing in
bytes, correct results cannot be obtained if processing using a string manipulation function is
performed in an area with a type other than the char type, unsigned char type, or signed char
type allocated within a little endian area.
Do not perform processing such as that described above.
[Example of incorrect coding] Transfer of word data using memcpy
int big = 0X01020304;
extern int little;
memcpy(&little,&big,4); /* Transfer using memcpy */
The result of the above code is shown below, and, as the result of transferring word data, is an
error.
566
STRMOVE(DEST,SRC) DEST.c=SRC.c;DEST.i=SRC.i;
/* Big endian area
/* Little endian area
(Big endian area)
01 02
03
04
memcpy
(Correct result)
*/
*/
(Little endian area)
01
02
03
04
04
03 02
01

Advertisement

Table of Contents
loading

Table of Contents