Tool News
 
 
 

Tool News

Products Info
Downloads
Tools FAQs
MESC TOOL NEWS: MESCT-NC30-971101D

NC30WA V.2.00 Release 1
NC30 V.2.00 Release 1
Precaution

Please note the following errors concerning C compilers NC30 V. 2.00 Release 1 and NC30WA V.2.00 Release 1 (with assembler), used with the M16C/60 Series . These errors will be corrected in the next upgraded version.



Immediate Value Right Shift
  1. Problem

    When the operation result between a long-type variable and an immediate value in the range of 0x8000L to 0xffffL is right-shifted, the result is an unsigned shift. The result should be arithmetic shift when normal(MSB becomes "1"), but the actual results in this case are logical shift (MSB becomes "0").

  2. Example
    [C language source example]
           long l,a;
    
           l=(a+0x8000L)>>n;
       

  3. Solution
    Cast the constant with signed long.
    [C language source example]
    
           l=(a+(signed long)0x8000L) >> n;
    
       

NC30WA V.2.00 Release 1, NC30 V.2.00 Release 1 Precaution
MESCT-NC30-971101D


Register Variable Tampering
  1. Occurrence Conditions

    • "-fER" is specified as the compile option.
      Note: "-fER" is the option which make register variable available.
    • TMP variable, storing the register variable, is used in multiple "IF" or "FOR" branches.
      Note: TMP variable is output by C compiler.
    Tampering occurs when both of these conditions are satisfied at the same time.

  2. Error Example
    [C language source example]
           int func(int i){
                 register int k;
    
                 for(k=0;k<100;k++){
                      if(func2(i))  
                          return k;
                 }
                 return 0;
           }
       

  3. Solution
    Please do not use "-fER".

NC30WA V.2.00 Release 1, NC30 V.2.00 Release 1 Precaution
MESCT-NC30-971101D


Constant compare should be an unsigned operation, but occurs as a signed operation.
  1. Occurrence Conditions

    • Comparison with an unsigned char type constant.
    • Compare data is signed constant of 0x80 or greater.
    • The variable compared with a constant is to be calculated.

  2. Error Example
    [C language source example]
    
           unsigned char c;
    
           if(0x90<(c&0x0f))
    

  3. Solution

    Use the `U` specifier to define the constant as unsigned. (Ex: 0x90 --> 0x90U)


NC30WA V.2.00 Release 1, NC30 V.2.00 Release 1 Precaution
MESCT-NC30-971101D


When "-fSSU" is specified as the compile option, more stack data may be provided than in actual use.
  1. Occurrence Conditions

    • Bit-field to bit-field transfer.
    • Bit-field is int type.
    • Both source and destination are registers, and they are different registers.(It is the matter of C compiler.)
    • All registers are in use. (It depends on contents of user program)

  2. Solution
    Do operation (transmission) after substituting source for temporary variable once.

NC30WA V.2.00 Release 1, NC30 V.2.00 Release 1 Precaution
MESCT-NC30-971101D


A system error may occur when "~" tilde operator is applied to bit data.
  1. Occurrence Conditions

    • Source is AUTO type bit field.
    • Source FB offset is not within the -32 to +32 range.
    • Destination is result of bit operation
      Note: When user designats "#pragma SBDATA" or "#pragma ADDRESS", C compiler outputs bit instructions.
    • Source and destination are both 1-byte bit fields.
    • Bit width of source and destination are both 1.

  2. Solution
    Do operation (transmission) after substituting source for temporary variable once.

NC30WA V.2.00 Release 1, NC30 V.2.00 Release 1 Precaution
MESCT-NC30-971101D


4-bit to 4-bit transfer operation may give an unknown value.
  1. Occurrence Conditions

    • Transferring bit field of 4 bits width to bit field of 4 bits width .
    • Source and destination are both `far`.
    • Source and destination are both registers.
    • Source and destination are both R0L
    • Source bit position is the first four bits.
    • Destination bit position is the 4th bit.
    This problem occurs when all the above conditions are satisfied at the same time.

  2. Solution
    Do operation (transmission) after substituting source for temporary variable once.

NC30WA V.2.00 Release 1, NC30 V.2.00 Release 1 Precaution
MESCT-NC30-971101D


Shift-left operation may give an unknown value.
  1. Occurrence Conditions

    • Shift count is not constant (Right operand is not constant).
    • Shift result is converted to lower data type.
    • Storage destination bit width <= shift count value < bit size of shift target

  2. Error Example
    [C language source example]
           char c;
    
           int i,count=9;
           
           c=i << count;
       

  3. Solution

    After storing the shift result into a temporary variable of the same size as the shift target, store it to the destination.


NC30WA V.2.00 Release 1, NC30 V.2.00 Release 1 Precaution
MESCT-NC30-971101D


When a register value is used in an if statement and the result of the if sentence is false, the register value becomes unknown.
  1. Occurrence Conditions

    • A register variable is effective by specifying -fER , or a variable is assigned to the register by specifying an optimization option (-0, -0R, -0S)
    • The register is used again at a statement which is called when the if statement is true.
    • "stz" instruction is output by compiler.

  2. Error Example
    [C language source example]
          func(int i){
             if(i==1)
                       i=2;
             return i;
    
          }
    

  3. Solution

    Describe asm(""); immediately after the if statement.


NC30WA V.2.00 Release 1, NC30 V.2.00 Release 1 Precaution
MESCT-NC30-971101D


An error occurs when there are multiple returns in the inline function.
  1. Error Example
    [C language source example]
           inline func()
           {
                int i;
    
                if(i==1)
                      return 0;
                else if(i==2)
                      return 2;
                return 1;
           }
    

  2. Solution
    Keep all returns in one place.
    [C language source example]
           inline func()
           {
                int i, j=1;
                
                if(i==1)
                      j = 0;
                else if(i==2)
                      j = 2;
                return j;
           }
       


NC30WA V.2.00 Release 1, NC30 V.2.00 Release 1 Precaution
MESCT-NC30-971101D


A 1-bit bit test may return a wrong value.
  1. Occurrence Conditions

    • 1-bit bit field is tested in an if statement.
    • The bit field is char type.
    • The bit field test is performed by pointer-relative.
    • The bit field is assigned on either R0H or R1H register for this operation.

  2. Solution

    Store the bit field to be tested in a temporary variable before the comparison.


NC30WA V.2.00 Release 1, NC30 V.2.00 Release 1 Precaution
MESCT-NC30-971101D


The -WEF (-Werror_file) option doesn't function during compile in the Windows95 version.
  1. Solution

    Please don't use -WEF. Instead, output the file using -Wstdout.


NC30WA V.2.00 Release 1, NC30 V.2.00 Release 1 Precaution
MESCT-NC30-971101D


The offset will deviate when the total of auto variables and the stack return value of register arguments is more than 128 bytes.
  1. Occurrence Conditions

    • Optimization option (-OR, -OS, -O) is not specified.
    • Stack return of register arguments of the function occurs.
    • Total of auto variables and register arguments is more than 128 bytes.

  2. Error Example
    [C language source example]
           func(int i)
           {
    
                int ary[80];
        :
                func2();
    
                ary[3];
    
           }
    

  3. Solution

    Please use the register declaration for the register argument of the function and specify "-fER" as compile option. Or, specify optimization option (-0, -0R, -0S).


NC30WA V.2.00 Release 1, NC30 V.2.00 Release 1 Precaution
MESCT-NC30-971101D


When reading an initialized union member, the initial value may be read even if the value has been modified.
  1. Occurrence Conditions

    • Optimization option (-0, -0R, -0S) is specified.
    • A member of the union is a structure or a union.
    • After a member ("A") is initialized, a value is written to another member ("B").
    • The first member ("A") is then called again.

  2. Error Example
    [C language source example]
           union u{
                struct{
                   unsigned char lowData;
                   unsigned char highData;
                }byte;
                unsigned int word;
           }
    
    
           func()
           {
                union u ustemp;
                int c;
                
                ustemp.bute.highData=0x80;
                ustemp.bute.lowData=0x11;
                ustemp.word=4;
                c=ustemp.byte.highData;
    
            }
    

  3. Solution

    Please insert asm ("") after member initialization.


NC30WA V.2.00 Release 1, NC30 V.2.00 Release 1 Precaution
MESCT-NC30-971101D


The FB offset value of the auto variable may deviate when -Ostack_frame_align (-OFSA) is specified.
  1. Occurrence Conditions

    • A char type auto variable is declared.
    • The effective area of auto variable and those of other auto variables do not conflict.
    • "-OSFA" is specified as the compile option.

  2. Error Example
    [C language source example]
           func()
           {
               char c;
               int i;
    
               i=c;
    
                 return i;
    
           }
    

  3. Solution

    Please don't use -OSFA.




© 2008. Renesas Technology Corp., All rights reserved. Privacy | Legal