Tool News
 
 
 

Tool News

Products Info
Downloads
Tools FAQs
MESC TOOL NEWS: MESCT-NC79WA-980901D

NC79WA V.3.00 Release 1
Precaution

Please take note of the following problem in using C compiler NC79WA (with assembler and integrated tool manager) for the 7900 series of microcomputers.


Problem on Optimize Option -OS
When optimize option -OS is given, the following incorrect codes are generated.
  1. If the result of evaluating an "if" statement is false, the code (an rts instruction etc.) for a return statement (or the end of a function) of the branch destination is not output.
  2. If data under control of a calling function exists in the frame area, the data cannot correctly be referenced.
Conditions
[Case 1] This problem may occur if the following three conditions are satisfied:
  1. Optimize option -OS is given.
  2. A return statement (or the end of a function) is designated as the branch destination of when the result of evaluating an "if" statement is false.
  3. A subroutine function is designated as the branch destination of when the result of evaluating the "if" statement is true, which is immediately followed by a return statement (or the end of a function).
[Case 2] This problem may occur if the following three conditions are satisfied:
  1. Optimize option -OS is given.
  2. A subroutine function accesses the frame area of the calling function.
  3. The subroutine function is immediately followed by a return statement (or the end of a function).

Examples
  1. Case 1
         [C source File]
          -------------------------------------------------------------------
          
           unsigned int i, j, k;
           void sub2(void);
           void sub1(void)
           {
                   if (i) {
                           if (j){         /* branch 1 */
                                   sub2();
                                   return;
                           }
                                           /* branch 2 */
                   } else {
                           k = 0x01;
                   }
                                           /* return */
           }
          
          -------------------------------------------------------------------
    
         [Generated Codes]
          -------------------------------------------------------------------
          
           _sub1:
                   ._line  7
           ;## # C_SRC :           if (i){
                   lda     A,DT+:_i
                   beq     L2
                   ._line  8
           ;## # C_SRC :                   if (j){         /* branch 1 */
                   lda     A,DT+:_j
                   beq     L4
                   ._line  9
           ;## # C_SRC :                           sub2();
                   jmpl    _sub2
           L4:
           ;                               <=== rtl instruction not outputted
                   ._line  13
           ;## # C_SRC :           } else {
           L2:
                   ._line  14
           ;## # C_SRC :                   k = 0x01;
                   movm.W  DT+:_k,#0001H
                   ._line  17
           ;## # C_SRC :   }
                   rtl
          
           -------------------------------------------------------------------
    
  2. Case 2
         [C Source File]
          -------------------------------------------------------------------
          
            void jmpsub( unsigned int near *);
            unsigned int    out;
          
            void main(void)
            {
                    unsigned int near i = 1;
                    jmpsub( (unsigned int near *)&i);
                    return;
            }
          
            void jmpsub( unsigned int near *p)
            {
                    unsigned int arr[10];
          
                    arr[1] = 0;
                    out = *p;
            }
          
          -------------------------------------------------------------------
    
         [Generated Codes]
          -------------------------------------------------------------------
          
            _main:
                    phd     0
                    subs    #0002H
                    tsd
                    ._line  6
            ;## # C_SRC :           unsigned int near i = 1;
                    movm.W  DP0:1,#0001H    ;       i
                    ._line  7
            ;## # C_SRC :           jmpsub( (unsigned int near *)&i);
                    tda     0
                    inc     A
                    adds    #0002H
                    pld     0              <=== Frame opened
                    jmpl    $jmpsub
            ;
                      :
            (middle lines omitted)
                      :
                    ._line  12
            ;## # C_SRC :   {
                    .DT     __DT
                    .DP0    OFF
                    .glb    $jmpsub
            $jmpsub:
                    ._line  16
            ;## # C_SRC :           out = *p;
                    tax
                    lda     A,DT+:0000H,X  <=== Refers to the frame opened
                    sta     A,DT+:_out
          
                    ._line  17
            ;## # C_SRC :   }
                    rtl
          
          -------------------------------------------------------------------
    

Workaround
When you give optimize option -OS, give optimize blocking option "-Off = 2583" at the same time as described below:
  1. type command line
    C:\> nc79 -OS -Off=2583 sample.c
  2. When TM used
    Give an "-Off = 2583" option by using the [Options...] -> [Extra options] command after selecting [Environment] -> [Project Setting] -> [BUILD] -> [C Compiler].




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