Tool News
 
 
 

Tool News

Products Info
Downloads
Tools FAQs
MESC TOOL NEWS: MESCT-NC308WA_1-991001D

NC308WA Precaution

Please take note of the following problem in using C compiler NC308WA (with assembler and integrated development environment) for the M16C/80 series of microcomputers.


  1. Problem
    The problem is described in MESC Technical News No. M16C-37-9910 "Note on Using INT Instruction in M16C/80 Group MCUs" issued on October 1, 1999, and this item of MESC TOOL NEWS provides additional information necessary to use NC308WA.


  2. Workaround
    The example of circumventing this problem described in the above mentioned Technical News can also be described by using the asm function, the #pragma ASM directive. However, if all of the following conditions are met, follow the instruction described below.

    • Software interrupt functions are described in the C language, using the #pragma INTCALL directive.
    • An "enter" instruction is output at the beginning of software interrupt functions because automatic variables are used in software interrupt functions, work areas for complicated expressions are reserved on a frame, etc.
    • The IPL value at issuing an INT instruction is not uniquely determined.


    In such a case, even if the codes sidestepping the problem are described with asm functions and a #pragma ASM directive at the beginning of a function, they are output after an "enter" instruction, resulting in the stack pointer pointing to the shifted location. Therefore, use the FB relative addressing mode in order to read the IPL to be set from the stack. In addition, if automatic variables are initialized at their declarations, they are initialized prior to the sidestepping codes. Then, sure to initialize automatic variables after sidestepping codes. An example of circumventing this problem is shown below.

         [Example]
          ----------------------------------------------------------------------
         |    int func(int);
         |    #pragma INTCALL 63 func()
         |
         |    int func(int i)
         |    {
         |        int a;          /* An "enter" instruction is output 
         |                                       if auto variables etc. exist. */
         |
         |    asm("  pushm   R0");
         |    asm("  stc     FLG,R0");
         |    asm("  mov.b   9[FB],R0H");
         |        /*
         |         * 9[FB] represents the upper bits (IPL value) 
         |         * of the FLG register saved on the stack by an INT instruction
         |         * in FB relative addressing mode.
         |        /*
         |    asm("  and.b   70H,R0H");
         |    asm("  ldc     R0,FLG");
         |    asm("  popm    R0");
         |    asm("  fset    I");
         |
         |    a=0;                /* Be sure to initialize auto variables 
         |                                            after sidestepping codes.*/
         |    ...(Omitted)...
         |    }
         |
          ----------------------------------------------------------------------
    






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