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
Summary of Contents for MB91F109
Page 2: ......
Page 3: ...FUJITSU LIMITED FR30 32 Bit Microcontroller MB91F109 Hardware Manual ...
Page 4: ......
Page 10: ...vi ...
Page 24: ...xx ...
Page 96: ...72 CHAPTER 2 CPU ...
Page 224: ...200 CHAPTER 4 BUS INTERFACE ...
Page 234: ...210 CHAPTER 5 I O PORTS ...
Page 268: ...244 CHAPTER 9 U TIMER ...
Page 290: ...266 CHAPTER 10 UART ...
Page 314: ...290 CHAPTER 12 16 BIT RELOAD TIMER ...
Page 322: ...298 CHAPTER 13 BIT SEARCH MODULE ...
Page 392: ...368 CHAPTER 16 FLASH MEMORY ...
Page 432: ...408 APPENDIX E Instructions F Table E 2 Instruction Formats OP rel11 5 11 ...
Page 448: ...424 APPENDIX E Instructions ...
Page 449: ...425 INDEX INDEX The index follows on the next page This is listed in alphabetic order ...
Page 458: ...434 INDEX ...
Page 460: ......
Page 461: ...FUJITSU SEMICONDUCTOR FR30 32 Bit Microcontroller MB91F109 Hardware Manual ...