Technical information

Operating Precautions for CPDW9X/NT-CDR-V85X, Y-GHS-MULTI-V800
TM
Customer Notification r20tu0003ed1812 43
No. a31
Wrong memory access optimization on SFR's volatile variables.
Version Information
V3.5.1
Details
The compiler makes wrong memory access optimization on SFR's volatile variables.
Example:
In the list file below, after execution of the 'and' instructions, r8 holds variable 'address' and r6
hold variable 'data' contents. The contents of register r6 (data) is written first, then r8 (address).
As both target variables FLRAP and FLRDTL/H are volatile type, this rearrangement is wrong.
test.c:
#define FLRDTL_ADRS 0xfffffcc8
#define FLRDTH_ADRS 0xfffffcc9
#define FLRAP_ADRS 0xfffffcca
#define FLRDTL *((volatile unsigned char *) FLRDTL_ADRS)
#define FLRDTH *((volatile unsigned char *) FLRDTH_ADRS)
#define FLRAP *((volatile unsigned short *) FLRAP_ADRS)
void Set_DPRAM8( unsigned short address, unsigned char data )
{
if( (address & 0x0001) == 0x0000 )
{
FLRAP = address;
FLRDTL = data;
}
else
{
FLRAP = address-1;
FLRDTH = data;
}
}
Command Sequence
ccv850e c noobj -Ospace test.c