Home
R8C/Tiny,M16C/60,30,Tiny,20,10 Series C Compiler Package V
Contents
1. 57 B S assembler Macro Spe 62 B 8 1 Outline of Assembler Macro Function 62 B 8 2 Description Example of Assembler Macro 62 B 8 3 Commands that Can be Written by Assembler Macro Function 63 Appendix C Overview of C Language Specifications RIT Gil Performance SpecifICallOs cere retten tabac edan EE on nad 1 C 1 1 Overview of Standard Specifications senrose renns e rN 1 C 1 2 Introduction to NC30 Performance ssssssssessesseeeeeeeneen nennen nennen nnne 2 d 5 be A MISMA fash lente 2 b Source File Coding SpeciiicalloTiS aui NE 2 c NOeSO Speecillcalioliss idis Meat A aor tus Mtis M E SM ISSN TU hot MARINES MM tosis TEE ARA 3 G2 Standard Language SpeciflGallofls Joni erecta rero coii rot vadat edens eth als 4 es NEC cT M H 4 oad tenes 4 NC30 MANUAL VII b tag d ELI 4 MOMS VANS septa cis induta E mp N a desea 5 d Gharacier Witetal Sica
2. Function Contents Reentrant acos Calculates arc cosine asin Calculates arc sine atan Calculates arc tangent atan2 Calculates arc tangent ceil Calculates an integer carry value cos Calculates cosine O cosh Calculates hyperbolic cosine Calculates exponential function fabs Calculates the absolute value of a double precision float O ing point number floor Calculates an integer borrow value O fmod Calculates the remainder O frexp Divides floating point number into mantissa and exponent O parts labs Calculates the absolute value of a long type integer O Idexp Calculates the power of a floating point number O log Calculates natural logarithm O log10 Calculates common logarithm O modf Calculates the division of a real number into the mantissa O and exponent parts pow Calculates the power of a number O sin Calculates sine O sinh Calculates hyperbolic sine O sqrt Calculates the square root of a numeric value O tan Calculates tangent O tanh Calculates hyperbolic tangent O h Integer Arithmetic Functions The following lists integer arithmetic functions Table E 9 Integer Arithmetic Functions Function Contents Reentrant abs Calculates the absolute value of an integer O bsearch Performs binary search in an array O div Divides an int type integer and calculates the remainder O labs Calculates the absolute value of a long type integer O Idiv Divides a lo
3. 2 B 1 2 Format of Variable Declaration xs nte tute cedet et cbe sesta 3 B 1 9 Format of Pointer type Variable iie ne 4 B 1 4 Format of Function Declaration B 1 5 near far Control by nc30 Command Line Options see 6 B 1 6 Function of Type conversion from near to far sssssssseeeeme 6 B 1 7 Checking Function for Assigning far Pointer to near Pointer 6 B 1 8 Declaring funcllotissus sisi iia iinet ecce b e DO acea nie 7 B 1 9 Function for Specifying near and far in Multiple 8 1 10 Notes onimnear and far AttTIDUtes oet roo bibere derer btt et ipd eap 9 a Notes on near and far Attributes of Functions cccs eesereeeeseeeeseeeeesneneeneneeeeenteeees 9 b Notes on near and far Modifier Syntax iocis is ei IRE RR RE IRL HARI EM eini 9 asi FUNCHOM pul ete rata 10 B 2 4 Overview otashi FUNGON onde re Pete i ee Etat EL POUR 10 NC30 MANUAL VI B 2 2 Specifying FB Offset Value of auto Variable 11 B 2 3 Specifying Register Name of register Variable sssseee 14 B 2 4 Specifying Symbol Name of extern and static 15 B 2 5 Specification Not Dependent on Storage
4. Example C source program struct tag int bitmap char code poi nter pragma EXT4MPTR pointer mai n Maps to prot section data pointer gt bitmap Assembly language source program mov w pointer AO mov w pointer 2 A1 bclr 3 A1 Change the bank bset 2 A1 Ide w A1A0 2 FB Figure B 70 Example Use of pragma EXT4MPTR Declaration Note 1 Before using this feature check to see if the microcomputer and the system hardwa re support 4M byte extension space mode 2 If the option R8C is used this declaration is ignored Appendix B 43 Appendix B Extended Functions Reference B 7 3 Using Extended Functions for Target Devices NC30 includes the following extended functions for target devices pragma ADDRESS pragma EQU Function Specifies the absolute address of a variable For near variables the specified address is within the bank Syntax pragma ADDRESSAvariable name absolute address Description The absolute address specified in this declaration is expanded as a character string in an assembler file and defined in pseudo instruction EQU The format for writing the numeri cal values therefore depends on the assembler as follows Append B or b to binary numbers Append O or o to octal numbers Write decimal integers only Append H or h to hexadecimal numbers If the number starts with letters A to F precede it with 0 Rules 1 A
5. Wstop at warning WSAW Stops compiling the source files if a warning occurs during compiling and returns the compiler end code 10 Wnesting comment WNC _ Outputs a warning for a comment including Wccom max warnings WCMW This option allows you to specify an upper limit for the Warning Count number of warnings output by ccom30 Wall None Displays message for all detectable warnings however not including alarms output by Wlarge to small and Wno used argument Wmake tagfile WMT _ Outputs error messages to the tag file of source file by source file Wuninitialize variable WUV Outputs a warning about auto variables that have not been initialized Wlarge to small WLTS Outputs a warning about the tacit transfer of variables in descending sequence of size Wno warning stdlib WNWS Specifying this option while Wnon prototype or Wall is specified inhibits Alarm for standard libraries which do not have prototype declaration Wno used argument WNUA Outputs a warning for unused argument of functions Wno used static function WNUSF For one of the following reasons a static function name is output that does not require code generation Wno used function WNUF Displays unused global functions when linking Wundefined macro WUM Warns you that undefined macros are used in if Wstop at link WSAL Stops linking the source files if a warning occurs during
6. Macro definitions can be nested to a maximum of 20 levels as shown below define XYZ1 100 define XYZ2 XYZ1 abbreviated define XYZ20 XYZ19 undef We CR Function Nullifies an identifier that is defined as macro Format undefAidentifier Description Nullifies an identifier that is defined as macro e The following four identifiers are compiler reserved words Because these identifi ers must be permanently valid do not undefine them with undef Name of source file Current source file line No Date compiled mm dd yyyy Time compiled hh mm ss Appendix C 18 Appendix C Overview of C Language Specifications include Function Takes in the specified file Format 1 includeA lt file name gt 2 includeA file name 3 includeAidentifier Description t Takes in file name gt from the directory specified by nc30 s command line option I Searches lt file name gt from the directory specified by environment variable INC30 if it s not found 2 Takes in file name from the current directory Searches file name from the following directory in sequence if it s not found 1 The directory specified by nc30 s startup option 2 The directory specified by environment variable INC30 3 lf the macro expanded identifier is file name gt or file name this command takes in that file from the directory according to rules of search 1 or 2 The maximum nu
7. data_FO section vector section OFFEO0H bss FO section fvector section OEFFFFH OFFFFFH Figure 2 29 Example Section Mapping NC30 MANUAL 46 Chapter 2 Basic Method for Using the Compiler b Outline of memory mapping setup file About sect30 inc This program is included from ncrt0 a30 It performs the following process mainly Maps each section in sequence 6 Sets the starting addresses of the sections Defines the size of the stack and heap sections 9 Sets the interrupt vector table 9 Sets the fixed vector table c Modifying the sect30 inc Figure 2 30 summarizes the steps required to modify the startup programs to match the target system 2 2 2 Customizing the Startup Program 5 2 e K o Map order each section and set starting addresses v Set the interrupt vector table wv Set the special page vector table ourocioes Figure 2 30 Example Sequence for Modifying Startup Programs NC30 MANUAL 47 Chapter 2 Basic Method for Using the Compiler d Mapping and Order Sections and Specifying Starting Address Map and order the sections to memory and specify their starting addresses mapping programs and data to ROM and RAM in the sect30 inc include file of the startup program The sections are mapped to memory in the order they are defined in sect30 inc Use the as30 pseudo instruction ORG to specify their starting addresses Figure 2 31 is an ex
8. 0 filename Function Specifies the name s of the file s absolute module file map file etc gener ated by In30 This option can also be used to specify the file name includes the path You must NOT specify the filename extension Syntax nc30A o filenameA C source file gt Execution i nc30 o test sample ncrt0 a30 sample c example M16C 60 NC30 COMPILER V X XX Release X COPYRI GHT C XXXX XXXX RENESAS TECHNOLOGY CORPORATION ALL RIGHTS RESERVED AND RENESAS SOLUTIONS CORPORATION ALL RIGHTS RESERVED ncrt0 a30 Sample c cd test 15 total 65 drwxr x 2 toolusr 512 Aug 17 16 13 drwxrwxrwx 11 toolusr 3584 Aug 17 16 14 1 toolusr 44040 Aug 17 16 14 sample x30 In this example the option is used to specify that sample x30 are output to directory test Appendix A 8 Appendix A dir directory Name Command Option Reference Function Syntax Execution example Note Output file specification This option allows you to specify an output destination directory for the output file nc30A dir directory name ncrt0 a30 sample c cd test sample 15 total 65 drwxr x 2 toolusr drwxrwxrwx 11 toolusr 1 toolusr sample nc30 dir test sample o ncrt0 a30 sample c M16C 60 NC30 COMPILER V X XX Release X COPYRIGHT C RENESAS TECHNOLOGY CORPORATION ALL RIGHTS RESERVED AND RENESAS SOLUTIONS
9. eiea enp e e RAE 19 a input TORIW L 2 55 95 52 58 220 tgates sheet ade iion iaiia 19 b huleson command tile descrpllOl too e tbese oth ees tenen medi sete bete estre 14 c Precautions to be observed when using a command 6 14 2 1 9 Notes on NC30 Command Line Options ssseeeeeeeeeenen een 14 a Notes on Coding nc30 Command Line Options ri rettet 14 b Priority of Options for Controlling Compile driver 14 2 1 4 inc30 Command Line ODLOFS uscire 15 a Options tor Controlling Compile DIVET 5 3 eit ex toe te HA ba UE tin dust Exp Puro 15 b Options Specifyirig Output Files s a EE a a i 15 d Options Tor Debugging cscs eicit eee so a re tr hp vies bg 16 c Version and command line Information Display 16 e Opimizauorn ODINS o doit cos Dual ap voles 17 f Generated Code Modification ODpflOtS Anti atest iae eens 18 G bibraty epeciylmg ODIO 5 9 ace ub e od a Beta 20 hz Waning ODHge ua rie ed 20 i ASsemble and desee 21 2 2 Preparing the Startup Program essiri
10. 48 1 Rules for Mapping Sections to Merno occasio om aera tremere merae speres 48 2 Example Section Mapping in Single Chip 50 e Semino Interr pt Vector Table caeco ceo ctio e cima et Naara 54 f Setting SPECIAL Page Vector Table iu acit SEE USE HAIR M E ONA 56 pope m ETE 57 3 1 1 Notes about Version up of compiler esesseeeeeeeeeneeeeee nnne 57 3 1 2 Notes about the M16C s Type Dependent Part esee 58 3 1 9 AbDOUEODLUITIZATOEs s ERO Sos ARA 59 a 950 59 Ch MOAI GISSS VAMAMO d amp GBBS 59 2 59 3 Programs mob 60 4 Operation between CONSTAINS neus ioo s oaa eph riepa ranan A E ap 60 5 Selectiomof OPTIMUM 60 b About the volatile qualiflgr 60 3 1 4 Precautions on Using register Variables esseseeeeerenneennenns 61 9 1 5 About Startup Handling 2 nt iem cert EE E 61 a register qualification and fenable register option sesssessseseeessss 61 b About register qualification and optimization options seeenn 61 For Greater Code EffIcIencysitesd et
11. arbitrary real number ReturnValue Returns the cosine of given real number x handled in units of radian Appendix E 24 cosh Appendix E Standard Library Mathematical Functions Function Format Method Argument Calculates hyperbolic cosine include lt math h gt double cosh x function double x arbitrary real number ReturnValue Returns the hyperbolic cosine of given real number x div Integer Arithmetic Functions Function Format Method Argument Divides an int type integer and calculates the remainder include lt stdlib h gt div_t div number denom function int number Dividend int denom Divisor ReturnValue Returns the quotient derived by dividing number by denom and the remainder of the division Description e Returns the quotient derived by dividing number by denom and the remainder of the division in structure div t OG div t is defined in stdlib h This structure consists of members int quot and int rem Appendix E 25 Appendix E Standard Library exp Mathematical Functions Function Calculates exponential function Format include lt math h gt double exp x Method function Argument double X arbitrary real number ReturnValue e Returns the calculation result of an exponential function of given real number x fabs Mathematical Functions Function
12. invalid operands The operation contains an error Check the expressions on the left and right sides of the operator invalid operands The operator contains an error Check the expressions on the left and right sides of the operator invalid operands The operation contains an error Check the expressions on the left and right sides of the operator invalid operands The operation contains an error Check the expressions on the left and right sides of the operator invalid lt lt operands The lt lt operation contains an error Check the expressions on the left and right sides of the operator invalid operands 6 The lt lt operation contains an error Check the expressions on the left and right sides of the operator invalid operands The operation contains an error Check the expressions on the left and right sides of the operator invalid operands 6 The operation contains an error Check the expressions on the left and right sides of the operator invalid operands The operation contains an error Check the expressions on the left and right sides of the operator invalid gt operands The gt operation contains an error Check the expressions on the left and right sides of the operator invalid gt gt operands The gt gt
13. Multiple command lines can be written in a command file New line characters in a command file are replaced with space characters The maximum number of characters that can be written in one line of a command file is 2 048 An error results when this limit is exceeded c Precautions to be observed when using a command file A directory path can be specified for command file names An error results if the file does not exist in the specified directory path Command files for 30 whose file name extension is cm are automatically generated in order for specifying files when linking Therefore existing files with the file name exten sion cm if any will be overwritten Do not use files which bear the file name extension cm along with this compiler You cannot specify two or more command files simulta neously If multiple files are specified the compiler displays an error message Too many command files 2 1 3 Notes on NC30 Command Line Options a Notes on Coding nc30 Command Line Options The nc30 command line options differ according to whether they are written in uppercase or lowercase letters Some options will not work if they are specified in the wrong case b Priority of Options for Controlling Compile driver There are the following priorities in the option about control of a compile driver E P c High Priority low gt Therefore if the following two options are specified at the same
14. A A Space or tab code optional Indicates that part of file listing has been omitted Additional descriptions are provided where other symbols are used NC30 MANUAL XI NC30 User s Manual NC30 MANUAL XII Chapter 1 Introduction to NC30 Chapter 1 Introduction to NC30 This chapter introduces the processing of compiling performed by NC30 and provides an example of program development using NC30 1 1 NC30 Components NC30 consists of the following eight executable files is SE Compile driver POPPO P Preprocessor Reels ET Compiler A AO P1380 Assembler Optimizer 5 StkViewer amp stk STK viewer amp stack size calculation Utility StkViewer is a GUI Graphical User Interface Utility 0 Utl30 i e SBDATA declaration amp SPECIAL page Function declaration Utility 7 MapViewer Map viewer included for only the Windows TM version MapViewer is a GUI Graphical User Interface Utility Items 4 to 7 are not included in the entry version 1 2 NC30 Processing Flow Figure 1 1 illustrates the NC30 processing flow C language source file nc30 Compile driver 30 Preprosesser ccom3o Compiler aopt30O Assembler Optimizer Assembly language source file Stack Size utility SBDATA defin
15. D32 This option specifies that the double type be handled in 32 bit data length as is the float type switch table INST When this option is specified the code which branches since it compares is generated to a switch statement fmake_vector_table Automatically generates the variable interrupt vec tor table fmake_special_table IMST Automatically generates the special page vector table ffar_pointer fFP Change the default attribute of pointer type variable to far R8C None Generates code suitable for the R8C Tiny series Appendix A 27 Appendix A Command Option Reference fansi Modify generated code Function Validates the following command line options fnot reserve asm Removes asm from reserved words fnot reserve far and near Removes far and near from reserved words fnot reserve inline Removes inline from reserved words fextend to int Extends char type data to int type data to per form operations In the entry version this option is always enabled i e assumed to be speci fied Therefore it cannot be enabled or disabled by specification Supplement When this option is specified the compiler generates code in conformity with ANSI standards fnot reserve asm fNRA Function Removes asm from the list of reserved words However _asm which has the same function remains as a reserved
16. Description Reads one character from the stream Interprets code 0x1A as the end code and ignores any subsequent data getchar Function Reads one character from stdin Format include lt stdio h gt int getchar void Method macro Argument argument used ReturnValue Returns the one input character Returns EOF if an error or the end of the file is encountered Description Reads one character from stream stdin Interprets code 0x1A as the end code and ignores any subsequent data Appendix E 35 Appendix E Standard Library gets Input Output Functions Function Reads one line from stdin Format include lt stdio h gt char far gets buffer Method function Argument char far buffer Pointer of the location to be stored in ReturnValue Returns the pointer of the location to be stored the same pointer as given by the argument if normally input Returns the NULL pointer if an error or the end of the file is encountered Description Reads character string from stdin and stores it in the buffer The new line character n at the end of the line is replaced with the null character 07 Interprets code 0x1A as the end code and ignores any subsequent data init Input Output Functions Function Initializes the stream Format include lt stdio h gt void init void Method function Argument argument used ReturnValue No value i
17. Figure B 3 Memory Location of Variable Appendix B 3 Appendix B Extended Functions Reference B 1 3 Format of Pointer type Variable Pointer type variables by default are the near type 2 byte variable A declaration ex ample of pointer type variables is shown in Figure B 4 9 Example int ptr Figure B 4 Example of Declaring a Pointer Type Variable 1 2 Because the variables are located near and take on the variable type far the description in Figure B 4 is interpreted as in Figure B 5 Example int near near ptr Figure B 5 Example of Declaring a Pointer Type Variable 2 2 The variable ptr is a 2 byte variable that indicates the int type variable located in the near area The ptr itself is located in the near area Memory mapping for the above example is shown in Figure B 6 Figure B 6 shows memory maps for above examples spe near area I dre Figure B 6 Memory Location of Pointer type Variable Appendix B 4 Appendix B Extended Functions Reference When near far is explicitly specified determine the size of the address at which to store the variable function that is written on the right side A declaration of pointer type variables that handle addresses is shown in Figure B 7 Example 1 int far ptr Example 2 int far ptr2 Figure B 7 Example of Declaring a Pointer Type Variable 1 2 As explained earlier unless near far is specified the compiler handles the
18. Method function Argument double X arbitrary real number ReturnValue 6 Returns the sine of given real number x handled in units of radian sinh Mathematical Functions Function Calculates hyperbolic sine Format include lt math h gt double sinh x Method function Argument double x arbitrary real number ReturnValue 6 Returns the hyperbolic sine of given real number x Appendix E 64 Appendix E Standard Library sprintf 5 Input Output Functions Function Writes text with format to a character string Format int sprintf pointer format argument Method function Argument char far pointer Pointer of the location to be stored const char far format Pointer of the format specifying character string ReturnValue Returns the number of characters output Description Converts argument to a character string as specified in format and stores them from the pointer Format is specified in the same way as in printf sqrt Mathematical Functions Function Calculates the square root of a numeric value Format include lt math h gt double sqrt x Method function Argument double X arbitrary real number ReturnValue Returns the square root of given real number x Appendix E 65 Appendix E Standard Library srand Integer Arithmetic Functions Function Imparts seed to a pseudo random number gen
19. b features of the asm function Ex cnnot be referred to correctly void func int i intj asm mov w 2 FB 4 FB J i Appendix B 20 Appendix B Extended Functions Reference In the above case because the compiler determines that i and j are not used within the function func it does not output codes necessary to construct the frame in which to reference the arguments For this reason the arguments cannot be referenced correctly 4 About branching within the asm function The compiler analyzes program flow in the intervals in which registers and variables respectively are effective as it processes the program Do not write statements for branching including conditional branching in the asm function that may affect the program flow b About Register 1 Do not destroy registers within the asm function If registers are going to be de stroyed use push and pop instructions to save and restore the registers 2 NC30 is premised on condition that the SB register is used in fixed mode after being initialized by the startup program If you modified the SB register write a statement to restore it at the end of consecutive asm functions as shown in Figure B 37 asm SB asm LDC 40 SB asm MOV W port SB SB changed abbreviated asm SB SB y SB returned to original state asm LDC amp SB 58 Figure B 37 Restoring Modified Static Base SB register
20. ened 6 S Operati ET e m E ET 7 E E 7 NE ODD TET ar 7 S X NNI PT 8 Data 8 By 8 Data TY PC and seats 8 C29 EXDpEIGSSIOFS Liens cite 9 xm MEC cc 11 Van Ale DOC AAU OM scsi mosso uU CE 11 Be 06 8 quei vett eder 12 C225 Statement Ps creel 19 amp Labeled m 19 D Compound StATSMEN ssc AL CRURA MIELE REAL ELE Spr cUidA 14 c Expression y Bull Statement x Se 14 d Selecion ale Ie Iit LM LU ENUETR REM AM RENOVARE dE PIRE cag tacget cued se 14 e Iteration Slatemell ui LERRA iai rat 14 Jn ES COLO ING FIT o adds 15 g Assembly Language 15 G3 Preprocess COmlmatds ecco eio cocc ot ee equae dede a aub dieu 16 C 3 1 List of Preprocess Commands Available sse 16 C 3 2 Preprocess Commands Reference essssssssssseeeeeneeennee nnne 16 53 83 Piedefined MaGctO5 pie Ret eter r
21. remainder omitted This declaration is interpreted as the following extern int far idata 10 func remainder omitted Figure B 13 Integrated Function of Variable Declaration As shown in this example if there are many declarations the type can be declared by specifying near or far in one of those declarations However an error occurs if there is any contention between near and far specifications in two or more of those declarations You can ensure consistency among source files by declaring near or far using a common header file common header file common h extern int far data C source file C source file a c b c include common h include common h main int data 10 data 1 Figure B 14 Example of Common header file Declaration Appendix B 8 Appendix B Extended Functions Reference B 1 10 Notes on near and far Attributes a Notes on near and far Attributes of Functions Functions always assume the far attribute Do not declare functions with near NC30 will output a warning when you declare the near attribute for a function b Notes on near and far Modifier Syntax Syntactically the near and far modifiers are identical to the const modifier The following code therefore results in an error This is not permitted Figure B 15 Example of Variable Declaration Appendix B 9 B 2 B 2 1 Appendix B Extended Functions Reference asm Function NC30 allows you to i
22. section bss DATA bss FO top Far ROM data area section rom_FE ROMDATA org 0F0000H rom FE top Section rom FO ROMDATA rom FO top nitial data of data section section data SEI ROMDATA data SEI top section data SOI ROMDATA data SOI top Section data NEI ROMDATA data NE 0p Section data NOI ROMDATA data NO 0p Section data FEI ROMDATA data FE 0p Section data FOI ROMDATA data FO 0p Section switch table ROMDATA switch table top Code area section program section interrupt 0rg must be set internal ROM area section program 5 Figure 2 13 Startup Program List 8 sect30 inc 2 11 NC30 MANUAL 29 Chapter 2 Basic Method for Using the Compiler Tf MVT 0 variable vector section section vector ROMDATA variable vector table org VECTOR ADR if Me0TYPE 1 word dummy in vector 0 BRK word dummy in vector 1 word dummy in vector 2 word dummy in vector 3 word dummy in vector 4 word dummy in vector 5 word dummy in vector 6 word dummy in vector 7 word dummy in vector 8 word dummy in vector 9 word dummy in vector 10 word dummy in DMAO0 for user vector 11 word dummy in DMA1 2 for user vector 12 word dummy in input key for user vector 13 word dummy in AD Convert for user vector 14
23. silent Compile driver control Function Suppresses the display of copyright notices at startup Execution nc30 c silent sample c example sample c Appendix A 6 Appendix A Command Option Reference dsource dS Function Generates an assembly language source file extension a30 with a C lan guage source list output as a comment Not deleted even after assembling Supplement When the S option is used the dsouce option is automatically enabled The generated files a30 and r30 are not deleted Use this option when you want to output C language source lists to the assem bly list file dsource in list dSL Function n addition to the dsource function generates an assembly language list file filename extension Ist Appendix A 7 Appendix A Command Option Reference A 2 2 Options Specifying Output Files Table A 2 shows the command line option that specifies the name of the output machine language data file Table A 2 Options for Specifying Output Files Option Function ofilename Specifies the name s of the file s absolute module file map file etc generated by In30 This option can also be used to specify the destina tion directory This option can also be used to specify the file name includes the path Do not specify the filename extension dir Specifies the destination directory of the file s absolute module file map file etc generated by In30
24. 855 18 B 2 6 Selectively suppressing optimization 19 B27 Notes ordthe asmi FU MCUO Mics xs ca toe sa inesse AMARE ee EL IIo SetR 20 a Extended Features Concerning asm functions sessseeeeeeee 20 De JADOUEIOOISIBI dro et eitis ees utat oda recti EH e IUS bte tue 21 NE Notes om LADCIS A N 21 B 3 Description of Japanese Characters sssssssssessssseenee eene 22 B 3 1 Overview of Japanese Characters sssessssssssessseeeeeneenee nnne nnne nennen 22 B 3 2 Settings Required for Using Japanese Characters sssssseeees 22 B 3 3 Japanese Characters in Character Strings esesssseseeeeeeeneeenen 23 B 3 4 Using Japanese Characters as Character Constants cccecsssceeeeeeeeeeeeeeeseeeeeees 24 B 4 Default Argument Declaration of Function ssssssseeeeeeenene 25 B 4 1 Overview of Default Argument Declaration of Function seseeeees 25 B 4 2 Format of Default Argument Declaration of Function seeeeee 25 B 4 3 Restrictions on Default Argument Declaration of 27 Bb nlinerunctom DeclaratiQl 5 1 2 cnt ote oct eee iu sre a oi 28 B 5 1 Overview of inline Storage Class ueteri ree bez tese c
25. ReturnValue 6 Returns a pointer to the character string at the destination of copy Description Copies character string 62 ending with NULL to area 51 9 After copying the character string ends with NULL When you specify options O OR or OS the system may selects functions with good code efficiency by optimization strcspn Function Calculates the length number of unspecified characters that are not found in the other character string Format include lt string h gt size t strcspn s1 s2 Method function Argument const char _far s1 Pointer to the character string to be searched in constchar far s2 Pointer to the character string to be searched for Return Value Returns the length number of unspecified characters Description 9 Calculates the size of the first character string consisting of characters other than those in s2 from area s1 and searches the characters from the beginning of s1 9 You cannot search for O Appendix E 69 Appendix E Standard Library stricmp String Handling Functions Function Compares character strings All alohabets are handled as upper case letters Format include lt string h gt int stricmp 51 52 Method function Argument char far s1 Pointer to the first character string to be compared char far s2 Pointer to the second character string to be compared ReturnValue ReturnValue 0 The two character strings
26. The object type pointed to by the pointer is incor rect Check the pointer type incomplete return type An attempt is made to reference an return vari able of incomplete type Check return variable incomplete struct member An attempt is made to reference an struct mem ber of incomplete Define complete structs or unions first init elements overflow ignored 6 The initialization expression exceeded the size of the variable to be initialized Make sure that the number of initialize expres sions does not exceed the size of the variables to be initialized inline function is called as normal function before change to static function The function declared in storage class inline is called as an ordinary function Always be sure to define an inline function before using it integer constant is out of range The value of the integer constant exceeded the value that can be expressed by unsigned long Use a value that can be expressed by unsigned long to describe the constant interrupt function called The function specified by pragma INTERRUPT is called Be careful not to call an interrupt handling func tion interrupt function can t return value The interrupt handling function specified by pragma INTERRUPT is using a return value Return values cannot be used in an interrupt function Delete the return value interrupt function
27. utl 30 sp30 ncrt0 x30 o special RET 96 Prompt ncrt0 x30 Name of map file Figure G 8 Example utl30 Command Line 15 pragma SPECIAL PAGE Utility SBDATA Size 255 pragma SPECIAL 255 funcl size 2 100 ref pragma SPECIAL 254 func2 size 100 ref pragma SPECIAL 253 func3 size 100 ref End of File 10 7 3 5 Figure G 9 SPECIAL Page Function declaration File special h P pragma SPECIAL PAGE Utility special page definition SPECIAL macro NUM 0rg OFFFFEH NUM 2 glb SPECIAL QNUM word SPECIAL QNUM amp OFFFFH endm SPECIAL 255 SPECIAL 254 SPECIAL 253 End of File Figure 4 10 SPECIAL Page vector declaration File special inc You include the SPECIAL Page Finction declaration file generated above in a program as a header file Fig G 11 shows an example of making setting in a SPECIAL Page Func tion declaration File Appendix G 13 Appendix G The SBDATA declaration amp SPECIAL Page Function declaration Utility utl30 G 6 G 6 1 include special h func o mmi t Figure G 11 Example of making settings in a SPECIAL Page Function File Includes during startup the SPECIAL Page vector definition file as a file to be included Fig G 12 shows an example of setting up a SPECIAL Page vector definition file o mmi t Section vector include special inc o
28. Appendix G The SBDATA declaration amp SPECIAL Page Function declaration Utility utl30 G 2 3 utl30 Command Line Options The following information input parameters is needed in order to start utl30 Table G 1 shows the utl30 command line options Table G 1 utl30 Command Line Options Option Short form Description sb30 None sp30 sb30 gt Outputs SBDATA declaration sp30 gt Outputs SPECIAL page function dec laration use utl30 always specify one of the two op tions If neither option is specified an error is assumed o function name gt None Outpus the result of SBDATA declaration or SPECIAL Page Function declaration to a file With this option not specified outputs the result to the host machine s either EWS or personal computer standard output device No exten sions can be specified If the specified file already exists the result is written to the standard output device fover_write FOW Forcibly writes over the output file name speci fied with the o option all None When used simultaneously with the sb30 option Because the usage frequency is low SBDATA declaration is output in the form of a comment for even the variables that are not placed in the SB area When used simultaneously with the sp30 option Because the usage frequency is low SPECIAL declaration is output in the form of a comment for even the functions that are not placed in the SPE CIAL p
29. Appendix A 50 Appendix A Command Option Reference Wuninitialize_variable WUV Function Outputs a warning for uninitialized auto variables This option is effective even when Wall is specified Supplement If an auto variable is initialized in conditional jump by for example a if or a for statement in the user application the compiler assumes it is not initialized Therefore when this option is used the compiler outputs a warning for it a Example main int i int val for i 0 i lt 2 I val 1 Initalize by logical ff val Wlarge to small WLTS Function Outputs a warning about the substitution of variables in descending sequence of size A warning may be output for negative boundary values of any type even when they fit in the type This is because negative values are considered under language conventions to be an integer combined with the unary operator For example the value 232768 fits in the signed int type but when broken into and 32768 the value 32768 does not fit in the signed int type and consequently becomes the signed long type Therefore the immediate value 32768 is the signed long type For this reason any statement like int i 32768 gives rise to a warning 6 Because this option outputs a large amount of warnings warning output is suppressed for the type conversions listed below Assignment from char type variables to char
30. Check access permission to the processing systems Or if access permission is OK check that the direc tory of the processing system is correctly set in the environment variable can t open command file Can not open the command file specified by Specify the correct input file too many options 6 This error message is not normally displayed It is an internal error Contact Renesas Solutions Corp Result too large 6 This error message is not normally displayed It is an internal error OContact Renesas Solutions Corp Too many open files 6 This error message is not normally displayed It is an internal error OContact Renesas Solutions Corp Appendix F 3 Appendix F Error Messages F 3 cpp30 Error Messages Tables F 3 to F 6 list the error messages output by the cpp30 preprocessor and their countermeasures Table F 3 cpp30 Error Messages 1 4 NO Error message Description and countermeasure 1 illegal command option 6 Input filename specified twice Specify the input filename once only 6 The same name was specified for both input and output files Specify different names for input and output files 9 Output filename specified twice Specify the output filename once only 6 The command line ends with the o option Specify the name of the output file after the o option 9 The I option specifying the include file path exceeds the limit Specify
31. Serial communication is set to UART1 in the M16C 60 series s two UARTs device c is written so that the UARTO can be selected using the conditional compile commands as follows 5 6 define UARTO 1 Specify these commands at the beginning of device c or specify following option when compiling 6 DUARTO To use both UARTs modify the file as follows 1 Delete the conditional compiling commands from the beginning of the device c file 2 Change the UARTO special register name defined in pragma EQU to a variable other than UART1 3 Reproduce the level 3 functions sget and sput for UARTO and change them to different variable names such as sgetO and sputo 4 Also reproduce the speed function for UARTO and change the function name to something like speedO This completes modification of device c Next modify the init function init c which makes the initial I O function settings then change the stream settings see below Appendix E 87 Appendix E Standard Library b Stream Settings The NC30 standard library has five items of stream data stdin stdout stderr stdaux and stdprn as external structures These external structures are defined in the standard header file stdio h and control the mode information of each stream flag indicating whether input or output stream and status informatio
32. preprocess command Specify characters as a comment string after the preprocess command 84 escape sequence out of An escape sequence in a character constant or range for character character string constant exceeded 255 charac ters Reduce the escape sequence to within 255 char acters 85 redefined A previously defined macro was redefined with different contents Check the contents against those in the previous definition 87 within comment A comment includes Do not nest comments 90 Macro name in if is not de An undefined macro name in is used fined so it s tereated as 0 2 Check the macro definition Appendix F 8 Appendix F Error Messages F 5 ccom930 Error Messages Tables F 8 to F 20 list the ccom30 compiler error messages and their countermeasures Table F 8 ccom30 Error Messages 1 14 Error message Description and countermeasure pragma PRAGMA name function name redefined The same function is defined twice in pragma name Make sure that pragma name is declared only once pragma PRAGMA name function argument is long long or double The arguments used for the function specified with the pragma program name function name are the long long type or the double type The long long type and double type cannot be used in the functions specified with the pragma program name function name Use other typ
33. 6 A union is defined twice Make sure that a union is defined only once reinitialized of variable name 6 n initialize expression is specified twice for the same variable Specify the initializer only once restrict is duplicate A restrict is defined twice Make sure that a restrict is defined only once size of incomplete array type An attempt is made to find sizeof of an array of unknown size This is an invalid size Specify the size of the array size of incomplete type An undefined structure or union is used in the operand of the sizeof operator Define the structure or union first The number of elements of an array defined as an operand of the sizeof operator is unknown gt Define the structure or union first size of void An attempt is made to find the size of void This is an invalid size gt The size of void cannot be found Appendix F 19 Appendix F Error Messages Table F 19 ccom30 Error Messages 12 14 Error message Description and countermeasure Sorry stack frame memory ex haust max 128 bytes but now nnn bytes NC30 NC308 only maximum of 128 bytes of parameters can be secured on the stack frame Currently nnn bytes have been used Reduce the size or number of parameters Sorry stack frame memory ex haust max 64 or 255 bytes but now nnn bytes 6 The stack frame maximum is follows 64 bytes NC7
34. Argument const char far s Pointer to a multibyte character string size tn Number of searched byte ReturnValue Returns the number of bytes in the character string if s configures a correct multibyte character string Returns 1 if s does not configure a correct multibyte character string Returns 0 if s indicates a NULL character Appendix E 47 Appendix E Standard Library mbstowcs Multi byte Character Multi byte Character String Manipulate Functions Function Format Method Argument ReturnValue Converts a multibyte character string into a wide character string include lt stdlib h gt size_t mbstowcs wcs s n function wchar_t_far wcs Pointer to an area for storing conversion wide character string const char far s Pointer to a multibyte character string size tn Number of wide characters stored Returns the number of characters in the converted multibyte character string Returns 1 if s does not configure a correct multibyte character string mbtowc Multi byte Character Multi byte Character String Manipulate Functions Function Format Method Argument ReturnValue Converts a multibyte character into a wide character include lt stdlib h gt int mbtowc wcs s n function wchar_t_far wcs Pointer to an area for storing conversion wide character string const char far s Pointer to a multibyte character string size
35. Figure D 12 Compile Result of Sample Program sample c 2 3 Appendix D 9 Appendix D C Language Specification Rules In the compile result 2 of the sample program sample c listed in Figure D 10 all arguments are passed via a stack since function func no proto is written in K amp R format Furthermore since the arguments of the function are not passed via register the symbol name of the function s start address is derived from func no proto described in the C language source file by prefixing it with _ underbar hence func no proto SD d FUNCTI ON main DG34 d FRAME AUTO sum size 2 offset 2 DES ARG Size 0 Auto Size 2 Context Size 5 line DE C SRC glb mai n enter line S434 C SRC 11 q 0002H R2 0001H R1 func_proto 02H SP 0 2 FB HE C_SRC 12 T push w 0003 push w 0002H push w 0001H jsr func no proto add b 06H SP NL UA C_SRC exitd END Figure D 13 Compile Result of Sample Program sample c 3 3 In Figure D 13 part 11 calls func proto and part 12 calls func no proto Appendix D 10 Appendix D C Language Specification Rules D 3 4 Interface between Functions Figures D 16 to D 18 show the stack frame structuring and release processing for the program shown in Figure D 14 Figure D 15 shows the assembly language program that is produced when the program shown in Figure D 14 is compiled int f unc void main void int i Ar
36. Following are detailed descriptions of the standard header files supplied with NC30 The header files are presented in alphabetical order The NC30 standard functions declared in the header files and the macros defining the limits of numerical expression of data types are described with the respective header files Appendix E 1 Appendix E Standard Library assert h a ae aa Function Defines assert function ctype h eee Function Defines declares string handling function The following lists string handling functions Function Contents isalnum Checks whether the character is an alphabet or numeral isalpha Checks whether the character is an alphabet iscntrl Checks whether the character is a control character isdigit Checks whether the character is a numeral isgraph Checks whether the character is printable except a blank islower Checks whether the character is a lower case letter isprint Checks whether the character is printable including a blank ispunct Checks whether the character is a punctuation character isspace Checks whether the character is a blank tab or new line isupper Checks whether the character is an upper case letter isxdigit Checks whether the character is a hexadecimal character tolower Converts the character from an upper case to a lower case toupper Converts the character from a lower case to an upper case errno h DL s R58 Fun
37. Use a constant to describe the number of ele ments asm s string must have more than 3 or or is described more than thrice in asm statement Make sure that is described only twice auto variable s size is zero An array with 0 elements or no elements was declared in the auto area Correct the coding bitfield width exceeded The bit field width exceeds the bit width of the data type Make sure that the data type bit width declared in the bit field is not exceeded bitfield width is not constant integer The bit width of the bit field is not a constant Use a constant to write the bit width can t get bitfield address by amp operator 9 The bit field type is written with the amp operator Do not use the amp operator to write the bit field type can t get inline function s address by amp operator The amp operator is written in an inline function gt Do not use the amp operator in an inline function can t get void value An attempt is made to get void type data as in cases where the right side of an assignment ex pression is the void type Check the data type can t output to file name 6 The file cannot be wrote Check the rest of disk capacity or permission of the file can t open file name 9 The file cannot be opened Check the permission of the file Appendix F 10 Appendix F Err
38. asm func i j Calling the assembler function M Figure B 76 Example of pragma PARAMETER Declaration Appendix B 51 Appendix B Extended Functions Reference pragma SPECIAL Function Declares a special page subroutine call JSRS instruction function Syntax pragma SPECIALAnumberAfunction name pragma SPECIALAfunction name A number Description 1 Functions declared using pragma SPECIAL are mapped to addresses created by adding OFOOOOH to the address set in the special page vector tables and are there fore subject to special page subroutine calls 2 A call number can be specified when declaring Specify a call number and the compile option fmake special table fMST before compiling the source files The compiler will automatically generate a special page vector table Rules 1 Functions declared using pragma SPECIAL are mapped to the program S section Be sure to map the program S section between OF0000H and OFFFFFH Calls are numbered between 18 and 255 in decimal only As a label SPECIAL calling number is output to the starting address of functions declared using pragma SPECIAL Set this label in the special page subroutine table in the startup file Note that when the option fmake special table fMST is specified the above set Co m ting is unnecessary 4 If different call numbers are written in the function the call number declared later is effective Example p
39. b __msize heap_top amp OFFFFH __mbase heap_top amp OFFFFH __mnext HEAPSIZE amp OFFFFH __msize es HE if STANDARD 1 glb init call init G jsr a init Call main function 23 dc 0h fb for debuger exit End program dummy interrupt function 25 end C COMPILER for R8C Tiny M16C 60 30 20 10 COPYRI GHT C XXXX XXXX RENESAS TECHNOLOGY CORPORATI ON AND RENESAS SOLUTIONS CORPORATION ALL RIGHTS RESERVED 21 For R8C Tiny Initializes the heap area Comment out this line if no memory man agement function is used 22 Calls the init function which initializes standard Comment out this line if no I O function is used 23 Calls the main function 2 24 exit function 25 Dummy interrupt processing function Figure 2 11 Startup Program List 6 ncrt0 a30 6 6 NC30 MANUAL 27 Chapter 2 Basic Method for Using the Compiler C Compiler for R8C Tiny M16C 60 30 20 1
40. c2 2 c3 that thechar type overflows in the middle of operation and that the result takes on an unexpected value An example is shown below main char c1 char c2 200 char c3 2 char c2 2 c3 In this case thechar type overflows when calculating c2 2 so that the cor rect result may not be obtained Specification of this option helps to obtain the correct result The reason why extension into the int type is disabled by default is because it is conducive to increasing the ROM efficiency any further fchar_enumerator fCE Function Processes enumerator types not as int types but as unsigned char types Notes The type debug information does not include information on type sizes There fore if this option is specified the enum type may not be referenced correctly in some debugger Appendix A 30 Appendix A Command Option Reference even fNE Function When outputting data does not separate odd and even data That is all data is mapped to the odd sections data_NO data_FO data_INO data_IFO bss_NO bss_FO rom_NO rom_FO Supplement By default the odd size and the even size data are output to separate sections Take a look at the example below char int i In this case variable c and variable i are output to separate sections This is because the even size variable i is located at an even address This allows for fast access when accessing in 16 bit bus width Use
41. func in int func out FILE oni bed typede fpos t typedef unsigned int size t extern FILE iob 1 Figure 1 7 Example Preprocessed C Source File 1 smp i NC30 MANUAL 8 Chapter 1 Introduction to NC30 nt getc FILE st 1 nt getchar voi d nt putc int c FILE st nt putchar int c nt feof FILE st int ferror FILE st n h n n i fgetc FILE s ar fgets char s int n FILE st fputc int c FILE st fputs const char s FILE st size t fread void ptr size t size size t nelem FILE stJ omitted int ungetc int c FILE st int printf const char format int fprintf FILE st const char format int sprintf char s const char format omitted extern int init dev FILE int extern int Speed int int int int extern int init prn void extern int _sget void extern int _sput int extern int _pput int extern char petente void main 2 int flag flag 0 31 printf flag d n flag 4 Figure 1 8 Example Preprocessed C Source File 2 smp i Let s look at the contents of the preprocessed C source file Items 1 to 4 correspond to 1 to 4 in Figures 1 7 and 1 8 1 Shows the expansion of header file stdio h specified in include 2 Shows the C source program resulting from expanding the macro 3 Shows
42. include lt stdlib h gt double atof s Methog function Variable const char far s Pointer to the converted character string ReturnValue Returns the value derived by converting a character string into a double precision floating point number atol Character String Convert Functions Function Converts a character string into an int type integer Format include lt stdlib h gt int atoi s Method function Variable const char far s Pointer to the converted character string ReturnValue Returns the value derived by converting a character string into an int type integer Appendix E 20 Appendix E Standard Library atol Character String Convert Functions Function Converts a character string into a long type integer Format include lt stdlib h gt long atol s Method function Variable const char far s Pointer to the converted character string ReturnValue Returns the value derived by converting a character string into an long type integer bcopy a Memory Handling Functions Function Copies characters from a memory area to another Format include lt string h gt void bcopy src dtop size Method function Variable char far src Start address of the memory area to be copied from char far Start address of the memory area to be copied to unsigned long size Number of bytes to be copied No value is returne
43. 65535 can take on as value USHRT MAX Maximum value that an unsigned short int type 65535 variable can take on as value ULONG MAX Maximum value that an unsigned long int type 4294967295 variable can take on as value ULLONG MAX Maximum value that an unsigned long long int 18446744073709551615 type variable can take on as value Appendix E 4 Appendix E Standard Library locale h Le a ee ee eee i Function Defines declares macros and functions that manipulate program localization The follow ing lists locale functions Function Contents localeconv Initializes struct Iconv setlocale Sets and searches the locale information of a program math h E ee ee ee ee Function Declares prototype of mathematical function The following lists mathematical functions Function Contents acos Calculates arc cosine asin Calculates arc sine atan Calculates arc tangent atan2 Calculates arc tangent ceil Calculates an integer carry value cos Calculates cosine cosh Calculates hyperbolic cosine exp Calculates exponential function fabs Calculates the absolute value of a double precision floating point number floor Calculates an integer borrow value fmod Calculates the remainder frexp Divides floating point number into mantissa and exponent parts labs Calculates the absolute value of a long type integer Idexp Calculates t
44. Calculates the absolute value of a double precision floating point number Format include lt math h gt double fabs x Method function Argument double X arbitrary real number ReturnValue e Returns the absolute value of a double precision floating point number Appendix E 26 Appendix E Standard Library feof Input Output Functions Function Checks EOF End of File Format include lt stdio h gt int feof stream Method macro Argument FILE far stream Pointer of stream ReturnValue Returns true other than 0 if the stream is EOF 9 Otherwise returns NULL 0 Description Determines if the stream has been read to the EOF Interprets code Ox1A as the end code and ignores any subsequent data ferror Input Output Functions Function Checks input output errors Format include lt stdio h gt int ferror stream Method macro Argument FILE far stream Pointer of stream ReturnValue Returns true other than 0 if the stream is in error Otherwise returns NULL 0 Description Determines errors in the stream Interprets code 0x1A as the end code and ignores any subsequent data Appendix E 27 Appendix E Standard Library fflush Function Flushes the stream of an output buffer Format include lt stdio h gt int fflush stream Method function Argument FILE far stream Pointer of stream ReturnValue Alwa
45. SPECIAL 220 SPECIAL 219 SPECIAL 218 SPECIAL 217 SPECIAL 216 SPECIAL 215 i SPECIAL 214 SPECIAL 213 SPECIAL 212 SPECIAL 211 j SPECIAL 210 SPECIAL 209 SPECIAL 208 i SPECIAL 207 SPECIAL 206 SPECIAL 205 SPECIAL 204 SPECIAL 203 SPECIAL 202 SPECIAL 201 SPECIAL 200 s SPECIAL 199 SPECIAL 198 SPECIAL 197 SPECIAL 196 SPECIAL 195 SPECIAL 194 SPECIAL 193 SPECIAL 192 i SPECIAL 191 SPECIAL 190 SPECIAL 189 SPECIAL 188 SPECIAL 187 SPECIAL 186 SPECIAL 185 SPECIAL 184 s SPECIAL 183 SPECIAL 182 SPECIAL 181 SPECIAL 180 SPECIAL 179 j SPECIAL 178 SPECIAL 177 SPECIAL 176 i SPECIAL 175 SPECIAL 174 SPECIAL 173 SPECIAL 172 SPECIAL 171 i SPECIAL 170 SPECIAL 169 SPECIAL 168 SPECIAL 167 SPECIAL 166 SPECIAL 165 A SPECIAL 164 SPECIAL 163 i SPECIAL 162 SPECIAL 161 SPECIAL 160 SPECIAL 159 SPECIAL 158 Figure 2 16 Startup Program List 11 sect30 inc 5 11 NC30 MANUAL 32 Chapter 2 Basic Method for Using the Compiler L 84 L 83 L 82 SPECIAL 157 SPECIAL 156 SPECIAL 155 SPECIAL 154 SPECIAL 153 SPECIAL 152 SPECIAL 151 SPECIAL 150 SPECIAL 149 SPECIAL 148 SPECIAL 147 SPECIAL 146 SPECIAL 145 SPECIAL 144 i SPECIAL 143 SPECIAL 142 SPECIAL 141 SPECIAL 140 SPECIAL 139 s SPECIAL 138 SPECIAL 137 SPECIAL 136 SPECIAL 135 SPECIAL 134 SPECIAL 133 SPECIAL 13
46. The return value from the alarm handler must be type void in the declaration Only the function definition put after p gt ragma ALMHANDLER are valid No processing occurs if you specify other than a function name No error occurs if you duplicate pragma ALMHANDLER declarations A compile warning occurs if you use any function specified in one of the following declarations in pragma ALMHANDLER e pragma INTERRUPT e pragma INTHANDLER 6 pragma HANDLER e pragma CYCHANDLER pragma TASK oar WN Example include lt mr30 h gt include id h pragma ALMHANDLER alm void alm void Be sure to declare as type void omitted Figure B 78 Example of pragma ALMHANDLER Declaration Appendix B 53 Appendix B Extended Functions Reference pragma CYCHANDLER Function Declares an MR30 cyclic handler Syntax pragma CYCHANDLERAcyclic handler name Description By using the above format to declare a cyclic handler a function written in C NC30 generates the code for the cyclic handler to be used at the entry and exit points of the function The cyclic handler is called from the system clock interrupt by the JSR instruction and returns by the RTS or EXITD instruction Rules 1 You canNOT write cyclic handlers that take parameters 2 The return value from the cyclic handler must be type void in the declaration 3 Only the function definition put after pragma CYCHANDLER are valid 4 N
47. To use utl30 specify the compile driver startup option finfo when compiling so that the absolute module file x30 will be generated MapViewer MapViewer is the execution file for the map viewer By processing the absolute module file x30 MapViewer graphically shows a post link memory mapping To use MapViewer specify the compile driver startup option finfo when compiling so that the absolute module file x30 will be generated Note that MapViewer is included for only the PC version To verify the map information while using the UNIX version generate a map file with the linker and check that file for map information In the entry version this option cannot be specified 1 The inspector information refers to one that is generated by NC30 when the compile option finfo is specified NC30 MANUAL 2 1 3 1 3 1 1 3 2 Chapter 1 Introduction to NC30 Notes Renesas Technology Corp are not designed or manufactured for use in a device or system that is used under circumstances in which human life is potentially at stake Please contact Renesas Technology Corp Renesas Solutions Corp or an authorized Renesas Semicon ductor product distributor when considering the use of a product contained herein for any specific purposes such as apparatus orsystems for transportation vehicular medical aerospace nuclear or undersea repeater use Notes about Version up of compiler The machine language instructions assembly
48. ample of these settings section program ORG OFFEO000H Specifies the starting address of the program section Figure 2 31 Example Setting of Section Starting Address sect30 inc If no starting address is specified for a section that section is mapped immediately after the previously defined section 1 Rules for Mapping Sections to Memory Because of the effect on the memory attributes RAM and ROM of Micro Processor memory some sections can only be mapped to specific areas Apply the following rules when mapping sections to memory a Sections mapped to RAM e data SE section Gbss SE section e data SO section Gbss SO section edata NE section bss NE section e data NO section Gbss NO section edata FE section bss FE section e data FO section Gbss FO section G stack section heap section b Sections mapped to ROM rom_NE section data_SEl section rom_NO section data_SOl section rom_FE section data_NEI section rom_FO section data_NOI section data_FEI section G program section e data FOI section G interrupt section OG switch table section OG vector section NC30 MANUAL 48 Chapter 2 Basic Method for Using the Compiler Note also that some sections can only be mapped to specific memory areas in the Micro Processor memory space a Sections mapped only to OH OFFFFH near area data_SE section Gbss SE section e data NE section QGbss NE section Grom NE section G stack sect
49. b Returning Return Values from Assembler Functions ccccsccceeseeeeeeeeeeeseeeeeseees 69 NC30 MANUAL V 3 4 3 5 Cs TRETEREMCIMONG ValiableS 69 d Notes on Coding Interrupt Handling in Assembler Function eessseuese 70 e Notes on Calling C Functions from Assembler Functions ccccccceeesceeeeeteeeeseees 3 3 3 Notes on Coding Assembler Functions 72 a Nolesvon Handing B and U NAGS osisssa iaeoa 72 5 Noteson Handing FB REISTE scansano 72 c Notes on Handling General purpose and Address 72 d Passing Parameters to an Assembler Function eese 72 When Using the R8G Tiny Selles i 2 atte o Eit a Sentido don aadi 73 3 41 REC OPON M E LLL ULL a 73 34 2 About MEMORY Spa66 iet utes A aE exp cie 73 9 4 9 About the Default Attributes of ROM and 73 9 4 4 About the Extended Functions of ztpragma siseseid 73 3 4 5 About the Stanup Progra assis tegis os tutes xp 74 3 4 6 About the Standard Function EIDEGE Siscectecdsscessazsctsccaacenies bainees cata t ta inc tpa trip ep aterert 74 OOT ENT 75 3 5 1 Precaution
50. character type integral type e structure 6 union enumerator type void e floating type b Qualified Type NC30 interprets the following as qualified type 9 const 9 volatile 6 ewstrict 6 near e far c Data Type and Size Table C 10 shows the size corresponding to data type Table C 10 Data Type and Bit Size Type Existence of sign Bitsize Range of values _ Bool No 8 0 1 char No 8 0 lt 255 unsigned char signed char Yes 8 1280127 int Yes 16 32768482767 short signed int signed short unsigned int No 16 0465535 unsigned short long Yes 32 2147483648421 47483647 signed long unsigned long No 32 044294967295 long long Yes 64 92233720368547 758084 signed long long 9223372036854775807 unsigned long long No 64 18446744073709551615 float Yes 32 1 17549435e 38F 8 40282347e438F double Yes 64 2 225073858507201 4e 308 lt long double 1 7976931348623157e 308 near pointer No 16 O lt OxFFFF far pointer No 32 0c 90xFFFFFFFF Appendix C 8 Appendix C Overview of C Language Specifications e The Bool type can not specify to sign ef a char type is specified with no sign it is processed as an unsigned char type if an int or short type is specified with no sign it is processed as a signed int or signed short type ef a long type is specifi ed with no sign it is processed as a sign long type ef a long long type is spec
51. dards In the entry version this option is always enabled i e assumed to be specified Therefore it cannot be enabled or disabled by specification fchar_enumerator CE Handles the enumerator type as an unsigned char type not as an int type fno_even fNE Allocate all data to the odd section with no separat ing odd data from even data when outputting ffar_RAM fFFRAM Changes the default attribute of RAM data to far fnear ROM fNROM Changes the default attribute of ROM data to near In the entry version this option cannot be specified fconst not ROM fCNR Does not handle the types specified by const as ROM data fnot address volatile fNAV Does not regard the variables specified by pragma ADDRESS pragma EQU as those specified by volatile 1 char type data or signed char type data evaluated under ANSI rules is always extended to int type data This is because operations on char types c1 c2 2 c3 for example would otherwise result in an overflow and failure to obtain the intended result Appendix A 26 Appendix A Table A 6 2 2 Option Command Option Reference Short form Generated Code Modification Options Description fsmall_array fSA When referencing a far type array whose total size is unknown when compiling this option calculates subscripts in 16 bits assuming that the array s total size is within 64 Kbytes In the entry version this option can
52. function Argument const char far st Pointer to the character string to be searched in const char far s2 Pointer to the character string of the character to be searched for ReturnValue 6 Returns the position pointer where the specified character is found Returns NULL when the specified character cannot be found Description Returns the location pointer of the first character string s2 from the beginning of area s1 When you specify options O OR or OS the system may selects another functions with good code efficiency by optimization strtod Character String Value Convert Functions Function Converts a character string into a double type integer Format include lt string h gt double strtod s endptr Method function Argument const char far s Pointer to the converted character string char far endptr Pointer to the remaining character strings that have not been converted ReturnValue Return Value OL Does not constitute a number 9 ReturnValue OL Returns the configured number in double type Description When you specify options OR or OS the system may selects another functions with good code efficiency by optimization Appendix E 75 Appendix E Standard Library strtok Function Divides some character string from a character string into tokens Format include lt string h gt char far strtok s1 52 Method function Argument char fa
53. gt 16 pusha TO amp Offffh pusha FROM 2216 pusha FROM amp Offffh Stk 12 glb bcopy call _bcopy G jsr a bcopy endm df R8C 1 51 for M16C 60 30 20 10 series glb X BankSelect BankSelect equ 08 macro define for special page Format SPECIAL number SPECIAL macro NUM org OFFFFEH NUM 2 glb __ SPECIAL QNUM word SPECIAL QNUM amp OFFFFH Interrupt section start insf start 5 0 glb start section interrupt reset this program will start istack_top i set istack pointer b 02h Oah b 00h 04h Set processer mode 7 b 00h Oah 0080h flg 8 stack_top sp set stack pointer data_SE_top sb set sb register di ntb VECTOR_ADR NEAR area initialize bss zero clear N BZERO bss SE top bss SE N BZERO bss SO top bss SO N BZERO bss NE top bss NE N BZERO bss NO top bss NO 6 After a reset execution starts from this label start 7 Sets processor operating mode 8 Sets IPL and each flags 9 Clears the near and SBDATA bss section to zeros Figure 2 8 Startup Program List 3 ncrt0 a30 3 6 NC30 MANUAL 24 Chapter 2 Basic Method for Using the Compiler N BCOPY data SEI top data SE top data SE N BCOPY data SOI top data SO top data 50 N BCOPY data NEI top data NE top data NE N BCOPY data NOI top data NO top data NO FAR area initialize 11 BZERO bss FE top bss FE BZERO bss FO top bss FO Copy edata E 0 section from edata EI 0I section 12 B
54. or an authorized Renesas Semicon ductor product distributor when considering the use of a product contained herein for any specific purposes such as apparatus orsystems for transportation vehicular medical aerospace nuclear or undersea repeater use Notes about Version up of compiler The machine language instructions assembly language generated by NC30 vary in contents depending on the startup options specified when compiling contents of version up etc Therefore when you have changed the startup options or upgraded the compiler version be sure to reevaluate the operation of your application program Furthermore when the same RAM data is referenced and its contents changed between interrupt handling and non interrupt handling routines or between tasks under realtime OS always be sure to use exclusive control such as volatile specification Also use exclusive control for bit field struc tures which have different member names but are mapped into the same RAM NC30 MANUAL 57 Chapter 3 Programming Technique 3 1 2 Notes about the M16C s Type Dependent Part When writing to or reading a register in the SFR area it may sometimes be necessary to use a specific instruction Because this specific instruction var ies with each type of MCU consult the user s manual of your MCU for de tails In this case write the instruction directly in the program using the ASM function In this compiler the instructions which cannot be us
55. sect30 inc 9 11 Chapter 2 Basic Method for Using the Compiler word dummy in vector 23 word dummy in vector 24 word dummy in vector 25 word dummy in vector 26 word dummy in vector 27 word dummy in vector 28 word dummy in vector 29 word dummy in vector 30 word dummy in vector 31 word dummy in vector 32 word dummy in vector 33 word dummy in vector 34 word dummy in vector 35 word dummy in vector 36 word dummy in vector 37 word dummy in vector 38 word dummy in vector 39 word dummy in vector 40 word dummy in vector 41 word dummy in vector 42 word dummy in vector 43 word dummy int vector 44 word dummy in vector 45 word dummy in vector 46 word dummy in vector 47 word dummy in vector 48 word dummy in vector 49 word dummy in vector 50 word dummy in vector 51 word dummy in vector 52 word dummy in vector 53 word dummy in vector 54 word dummy in vector 55 word dummy in vector 56 word dummy in vector 57 word dummy in vector 58 word dummy in vector 59 word dummy in vector 60 word dummy in vector 61 word dummy in vector 62 word dummy in vector 63 else MVT__ section NC rvector ROMDATA 0rg VECTOR ADR endi f fixed vector section section fvector ROMDATA fixed vector table org OffdcH UDI word dummy in OVER FLOW word dummy in BRKI word dummy in ADDR
56. 1 Conversion specification symbol d Converts a signed decimal The target parameter must be a pointer to an integer Converts signed decimal octal and hexadecimal input Octals start with 0 Hexadecimals start with Ox or OX The target parameter must be a pointer to an integer u Converts an unsigned decimal The target parameter must be a pointer to an un signed integer eo Converts a signed octal The target parameter must be a pointer to an integer ex X Converts a signed hexadecimal Uppercase or lowercase can be used for OAH to OFH The leading Ox is not included The target parameter must be a pointer to an integer s Stores character strings ending with the null character The target parameter must be a pointer to a character array of sufficient size to store the character string including the null character O If input stops when the maximum field width is reached the character string stored consists of the characters to that point plus the ending null character ec Stores a character Space characters are not skipped If you specify 2 or more for the maximum field width multiple characters are stored However the null character is not included The target parameter must be a pointer to a character array of sufficient Size to store the character string ep Converts input in the format data bank register plus offset Example 00 1205 The target parameter is a pointer to all types Stores
57. 1 9 Example Assembly Language Source File smp a30 1 2 NC30 MANUAL 10 Chapter 1 Introduction to NC30 mov w 0000H 2 FB flag line 11 DE C SRC printf flag d n flag 2 push w 2 FB flag push w ___T0 gt gt 16 push w s TO amp OFFFFH jsr pri ntf add b 06H SP line 13 1 C SRC exitd omitted glb _sscanf glb _scanf glb _fscanf glb _sprintf glb fprintf glb pri ntf omitted SECTI ON rom FO ROMDATA byte 66H im UND byte 6cH Pe pt byte 61H Soar byte 61H byte 20H pond byte 3dH poa byte 20H oet byte 25H ES omitted END 34 Compile End Ti me Thu May 5 18 40 11 2000 Figure 1 10 Example Assembly Language Source File smp a30 2 2 Let s look at the contents of the assembly language source files Items 1 to 2 corre spond to 1 to 2 in Figure 1 9 and Figure 1 10 1 Shows status of optimization option and information on the initial settings of the near and far attribute for ROM and RAM 2 When the nc30 command line option dsource dS is specified shows the contents of the C source file s as comments NC30 MANUAL 11 2 1 2 Basic Method for Using the Compiler Chapter 2 Basic Method for Using the Compiler Chapter 2 This chapter describes how to start the compile driver nc30 and the command line op tions Starting Up the Compiler nc30 Command Format The nc30 com
58. 1 Specify section names using the assembler pseudo command SECTION 2 Global specify function name labels using the assembler pseudo command GLB 3 Add the underscore to the function name to write it as label 4 When modifying the B and U flags within the function save the flag register to the stack beforehand The following shows a procedure for writing the exit processing of assembler functions 5 lf you modified the B and U flags within the function restore the flag register from the stack 6 Write the RTS instruction Do not change the contents of the SB and FB registers in the assembler function If the contents of the SB and FB registers are changed save them to the stack at the entry to the function then restore their values from the stack at the exit of the function Figure 3 15 is an example of how to code an assembler function In this example the section name is program which is the same as the section name output by NC30 SECTI ON program 1 GLB asmfunc 2 asm func 31 PUSHC FLG 4 PUSHM R3 R1 5 MOV w SYM1 R3 MOV w SYM1 2 Rl omitted POPM R3 RI 6 POPC FLG 7 RTS 8 END 1 to 8 correspond to the steps described above Figure 3 15 Example Coding of Assembler Function 1 Do not change the contents of B and U flags in the assembler function NC30 MANUAL 68 Chapter 3 Programming Technique b Returning Return Values from Assembler Functio
59. 2 Figures D 16 to D 18 below show stack and register transitions in each processing in Figure D 15 Processing in 1 2 entry processing of function main is shown in Figure D 16 Processing 3 gt 4 5 gt 6 7 processing to call function func and construct stack frames used in function func is shown in Figure D 17 Processing 8 9 gt 10 11 processing to return from function func to function main is shown in Figure D 18 Variable j Variable k OLD FB lt SP Stack usage state for Stack usage state of 2 start of 1 main Figure D 17 Entry processing of function main Appendix D 12 Appendix D C Language Specification Rules Argument x i Argument z k Argument y j Return address Argument z k e lt 7 Lm Variable sum Stack useage state of 3 Stack useage state of 4 5 Stack useage state of 6 Stack useage state of 6 When PUSH instruction When JSR instruction When ENTER instruction completed completed Figure D 18 Calling Function func and Entry Processing Return value of Argument x i Argument y j B of Function main Argument z k Variable Stack useage state of 8 Stack useage state of 9 When EXITD instruction completed Figure D 19 Exit Processing of Function func Appendix D 13 completed Stack useage state of 10 11 D 4 Appendix D C Language Specification Rules Securing auto Variable Area Variables of storage clas
60. 2 Basic Method for Using the Compiler STACK SIZE definition 2 if USTACKSIZE 0 STACKSIZE equ 300h else STACKSIZE equ __USTACKSIZE__ endif INTERRUPT STACK SIZE definition 3 if __ISTACKSIZE__ 0 STACKSI equ 300h else I STACKSIZE equ __1STACKSIZE__ endif INTERRUPT VECTOR ADDRESS definition 4 fed VECTOR_ADR equ Off d00h SVECTOR_ADR equ Offe00h else VECTOR ADR equ Ofedch endif Section allocation 5 list OFF include sect30 inc list ON Glib SB __SB equ data SE top Initialize Macro declaration N BZERO macro TOP SECT mov b 00H ROL mov w TOP_ amp OFFFFH Al mov w sizeof SECT_ R3 sstr b endm N BCOPY macro FROM TO SECT_ FROM amp OFFFFH A0 mov b FROM 16 RIH mov w TO_ Al mov w sizeof SECT_ R3 smovf b endm BZERO macro TOP SECT push w sizeof SECT_ gt gt 16 push w sizeof SECT amp Offffh pusha TOP_ gt gt 16 pusha TOP amp Offffh stk 8 glb bzero call bzero 6 jsr a bzero endm 2 defines the user stack size 3 defines the interrupt stack size 4 defines the start address of interrupt vector table b Includes sect30 inc Figure 2 7 Startup Program List 2 ncrt0 a30 2 6 NC30 MANUAL 23 Chapter 2 Basic Method for Using the Compiler BCOPY macro FROM TO_ SECT_ push w sizeof SECT gt gt 16 push w sizeof SECT amp Offffh pusha gt
61. Because improper use of this facility produces negative effects always be sure to examine generated codes before deciding to use it b About register qualification and optimization options When optimization options are specified variables are assigned to registers as one opti mization feature This assignment feature is not affected by whether the variables are reg ister qualified About Startup Handling Startup may need to be modified depending on the type of microcomputer you are using or depending on your application system For modifications pertinent to the type of microcomputer consult the data book etc for your microcomputer and correct the startup file included with the compiler package before use NC30 MANUAL 61 3 2 3 2 1 Chapter 3 Programming Technique For Greater Code Efficiency Programming Techniques for Greater Code Efficiency a Regarding Integers and Variables 1 Unless required use unsigned integers If there is no sign specifier for int short or long types they are processed as signed integers Unless required add the un signed sign specifier for operations on integers with these data types 21 possible do not use gt or for comparing signed variables Use and for conditional judgements b fartype array The far type array is referenced differently at machine language level depending on its size 1 When the array size is within 64 Kbytes Subscripts are calculated in 16
62. CORPORATION ALL RIGHTS RESERVED 512 Aug 17 16 13 3584 Aug 17 16 14 44040 Aug 17 16 14 ncrt0 a30 In this example the option is used to specify that ncrt0 a30 are output to directory test The source file information used for debugging is generated starting from the directory from which the compiler was invoked the current directory Therefore if output files were generated in different directories the debugger etc must be notified of the directory from which the compiler was invoked Appendix A 9 A 2 3 Appendix A Command Option Reference Version Information Display Option Table 2 3 shows the command line options that display the cross tool version data Table 2 3 Options for Displaying Version Data Option Function V Displays the name of the command program and the command line during execution V Displays the startup messages of the compiler programs then fin ishes processing without compiling V Display command program name Function Compiles the files while displaying the name of the command program that is being executed Execution le nc30 c v sample c example M16C 60 NC30 COMPILER V X XX Release X COPYRIGHT C XXXX XXXX RENESAS TECHNOLOGY CORPORATION ALL RIGHTS RESERVED AND RENESAS SOLUTIONS CORPORATION ALL RIGHTS RESERVED Sample c cpp30 sample c o sample i DM16C DNC30 ccom30 sample i o sample a30 8530 N sample a30 M Notes Use lo
63. F 21 Warning message ccom30 Warning Messages 1 10 Description and countermeasure pragma pragma name HAN DLER both specified Both pragma pragma name and pragma HAN DLER are specified in one function Specify pragma pragma name and pragma HANDLER exclusive to each other pragma pragma name amp INTER RUPT both specified Both pragma pragma name and pragma IN TERRUPT are specified in one function Specify pragma pragma name and pragma IN TERRUPT exclusive to each other pragma pragma name amp TASK both specified Both pragma pragma name and pragma TASK are specified in one function gt Specify pragma pragma name and pragma TASK exclusive to each other pragma pragma name format error The pragma pragma name is erroneously writ ten Processing will be continued Write it correctly pragma pragma name format error ignored The pragma pragma name is erroneously writ ten This line will be ignored Write it correctly pragma pragma name not function ignored A name is written in the pragma pragma name that is not a function Write it with a function name pragma pragma name s function must be predeclared ignored A function specified in the pragma pragma name is not declared For functions specified in a pragma pragma name write prototype declaration in advance pragma pragma name s function must be
64. If the SB area is used as a result of the sosym declaration in an assembler routine you need to adjust the file generated by utl30 assembler routine Sbsym sym o mmi t glb sym sym blkb 2 generated file by utl30 pragma SBDATA Utility SBDATA Size 255 pragma SBDATA data3 size 4 refz 2 pragma SBDATA data2 sizez 1 refz 1 omitted pragma SBDATA datal sizez 2 ref 1 3 End of File Since 2 byte data are SB declared in an assembler routine you subtract 2 bytes of BBDATA declaration from the file generated by ut 30 Exampl e pragma SBDATA datal size 2 ref 1 Comments out Figure G 7 Example of adjust the file generated by utl30 Appendix G 12 Appendix G The SBDATA declaration amp SPECIAL Page Function declaration Utility utl30 G 5 2 Generating a SPECIAL Page Function declaration file a Generating a SPECIAL Page Function declaration file It is possible to output SPECIAL page function declaration and SPECIAL page vector definition files by having the absolute module file generated by using the option finfo when compiling processed by utl30 the SBDATA Declaration amp SPECIAL Page Function Declaration Utility Figure G 8 shows an example of input for utl30 Figure G 9 shows an example of a SPE CIAL page function declaration file Figure G 10 shows an example of a SPECIAL page vector definition file
65. If the number of columns in the result of conversion is less than the specified number the beginning is padded with zeros b If the specified number of columns exceeds the minimum field width the specified number of columns takes precedence c If the number of columns in the specified precision is less than the minimum field width the field width is processed after the minimum number of columns have been processed d The default is 1 e Nothing is output if zero with converted by zero minimum columns Appendix E 55 Appendix E Standard Library Specifying format in printf form s conversion a Represents the maximum number of characters b If the result of conversion exceeds the specified number of characters the remain der is discarded c There is no limit to the number of characters in the default d If you specify an asterisk for the precision the integer of the parameter specifies the precision e If the parameter is a negative value specification of the precision is invalid G6 E and f conversion n where n is the precision numerals are output after the decimal point 60 and G conversion Valid characters in excess of n where n is the precision are not output 5 1 Lorh 6 d i u x X and n conversion is performed on long int and unsigned long int parameters h d i 0 u x and X conversion is performed on short int and unsigned short int parameters ef or h are specified in ot
66. In80 assemble command If you specify two or more options enclose them in double quotes In the entry version this option cannot be specified Appendix A 55 Appendix A Command Option Reference as30 option Assemble link option Function Specifies as30 assemble command options If you specify two or more options enclose them in double quotes In the entry version this option cannot be specified Syntax nc30A as30A option1Aoption2 A lt C source file gt Execution n the example below the assembler list file is generated when compiling example 9 nc30 v as30 1 s sample c M16C 60 NC30 COMPILER V X XX Release X COPYRIGHT C XXXX XXXX RENESAS TECHNOLOGY CORPORATION ALL RIGHTS RESERVED AND RENESAS SOLUTIONS CORPORATION ALL RIGHTS RESERVED sample c Cpp30 sample c o sample i DM16C DNC30 ccom30 sample i o sample a30 as30 N 1 s sample a30 ls sample rw r r 1 toolusr 2850 Aug 17 14 51 sample c rw r 1 toolusr 10508 Aug 17 15 43 sample lst rw r 1 toolusr 587 Aug 17 15 43 sample r30 2 Note Do not specify the as30 options C M O P T V or X Appendix A 56 Appendix A Command Option Reference In30 option Function Specifies options for the In30 link command You can specify a maximum of four options If you specify two or more options enclose them in double quotes In the entry version this option cannot be specified S
67. Messages nc30 Error Messages Tables F 1 and F 2 list the nc30 compile driver error messages and their countermea sures Table F 1 nc30 Error Messages 1 2 Error message Description and countermeasure Arg list too long The command line for starting the respective process ing system is longer than the character string defined by the system Specify a NC30 option to ensure that the number of characters defined by the system is not exceeded Use the v option to check the command line used for each processing block Cannot analyze error This error message is not normally displayed It is an internal error OContact Renesas Solutions Corp Command file line characters exceed 2048 There are more than 2048 characters on one or more lines in the command file Reduce the number of characters per line in the com mand file to 2048 max Core dump command name The processing system indicated in parentheses caused a core dump The processing system is not running correctly Check the environment variables and the directory containing the processing system If the processing system still does not run correctly Please contact Renesas Solu tions Corp Exec format error Corrupted processing system executable file hReinstall the processing system Ignore option 6 You specified an illegal option for NC30 9Specify the correct option illegal o
68. Outputs the parameter as an ASCII character es Converts the parameter after the string far pointer char and up to a null character 0 or the precision to a character string Note that wchar t type character strings cannot be processed p Outputs the parameter pointer all types in the format 24 bits address n Stores the number of characters output in the integer pointer of the parameter The parameter is not converted ec Converts a double type parameter to the exponent format The format is d dddddde dd E Same as e except that E is used in place of e for the exponent Converts double parameters to d dddddd format 9 Converts double parameters to the format specified in e or f Normally f conversion but conversion to e type when the exponent is 4 or less or the precision is less than the value of the exponent eG Same as g except that E is used in place of e for the exponent 1 In the standard library included with your product the character string pointer is a far pointer All printf functions handle 96s with a far pointer Note that scanf functions use a near pointer by default Appendix E 54 Appendix E Standard Library Specifying format in printf form 2 Flags e Left aligns the result of conversion in the minimum field width The default is right alignment Adds or to the result of signed conversion By default only the is added to negative numbers
69. Returns NULL if a memory area of the specified size could not be secured Description amp Changes the size of an area already secured using malloc or calloc 9 Specify a previously secured pointer in parameter cp and specify the number of bytes to change in nbytes Appendix E 59 Appendix E Standard Library scanf Input Output Functions Function Reads characters with format from stdin Format include lt stdio h gt include ctype h int scanf format argument Method function Argument char far format Pointer of format specifying character string The part after the percent 96 sign in the character string given in format has the following meaning The part between and is optional Details of the format are shown below Format maximum field width modifier I L or h conversion specification character Example format 5ld ReturnValue Returns the number of data entries stored in each argument Returns EOF if EOF is input from stdin as data Description Converts the characters read from stdin as specified in format and stores them in the variables shown in the arguments Argument must be a far pointer to the respective variable The first space character is ignored except in c and conversion Interprets code 0x1A as the end code and ignores any subsequent data Appendix E 60 Appendix E Standard Library Specifying format in scanf form
70. The expression of the return statement does not match the type of the function Make sure that the return value is matched to the type of the function or that the type of the function is matched to the return value invalid storage class for function change to extern An invalid storage class is used in function decla ration It will be handled as extern when pro cessed Change the storage class to extern Kanji in pragma ADDRESS The line of pragma ADDRESS contains kanji code This line will be ignored Do not use kanji code in this declaration keyword keyword are reserved for future A reversed keyword is used Change it to a different name large type was implicitly cast to small type The upper bytes word of the value may be lost by assignment from large type to a smaller type Check the type If the description is correct ig nore this warning mismatch prototyped parameter type 6 The argument type is not the type declared in prototype declaration Check the argument type meaningless statements deleted in optimize phase 9 Meaningless statements were deleted during op timization Delete meaningless statements meaningless statement The tail of a statement is You may confuse with Check on it mismatch function pointer assign ment The address of a function having a register argu ment is substituted for a po
71. __ mbase glb __mnext glb __msize heap_top amp 0FFFFH mbase mov w heap_top gt gt 16 mbases2 mov w heap_top amp 0FFFFH __mnext mov w heap_top gt gt 16 __mnext 2 mov w HEAPSIZE amp OFFFFH __msize mov w HEAPSIZE gt gt 16 __msize 2 endi f J Figure 2 25 Initialization When Using Memory Management Functions ncrt0 a30 If you are not using the memory management functions comment out the whole initialization section This saves the ROM size by stopping unwanted library items from being linked 3 Notes on Writing Initialization Programs Note the following when writing your own initialization programs to be added to the startup program 1 If your initialization program changes the U or B flags return these flags to the origi nal state where you exit the initialization program Do not change the contents of the SB register 2 If your initialization program calls a subroutine written in C note the following two points 1 Call the C subroutine only after clearing them B and D flags 2 Call the C subroutine only after setting the U flag NC30 MANUAL 41 Chapter 2 Basic Method for Using the Compiler d Setting the Stack Section Size A stack section has the domain used for user stacks and the domain used for interrup tion stacks Since stack is surely used please surely secure a domain stack size should set up the greatest size to be used Stack size is calculated to use t
72. a30 dS 3E Normal Optimize OFF ROM size Optimize OFF 138 Speed Optimize OFF 138 Default ROM is far Default RAM is near GLB SB SB SB FB 0 HH FUNCTION func Ht FUNCTION main HH dE FRAME AUTO i size 2 offset 4 Ht FRAME AUTO S Size 2 offset 2 SHE ARG Size 0 Auto Size 4 Context Size 5 SECTION program CODE align file smp c align line 7 SHESC SRC glb main main enter 04H line 9 3H 40 SRC mov w 2 FB RO _line 2 SHESCSRC mov w RO 4 FB Sos line 3 3HER SRC return i mov w RO R1 add w 40001 0 line 9 3H 40 SRC mov w R1 2 FB line 10 SHESC SRC exitd E1 END lt Inline storage class have codes embedded directly 138 Compile End Time Wed Nov 14 12 16 23 20xx Figure B 54 Compile Result of sample program smp a30 Appendix B 29 Appendix B Extended Functions Reference B 5 3 Restrictions on inline Storage Class When specifying the inline storage class pay attention to the following 1 Regarding the parameter of inline functions The parameter of an in line function cannot be used by structure and union It becomes a compile error 2 Regarding the indirect call of inline functions The indirect call of an in line function cannot be carried out It becomes a compile error when a indirect call is described 3 Regarding the recursive call of inline functions The recursive call of an in line function cannot be carried
73. acos x Method function Variable double x arbitrary real number ReturnValue Assumes an error and returns 0 if the value of given real number x is outside the range of 1 0 to 1 0 G Otherwise returns a value in the range from 0 to p radian asin Mathematical Functions Function Calculates arc sine Format include math h double asin x Methog function Variable double x arbitrary real number ReturnValue Assumes an error and returns 0 if the value of given real number x is outside the range of 1 0 to 1 0 G Otherwise returns a value in the range from p 2 to p 2 radian Appendix E 18 Appendix E Standard Library atan Mathematical Functions Function Calculates arc tangent Format include lt math h gt double atan x Method function Variable double x arbitrary real number ReturnValue Returns a value in the range from 2 to 2 radian atan2 Mathematical Functions Function Calculates arc tangent Format include lt math h gt double atan2 x y Method function Variable double x arbitrary real number double y arbitrary real number ReturnValue amp Returns a value in the range from r to x radian Appendix E 19 Appendix E Standard Library atof Character String Value Convert Functions Function Converts a character string into a double type floating point number Format
74. and exit points of the function 6 In entry processing all registers of the Micro Procesor are saved to the stack 6 In exit processing the saved registers are restored and control is returned to the calling function by the REIT instruction 2 You may specify either B or E in this declaration B Instead of saving the registers to the stack when calling the function you can switch to the alternate registers This allows for faster interrupt processing E Multiple interrupts are enabled immediately after entering the interrupt This im proves interrupt response 3 An interrupt vector number can be specified when declaring Specify an interrupt vector number and the compile option fmake vector table fMVT before compiling the source files The compiler will automatically generate an invariable terrupt vector table Note that when the option fmake vector table fMVT is specified you do not need to specify an interrupt function name for the vector section in the startup program Rules 1 A warning is output when compiling if you declare interrupt processing functions that take parameters 2 A warning is output when compiling if you declare interrupt processing functions that return a value Be sure to declare that any return value of the function has the void type 3 Only functions for which the function is defined after a pragma INTERRUPT decla ration are valid No processing occurs if you specify other than a function na
75. and the results of compiling C source file void func void is a register variable register int i 1 Variable asm mov w A1 i Assembly language source file compile result 14 FUNCTION func 138 4 ARG Size 0 Auto Size 0 Context Size 3 section program file reg c line 3 840 SRC glb func line 4 RC SRC register int i21 mov w 0001H RO 2 line 6 3HERS C SRC asm mov w A1 i 448 ASM START mov w ROT i R0 register is transferred to register ASM END Figure B 25 An Example for Referencing a Register Variable and its Compile Result In NC30 register variables used within functions are managed dynamically At anyone position the register used for a register variable is not necessarily always the same one Therefore if a register is specified directly in an asm function it may after compiling operate differently We therefore strongly suggest using this function to check the register variables 1 If the variables need to be forcibly mapped to registers using the register qualifier specify the option fenable register fER when compiling Appendix B 14 Appendix B Extended Functions Reference B 2 4 Specifying Symbol Name of extern and static Variable extern and static storage class variables written in C are referenced as symbols You can use the format shown in Figure B 26 to use extern and static variables in asm functions asm
76. arguments are passed via stack when description of K amp R format is entered description of old format Note also that if a description format where prototype declaration is entered for the function new format and a description of the K amp R format old format coexist in given statement the system may fail to pass arguments to the function correctly for reasons of language specifications of the C language Therefore we recommends using a prototype declaring description format as the standard format to write the C language source files for NC30 Appendix D 7 Appendix D C Language Specification Rules D 3 3 Rules for Converting Functions into Assembly Language Symbols The function names in which functions are defined in a C language source file are used as the start labels of functions in an assembler source file The start label of a function in an assembler source file consists of the function name in the C language source file prefixed by _ underbar or dollar The table below lists the character strings that are added to a function name and the conditions under which they are added Table D 9 Conditions Under Which Character Strings Are Added to Function Added character string Condition dollar Functions where any one of arguments is passed via register underbar Functions that do not belong to the above Shown in Figure D 10 is a sample program where a function has register arguments and where a funct
77. bit width This ensures efficient access for arrays of 64 Kbytes or less in size 2 When the array size is greater than 64 Kbytes or unknown Subscripts are calculated in 32 bit width Therefore when it is known that the array size does not exceed 64 Kbytes explicitly state the size in extern declaration of far type array as shown in Figure 3 7 or add the fsmall array fSA 2 option before compiling This helps to increase the code efficiency of the program extern int far array Size is unknown so subscripts are calculated as 32 bit values extern int far array 10 lt Sizeis within 64KB so access is more efficient Figure 3 7 Example extern Declaration of far Array 1 If there is no sign specifier for char type or bitfield structure members they are processed as unsigned 2 When the fsmall_array fSA option is specified the compiler assumes an array of an un known size to be within 64 Kbytes as it generates code In the entry version this option cannot be specified NC30 MANUAL 62 Chapter 3 Programming Technique c Array Subscripts Array subscripts are type extended during operations according to the size of each ele ment in the array 1 2 bytes or more other than char or signed char types Subscripts are always extended to int types for operations 2 far arrays of 64KB or more Subscripts are always extended to long types for operations Therefore if you declare variables that will b
78. bits unsigned int dadd_w unsigned int valt unsigned int val2 When calculated in 16 bits Function Syntax DSUB Returns the result of decimal addition with carry on val1 plus val2 include lt asmmacro h gt unsigned char dadc_b unsigned char val1 unsigned char val2 When calculated in 8 bits unsigned int dadc w unsigned int vali unsigned int val2 When calculated in 16bits Function Syntax Returns the result of decimal subtraction on vali minus val2 include lt asmmacro h gt unsigned char dsub_b unsigned char val1 unsigned char val2 When calculated in 8 bits unsigned int dsub w unsigned int val1 unsigned int val2 When calculated in 16 bits Appendix B 63 Appendix B Extended Functions Reference DSBB Function Returns the result of decimal subtraction with borrow on val1 minus val2 Syntax include lt asmmacro h gt unsigned char dsbb_b unsigned char val1 unsigned char val2 When calculated in 8 bits unsigned int dsbb w unsigned int val1 unsigned int val2 When calculated in 16 bits RMPA Function Initial value init Number of times count The result is returned after performing a sum of products operation assuming p1 and P2 as the start addresses where multipli ers are stored Syntax include lt asmmacro h gt signed long rmpa_b signed long init signed int count signed char p1 signed char p2 When calculated in 8 bits signed
79. but Renesas Electronics does not warrant that such information is error free Renesas Electronics assumes no liability whatsoever for any damages incurred by you resulting from errors in or omissions from the information included herein Renesas Electronics products are classified according to the following three quality grades Standard High Quality and Specific The recommended applications for each Renesas Electronics product depends on the product s quality grade as indicated below You must check the quality grade of each Renesas Electronics product before using it in a particular application You may not use any Renesas Electronics product for any application categorized as Specific without the prior written consent of Renesas Electronics Further you may not use any Renesas Electronics product for any application for which it is not intended without the prior written consent of Renesas Electronics Renesas Electronics shall not be in any way liable for any damages or losses incurred by you or third parties arising from the use of any Renesas Electronics product for an application categorized as Specific or for which the product is not intended where you have failed to obtain the prior written consent of Renesas Electronics The quality grade of each Renesas Electronics product is Standard unless otherwise expressly specified in a Renesas Electronics data sheets or data books etc Standard Computers of
80. by default This option allows it to be changed to the JSR W command Change to the JSR W command helps to compress the gen erated code size Conversely if a function is called that is located 32 Kbytes or more forward or backward from the calling position the JSR W command causes an error when linking This error can be avoided by a combined use with pragma JSRA This option is useful when the program is relatively small not exceeding 32 Kbytes in size or ROM compression is desired fbit 4B Function Generates code assuming that bitwise manipulating instructions can be ex ecuted using absolute addressing for all external variables mapped into the near area Supplement If the near external variables subject to bit manipulations are located in the M16C memory space 000016 through 1FFF16 specification of this option helps to increase the code efficiency generated by the compiler If in single chip applications the RAM is located in the above memory space specifying this option should prove effective If an attempt is made to operate on variables that are located in any other memory space an error will result when linking Appendix A 35 Appendix A Command Option Reference fno_carry fNC Function Suppresses carry flag addition when data is indirectly accessed using far type pointers supplement When accessing structures or 32 bit data indirectly using far type pointers this option generates code that does not perform
81. char far strncpy 51 52 n Method function Argument char far s1 Pointer to the character string to be copied to const char far s2 Pointer to the character string to be copied from Size tn Number of characters to be copied ReturnValue Returns a pointer to the character string at the destination of copy Description Copies n characters from character string s2 to area s1 If character string s2 contains more characters than specified in n they are not copied and is not appended Conversely if 52 contains fewer characters than specified in n O s are appended to the end of the copied character string to make up the number specified in n When you specify options O OR or OS the system may selects another functions with good code efficiency by optimization Appendix E 72 Appendix E Standard Library strnicmp Function Compares character strings n characters All alphabets are handled as upper case letters Format include lt string h gt int strnicmp 51 52 n Method function Argument char far s1 Pointer to the first character string to be compared char far s2 Pointer to the second character string to be compared Size tn Number of characters to be compared ReturnValue ReturnValue 0 The two character strings are equal 9 ReturnValue gt 0 The first character string s1 is greater than the other 9 ReturnValu
82. characters from a memory area to another memcpy Copies characters n bytes from a memory area to another memset Set a memory area by filling with characters Compare memcmp Compares memory areas n bytes memicmp Compares memory areas with alphabets handled as upper case letters Search memchr Searches a character from a memory area time h pe P qui Function Declares the functions necessary to indicate the current calendar time and defines the type Appendix E 9 E2 E 2 1 Appendix E Standard Library Standard Function Reference Overview of Standard Library NC30 has 119 Standard Library items Each function can be classified into one of the following 11 categories according to its function 1 String Handling Functions Functions to copy and compare character strings etc 2 Character Handling Functions Functions to judge letters and decimal characters etc and to covert uppercase to lowercase and vice versa 3 1 0 Functions Functions to input and output characters and character strings These include functions for formatted I O and character string manipulation 4 Memory Management Functions Functions for dynamically securing and releasing memory areas 5 Memory Manipulation Functions Functions to copy set and compare memory areas 6 Execution Control Functions Functions to execute and terminate programs and for jumping from the currently execut ing function to an
83. eBlank By default a blank is added before the value if the result of signed conversion has no sign e Adds 0 to the beginning of o conversion Adds Ox or OX to the beginning when other than 0 in x or X conversion Always adds the decimal point in e E and f conversion Always adds the decimal point in g and G conversion and also outputs any Os in the decimal place 3 Minimum field width 6 Specifies the minimum field width of positive decimal integers When the result of conversion has fewer characters than the specified field width the left of the field is padded 9 The default padding character is the blank However is the padding character if you specified the field with using an integer preceded by 0 9 If you specified the flag the result of conversion is left aligned and padding characters always blanks inserted to the right If you specified the asterisk for the minimum field width the integer in the parameter specifies the field width If the value of the parameter is negative the value after the flag is the positive field width 4 Precision Specify a positive integer after If you specify only with no value it is interpreted as zero The function and default value differs according to the conversion type Floating point type data is output with a precision of 6 by default However no decimal places are output if you specify a precision of 0 d i u x and X conversion a
84. extern and static variables in asm functions Can not operate bit fields og greater than 2 bits asm op code b bit field name Figure B 29 Format for Specifying Symbol Names You can specify one variable name using this format See Figure B 30 for an example Appendix B 16 Appendix B Extended Functions Reference struct TAG char bit0 1 char bit1 1 char bit2 1 char bit3 1 s void func void asm bset b s bit1 Figure B 30 Example of Specifying Symbol Bit Position Figure B 31 shows the results of compiling the C source file shown in Figure B 30 3HE FUNCTION func 138 ARG Size 0 Auto Size 0 Context Size 3 section program file kk c line 10 AHESC SRC glb func line 11 840 9 asm bset b s bit1 ASM START bset 1 5 1848 ASM END line 12 HER C SRC rts SECTION bss NO DATA 5 Figure B 31 Example of Referencing Bit Field of Symbol When referencing the bit fields of extern or static variables you must confirm that they are located within the range that can be referenced directly using bit operation instructions within OOOOH and 1FFFH Appendix B 17 B 2 5 Appendix B Extended Functions Reference Specification Not Dependent on Storage Class The variables written in C language can be used in the asm function without relying on the storage class of that variable auto register extern or static variable Consequently a
85. from the stream getchar Inputs one character from stdin fgets Inputs one line from the stream gets Inputs one line from stdin fread Inputs the specified items of data from the stream scanf Inputs characters with format from stdin fscanf Inputs characters with format from the stream sscanf Inputs data with format from a character string Output fputc Outputs one character to the stream putc Outputs one character to the stream putchar Outputs one character to stdout fputs Outputs one line to the stream puts Outputs one line to stdout fwrite Outputs the specified items of data to the stream perror Outputs an error message to stdout printf Outputs characters with format to stdout fflush Flushes the stream of an output buffer fprintf Outputs characters with format to the stream sprintf Writes text with format to a character string vfprintf Output to a stream with format vprintf Output to stdout with format vsprintf Output to a buffer with format Return ungetc Sends one character back to the input stream Deter ferror Checks input output errors mina tion feof Checks EOF End of File Appendix E 7 Appendix E Standard Library stdlib h Function Declares the prototypes of memory management and terminate functions Function Contents abort Terminates the execution of the program abs Calculates the absolute valu
86. h gt int vprintf format ap Method function Argument const char far format Pointer of the format specifying character string va list ap Pointer of argument list ReturnValue Returns the number of characters output Description Output to stdout with format When writing pointers in variable length variables make sure they are a far type pointer Appendix E 81 Appendix E Standard Library vsprintf Function Output to a buffer with format Format Hinclude stdarg h include lt stdio h gt int vfprintf s format ap Method function Argument char far s Pointer of the location to be store const char _ far format Pointer of the format specifying character string va list ap Pointer of argument list ReturnValue Returns the number of characters output Description amp When writing pointers in variable length variables make sure they are a far type pointer wcstombs Multi byte Character Multi byte Character String Manipulate Functions Function Converts a wide character string into a multibyte character string Format include lt stdlib h gt size_t far wcstombs s wcs n size t wcstombs s wcs n NC308 only Method function Argument char far s Pointer to an area for storing conversion multibyte char acter string const wchar t far wcs Pointer to a wide character string size tn Number of wide characters st
87. handled in 32 bit data length as is the float type fno_switch_table INST When this option is specified the code which branches since it compares is generated to a switch statement fmake_vector_table fMVT Automatically generates the variable interrupt vec tor table fmake special table fMST Automatically generates the special page vector table ffar pointer fFP Change the default attribute of pointer type variable to far R8C None Generates code suitable for the R8C Tiny series NC30 MANUAL 19 Chapter 2 Basic Method for Using the Compiler g Library Specifying Option Table 2 7 lists the startup options you can use to specify a library file Table 2 7 Library Specifying Option Option Function llibraryfilename Specifies a library file that is used by In30 when linking files h Warning Options Table 2 8 shows the command line options for outputting warning messages for contra ventions of nc30 language specifications Table 2 8 Warning Options Option Short form Function Wnon prototype WNP Outputs warning messages for functions without proto type declarations Wunknown pragma WUP Outputs warning messages for non supported pragma Wno stop WNS Prevents the compiler stopping when an error occurs Wstdout None Outputs error messages to the host machine s standard output stdout Werror file file name WEF Outputs error messages to the specified file
88. is called from the ncrt0 a30 startup program Figure E 5 shows the source program for the init function include lt stdio h gt FILE _iob 4 void init void void init void stdin cnt stdout gt _cnt stdaux gt _cnt stdprn cnt 0 stdin flag _ OREAD stdout flag lOWRT stdaux flag _ ORW stdprn flag lOWRT stdin mod TEXT stdout mod TEXT stdaux gt mod BIN stdprn mod TEXT stdin func in sget stdout func in NULL stdaux func in sget stdprn func in NULL stdin func out sput stdout func out sput stdaux func out sput stdprn func out pput ifdef UARTO speed 96 _B8 PN 52 else speed 96 _B8 PN 52 endi f init prn Figure E 5 Source file of init function init c Appendix E 92 Appendix E Standard Library In systems using the two M16C 60 series UARTs modify the init function as shown be low In the previous subsection we set the UARTO functions in the device c source file temporarily as sgetO sputO and speedo 1 Use the standard auxiliary stdaux for the UARTO stream 2 Set the flag flag and mode mod for standard auxiliary I O to match the system 3 Set the level 3 function pointer for standard auxiliary I O 4 Delete the conditional compile commands for the speed function and change to function speedO for UARTO These settings allow both UARTS to b
89. is compiled in default settings by NC30 it calls a runtime library to correct the result for this problem even in cases where the dividend is 4 byte the divisor is 2 byte and the result is 2 byte finfo Changes generated code Function Outputs the information required for the TM Inspector STK Viewer Map Viewer and utl30 In the entry version this option cannot be specified Supplement When using STK Viewer Map Viewer or utl30 the absolute module file x30 output by this option is needed Note Nocheck is made for the use of global variables in the asm function For this reason use of the asm function even in utl30 is ignored Appendix A 37 Appendix A Command Option Reference fswitch_other_section fSOS Function This option outputs a ROM table for a switch statement to some other section than a program section Supplement section name is switch table This option does not normally need to be used f change bank always ICBA Function This option allows you to write multiple variables to an extended area with pragma EXT4MPTR Supplement Specify this option when you declare multiple pointer variables to a 4M space while at the same time using the pragma EXT4MPTR feature Note This option cannot used simultaneously with the R8C option Appendix A 38 Appendix A Command Option Reference fauto over 255 fAO2 Function Changes the stack frame size per function that can be
90. is ignored as invalid 3 If the specified variable is a static variable declared in a function the pragma SBDATA declaration is ignored as invalid 4 The variable declared to be pragma SBDATA is placed in a SBDATA attribute sec tion when allocating memory for it 5 f pragma SBDATA is declared for ROM data the data is not placed in a SBDATA attribute section 6 If the option fauto over 255 is used this declaration is ignored Example pragma SBDATA sym data struct sym data char bi char bi char char char char char char sym data C C C C C c c C 5 CO c r3 r1 1x13 Soma Sao func void sym data bit1l 0 omitted V Figure B 64 Example Use of pragma SBDATA Declaration 1 Do not write a pragma SBDATA declaration for ROM data Appendix B 39 Appendix B Extended Functions Reference pragma SECTION Function Changes the names of sections generated by NC30 Syntax pragma SECTIONAsection nameAnew section name Description Specifying the program section data section and rom section in a pragma SECTION declaration changes the section names of all subsequent functions Specifying a bss section in a pragma SECTION declaration changes the names of all data sections defined in that file If you need to add or change section names after using this function to change section names change initialization etc in the startup program for the respective
91. j size 2 REGISTER R2 lt 9 ARG Size 2 Auto Size 4 Context Size 5 section program file proto c line 4 48 C SRC glb func proto func proto enter 04H mov w R1 2 FB mov w R2 4 FB line 5 1 C SRC return mov w 2 FB RO add w 4 FB RO add w 5 FB RO exitd 7 This passes the third argument k via stack 8 This passes the first argument i via register 9 This passes the second argument j via register 10 This is the start address of function func_proto Figure D 11 Compile Result of Sample Program sample c 1 3 In the compile result 1 of the sample program sample c listed in Figure D 10 the first and second arguments are passed via a register since function func_proto is prototype declared The third argument is passed via a stack since it is not subject to via register transfer Furthermore since the arguments of the function are passed via register the symbol name of the function s start address is derived from func proto described in the C language source file by prefixing it with dollar hence func proto FRAME ARG FRAME ARG FRAME ARG ARG Size 6 Auto Size 0 Context Size 5 line 11 C SRC glb func no prote 12 func no proto enter 00H line 12 S98 C SRC return mov w 5 FB RO i add w 7 FB RO add w 9 FB RO exitd 11 This passes all arguments via a stack 12 This is the start address of function func no proto
92. language generated by NC30 vary in contents depending on the startup options specified when compiling contents of version up etc Therefore when you have changed the startup options or upgraded the compiler version be sure to reevaluate the operation of your application program Furthermore when the same RAM data is referenced and its contents changed between interrupt handling and non interrupt handling routines or between tasks under realtime OS always be sure to use exclusive control such as volatile specification Also use exclusive control for bit field struc tures which have different member names but are mapped into the same RAM Notes about the M16C s Type Dependent Part When writing to or reading a register in the SFR area it may sometimes be necessary to use a specific instruction Because this specific instruction varies with each type of MCU consult the user s manual of your MCU for details In this case write the instruction directly in the program using the ASM function In this compiler the instructions which cannot be used may be generated for writing and read out to the register of SFR area When accessing registers in the SFR area in C language make sure that the same correct instructions are generated as done by using asm func tions regardless of the compiler s version and of whether optimizing op tions are used or not When you describe like the following examples as C language descrip tion to a SFR are
93. linkage editor In30 too Appendix A 41 Appendix A Command Option Reference ffar_pointer fFP Function Change the default attribute of pointer type variable to far Supplement 1 The pointer type variable in this compiler is a near attribute as a default attribut e This option is used when changing the default attribute of a pointer type variab le into a far attribute 2 The pointer variable which described the near qualifier is not influenced of this option It always becomes a near attribute Exsample char near p It processes as a near pointer R8C Function Generates code suitable for the R8C Tiny series Supplement The fnear ROM fNROM option is set by default Note This option cannot be used in combination with the following options If one of these options is specified the option is ignored ffar_RAM fFRAM fno_carry fNC fchange bank always fCBA Appendix A 42 Appendix A Command Option Reference A 2 7 Library Specifying Option Table A 7 lists the startup options you can use to specify a library file Table A 7 Library Specifying Option Option Function llibraryfilename Specifies a library file that is used by In30 when linking files Appendix A 43 Appendix A Command Option Reference Mibraryfilename Specifying a library file Function Specifies a library file that is used by In30 when linking files The file extension can be omitted Syntax nc30A l
94. long rmpa_w signed long init signed int count signed int p1 signed int p2 When calculated in 16 bits DIV Function devide val1 by val2 Syntax include lt asmmacro h gt signed char div_b signed int val1 signed char val2 calculated in 8 bits with signed signed int div w signed int val1 signed int val2 calculated in 16 bits with signed unsigned char divu b unsigned int val1 unsigned char val2 calculated in 8 bits with unsigned unsigned int divu w unsigned long val1 unsigned int val2 calculated in 16 bits with unsigned signed char divx b signed int val1 signed char val2 calculated in 8 bits with signed signed int divx w signed long val1 signed int val2 calculated in 16 bits with signed Appendix B 64 MOD Appendix B Extended Functions Reference Function Syntax devide val1 by val2 and get mod include asmmacro h signed char mod b signed int val1 signed char val2 When calculated in 8 bits signed int mod b signed long vall signed int val2 calculated in 16 bits unsigned char modu b unsigned int val1 unsigned char val2 calculated in 8 bits unsigned int modu w unsigned long val1 unsigned int val2 calculated in 16 bits SMOVB Iu T 2 Function Syntax Strings are transferred from the source address indicated by p1 to the destination address indicated by p2 as man
95. mmi t Figure G 12 Example of making settings in a SPECIAL Page Function File for sect30 inc In addition use of the compiler option fmake special table fMST helps to eliminate the need for setting a SPECIAL page vector definition file in the startup file For details refer to the description of pragma SPECIAL in Appendix A Command Option Refer ence and Appendix B Extended Function Reference utl30 Error Messages Error Messages Table G 2 lists the utl30 calculation utility error messages and their countermeasures Table G 2 sbutl Error Messages Error message Contents of error and corrective action ignore option 6 You specified an option that cannot be in used utl30 55 Specify a proper option Illegal file extension XXX Extension of input file is illegal Specify a proper file No input x30 file specified No map file specify map file cannot open x30 file file name Map file not found Specify the correct input map file cannot close file file name 6 input file cannot be closed Specify the correct input file name cannot open output file file name 9 Output file cannot be close Specify the correct output file name not enough memory The extended memory is insufficient Increase the extended memory since file name file exist it makes The file name specified with o already exist a standard output Check the output file name
96. of members variables of a struct or union Do not specify near and far for members task function called The function specified by pragma TASK is called Be careful not to call a task function task function can t return value The function specified by pragma TASK is using a return value The function specified by pragma TASK cannot use return values Delete the return value Appendix F 30 Appendix F Error Messages Table F 29 ccom30 Warning Messages 9 10 Warning message Description and countermeasure task function has invalid argument The function specified with pragma TASK uses arguments Any function specified with pragma TASK can not use arguments Delete the arguments this comparison is always false Comparison is made that always results in false Check the conditional expression this comparison is always true 6 Comparison is made that always results in true Check the conditional expression this feature not supported now ignored 6 This is a syntax error Do not this syntax because it is reserved for extended use in the future Write the description correctly this function used before with non default argument A function once used is declared as a function that has a default argument Declare the default argument before using a func tion this interrupt function is called as normal function bef
97. of the standard NC30 header files Contents of Standard Header Files NC30 includes the 15 standard header files shown in Table E 1 Table E 1 List of Standard Header Files Header File Name Contents assert h Outputs the program s diagnostic information ctype h Declares character determination function as macro errno h Defines an error number float h Defines various limit values concerning the internal representation of floating points limits h Defines various limit values concerning the internal processing of compiler locale h Defines declares macros and functions that manipulate program localization math h Declares arithmetic logic functions for internal processing setjmp h Defines the structures used in branch functions signal h Defines declares necessary for processing asynchronous interrupts stdarg h Defines declares the functions which have a variable number of real arguments stddef h Defines the macro names which are shared among standard include files stdio h Defines the FILE structure Defines a stream name Declares the prototype of input output functions stdlib h Declares the prototypes of memory management and terminate functions string h Declares the prototypes of character string and memory handling functions time h Declares the functions necessary to indicate the current calendar time and de fines the type Standard Header Files Reference
98. operand of the sizeof operator Define the structure or union first 6 The number of elements of an array defined as an operand of the sizeof operator is unknown Define the structure or union first size of incomplete array type An attempt is made to find sizeof of an array of unknown size This is an invalid size Specify the size of the array size of void An attempt is made to find the size of void This is an invalid size The size of void cannot be found standard libraly ifunction name i need iinclude file name 6 This standard library function is used without its header file included Be sure to include the header file static valuable in inline function static data is declared within a function that is declared in storage class inline Do not declare static data in an inline function string size bigger than array size 6 The size of the initialize expression is greater than that of the variable to be initialized Make sure that the size of the initialize expres sion is equal to or smaller than the variable string terminator not added 6 Since the variable to be initialized and the size of the initialize expression are equal 0 cannot be affixed to the character string Increase a element number of array struct or union member s ad dress can t has no near far informa tion near or far is used as arrangement position infor mation
99. out It becomes a compile error when a recursive call is described 4 Regarding the definition of an inline function When specifying inline storage class for a function be sure to define the body of the function in addition to declaring it Make sure that this body definition is written in the same file as the function is written The description in Figure B 55 is processed as an error in NC30 inline void func int i void main void func 1 Error Message Error ccom smp c line 5 inline function s body is not declared previously gt func 1 Sorry compilation terminated because of these errors in main Figure B 56 Example of inappropriate code of inline function 1 Furthermore after using some function as an ordinary function if you define that function as an inline function later your inline specification is ignored and all functions are handled as static functions In this case NC30 generates a warning See Figure B 57 int func int i void main void func 1 inline int func int i return i Warning Message Warning ccom smp c line 9 inline function is called as normal function before Change to static function Figure B 57 Example of inappropriate code of inline function 2 Appendix B 30 Appendix B Extended Functions Reference 5 Regarding the address of an inline function The inline function itself does not have an address Therefore if the amp
100. popm RO R1 R2 R3 A0 Al FB Pull registers p Return to C program Figure 3 18 Example Coding of Interrupt Processing Assembler Function NC30 MANUAL 70 Chapter 3 Programming Technique e Notes on Calling C Functions from Assembler Functions Note the following when calling a function written in C from an assembly language pro gram 1 Call the C function using a label preceded by the underscore _ or the dollar 2 Make sure the registers used in the assembler functions are saved before calling any C language function and that they are restored after returning from the C language function NC30 MANUAL 71 Chapter 3 Programming Technique 3 3 3 Notes on Coding Assembler Functions Note the following when writing assembly language functions subroutines that are called from a C program a Notes on Handling B and U flags When returning from an assembler function to a C language program always make sure that the B and U flags are in the same condition as they were when the function was called b Notes on Handling FB Register If you modified the FB frame base register in an assembler function you may not be able to return normally to the C language program from which the function was called Therefore do not modify the FB value in assembler functions If it is yet necessary to modify the FB register for reason of system design save it to the stack at the beginning of a function and restore it when re
101. prototyped ignored A function specified in the pragma pragma name is not prototype declared For functions specified in a pragma pragma name write prototype declaration in advance pragma pragma name s function return type invalid ignored The type of return value for a function specified in the pragma pragma name is invalid Make sure the type of return value is any type other than stOsct union or double pragma pragma name unknown switch ignored The switch specified in the pragma pragma name is invalid Write it correctly Appendix F 23 Appendix F Error Messages Table F 22 ccom30 Warning Messages 2 10 Warning message Description and countermeasure pragma ADDRESS variable initialized ADDRESS ignored The variable specified in pragma ADDRESS is initialized The specification of pragma AD DRESS will be nullified gt Delete either 4pragma ADDRESS or the initialize expression pragma ASM line too long then cut The line in which pragma ASM is written ex ceeds the allowable number of characters 1 024 bytes gt Write it within 1 024 bytes pragma directive conflict pragma of different functions is specified for one function Write it correctly pragma DP n DATA format error ignored NC79 only You have also specified option fDPO8 If you specify both pragma DP n DATA and fDPO8 pragma DP n DATA is inval
102. remainder of the SB area Appendix G 10 Appendix G The SBDATA declaration amp SPECIAL Page Function declaration Utility utl30 G 5 Example of utl30 use 4 5 1 Generating a SBDATA declaration file a Generating a SBDATA declaration file You can output a SBDATA declaration file by means of causing the SBDATA declaration utility utl30 to process files holding information as to the state of using variables Fig G 4 shows an example of making entries in utl30 and Fig G 5 shows an example of SBDATA declaration file utl 30 ncrt0 x30 osbdata lt RET gt 96 Prompt ncrt0 x30 Name of map file Figure G 4 Example utl30 Command Line j pragma SBDATA Utility 5 SBDATA Size 255 pragma SBDATA data3 Size 4 ref 2 pragma SBDATA data2 Size 1 ref 1 pragma SBDATA datal Sizez 2 ref 1 End of File Size is size of data ref is access count of the variables Figure G 5 SBDATA declaration File sbdata h You include the SBDATA declaration file generated above in a program as a header file Fig G 6 shows an example of making setting in a SBDATA file include sbdata h func o mmi t Figure G 6 Example of making settings in a SBDATA Appendix G 11 Appendix G The SBDATA declaration amp SPECIAL Page Function declaration Utility utl30 b Adjustment in an instance in which SB declaration is made in asesembler
103. searched for ReturnValue Returns the position of character c that is last encountered in character string e Returns NULL when character string s does not contain character c Description amp Searches for the character specified in c from the end of area s You can search for O When you specify options O OR or OS the system may selects another functions with good code efficiency by optimization strspn String Handling Functions Function Calculates the length number of specified characters that are found in the charac ter string Format include lt string h gt size_t strspn s1 s2 Method function Argument const char far st Pointer to the character string to be searched in const char far s2 Pointer to the character string of the character to be searched for ReturnValue Returns the length number of specified characters Description Calculates the size of the first character string consisting of characters in s2 from area s1 and searches the characters from the beginning of s1 9 You cannot search for O When you specify options O OR or OS the system may selects another functions with good code efficiency by optimization Appendix E 74 Appendix E Standard Library strstr String Handling Functions Function Searches the specified character from a character string Format include lt string h gt char far strstr s1 52 Method
104. sections You can specify pragma SECTION data and pragma section program two or more times in one file Example B C source program pragma SECTION program prol void func void Changes name of program section to pro1 remai nder omitted Assembly language source program HHH FUNCTION func section prol file smp c Maps to pro1 section line 9 glb func func Change name of data section from data to datal pragma SECTION data datal int i Maps to datal NE section f unc remainder omitted pragma SECTION data data2 int j Maps to data2 NE section sub remainder omitted Figure B 65 Example Use of pragma SECTION Declaration Supplement When modifying the name of a section note that the section s location attribute e g _NE or is added after the section name Note In NC30WA V4 00 or earlier the data and rom sections as with the bss section could only have their names altered in file units For this reason the programs created with NC30WA V4 00 or earlier require paying attention to the position where ZPRAGMA SECTION is written String data is output with the rom section name that is last declared Appendix B 40 Appendix B Extended Functions Reference pragma STRUCT Function 1 Inhibits packing of structures 2 Arranges structure members Syntax 1 pragma STRUCTAstructure_tagAunpack 2 pra
105. start the compile driver nc30 and the command line op tions The description of the command line options includes those for the as30 assembler and In30 linkage editor which can be started from nc30 A 1 nc30 Command Format a 3 nc30A command line option A assembly language source file name A relocatable object file name A lt C source file name gt Prompt lt gt Mandatory item Optional item A Space Figure A 1 nc30 Command Line Format 96 nc30 osample as30 I In30 ms ncrt0 a30 sample c lt RET gt lt RET gt Return key Always specify the startup program first when linking Figure A 2 Example nc30 Command Line Appendix A 1 A 2 A 2 1 Appendix A Command Option Reference nc30 Command Line Options Options for Controlling Compile Driver Table A 1 shows the command line options for controlling the compile driver Table A 1 Options for Controlling Compile Driver Option Function C Creates a relocatable file extension r30 and ends processing Didentifier Defines an identifier Same function as define Idirectory Specifies the directory containing the file s specified in include You can specify up to 8 directories E Invokes only preprocess commands and outputs result to standard output P Invokes only preprocess commands and creates a file extension i S Creates an assembly language source file extension a30 and ends
106. storage class available fno_align Does not align the start address the function Inthe entry version this option cannot be specified fUSRW None Changes the default instruction for calling functions to JSR W fbit fB Generates code assuming that bitwise manipulating instructions can be executed using absolute ad dressing for all external variables mapped into the near area fno_carry fNC Suppresses carry flag addition when data is indi rectly accessed using far type pointers fauto_128 fA1 Limits the usable stack frame to 128 byte fuse DIV FUD This option changes generated code for divide op eration In the entry version this option cannot be specified finfo None Outputs the information required for the Inspector STK Viewer Map Viewer and utl30 to the absolute module file x30 In the entry version this option cannot be specified fswitch_other_section fSOS This option outputs a ROM table for a switch state ment to some other section than a program section fchange bank always fCBA This option allows you to write multiple variables to an extended area fauto over 255 fAO2 Changes the stack frame size per function that can be reserved to 64 Kbytes ferase static function fESF If the function specified by this option is a static function name function name function no codes are generated for that functio fdouble 32 532 This option specifies that the double type be
107. string to be concatenated from size tn Number of characters to be concatenated ReturnValue Returns a pointer to the concatenated character string area Description Concatenates character strings s1 and n characters from character string 62 The concatenated string ends with NULL When you specify options O OR or OS the system may selects another functions with good code efficiency by optimization Appendix E 71 Appendix E Standard Library strncmp String Handling Function Function Compares character strings n characters Format include lt string h gt int strncmp s1 52 n Method function Argument const char _far s1 Pointer to the first character string to be compared const char far s2 Pointer to the second character string to be compared Size tn Number of characters to be compared ReturnValue Return Value O The two character strings are equal 9 Return Value O0 The first character string s1 is greater than the other 6 Return Value O The second character string s2 is greater than the other Description Compares each byte of n characters of two character strings ending with NULL When you specify options O OR or OS the system may selects another functions with good code efficiency by optimization strncpy Function Copies a character string n characters Format include lt string h gt
108. the I option 8 times or less The command line ends with the I option Specify the name of an include file after the I option 9 The string following the D option is not of a character type letter or underscore that can be used in a macro name Illegal macro name defini tion Specify the macro name correctly and define the macro correctly The command line ends with the D option Specify a macro filename after the D option 6 The string following the U option is not of a character type letter or underscore that can be used in a macro name Define the macro correctly You specified an illegal option on the cpp30 com mand line Specify only legal options 11 cannot open input file 6 Input file not found Specify the correct input file name 12 cannot close input file 6 Input file cannot be closed Check the input file name 14 cannot open output file Cannot open output file Specify the correct output file name 15 cannot close output file Cannot close output file Check the available space on disk Appendix F 4 Appendix F Error Messages Table F 4 cpp30 Error Messages 2 4 No Error message Description and countermeasure 16 cannot write output file Error writing to output file gt Check the available space on disk 17 input file name buffer over The input filena
109. the init function is called If your application program does not use standard I O comment out the init function call from ncrt0 a30 if STANDARD IO 1 glb init call _init G jsr a init endif M Figure 2 24 Part of ncrt0 a30 Where init Function is Called If you are using only sprintf and sscanf the init function does not need to be called 1 The init function also initializes the microcomputer hardware for standard in put output functions By default the M16C 62 is assumed to be the microcomputer that it initializes When using standard input output functions the init function etc may need to be modified depending on the system in which the microcomputer is to be used NC30 MANUAL 40 Chapter 2 Basic Method for Using the Compiler 2 Settings When Not Using Memory Management Functions To use the memory management functions calloc and malloc etc not only is an area allocated in the heap section but the following settings are also made in ncrt0 a30 1 Initialization of external variable char _mbase 2 Initialization of external variable char mnext Initializes the heap top label which is the starting address of the heap section 3 Initialization of external variable unsigned msize Initializes the HEAPSIZE expression which sets at 2 2 2 e heap section size Figure 2 25 shows the initialization performed in ncrt0 a30 C heap area initialize if HEAP 1 glb
110. the scalar type for an expression in the do while statement do while void statement 6 The void type is used in the expression of the do while statement Use the scalar type for an expression in the do while statement duplicate frame position defind variable name 6 Auto variable is described more than twice Write the type specifier correctly duplicate long 6 long is described more than twice Write the type specifier correctly Empty declare Only storage class and type specifiers are found Write a declarator float and double not have sign 6 Specifiers signed unsigned are described in float or double Write the type specifier correctly floating point value overflow The floating point immediate value exceeds the representable range Make sure the value is within the range floating type s bitfield bit field of an invalid type is declared Use the integer type to declare a bit field for struct union statement The struct or union type is used in the second expression of the for statement Use the scalar type to describe the second ex pression of the for statement Appendix F 11 Appendix F Error Messages Table F 11 ccom30 Error Messages 4 14 Error message Description and countermeasure for void statement The 2nd expression of the for statement has void gt Use the scalar type as
111. the source file 46 undef id not found The following macro names to be undefined in undef were not defined FILE LINE DATE TIME Check the macro name 52 illegal ifdef ifndef command Error in ifdef usage Correct the source file 53 elseif else sequence error elseif or else were used without if ifdef ifndef Use elseif or else only after if ifdef ifndef 54 jendif not exist No endif to match if ifdef ifndef Add endif to the source file 55 endif sequence error 6 endif was used without if ifdef ifndef Use endif only after if ifdef ifndef Appendix F 6 Appendix F Error Messages Table F 6 cpp30 Error Messages 4 4 No Error message Description and countermeasure 61 jillegal line command usage Error in line Correct the source file Appendix F 7 Appendix F Error Messages F 4 cpp30 Warning Messages Table F 7 shows the warning messages output by cpp30 and their countermeasures Table F 7 cpp30 Warning Messages No Warning Messages Description and countermeasure 81 reserved id used You attempted to define or undefine one of the following macro names reserved by cpp30 FILE LINE DATE TIME Use a different macro name 82 assertion warning The result of an assert operation expression was 0 Check the operation expression 83 garbage argument Characters other than a comment exist after a
112. type variables Assignment of immediate values to char type variables Assignment of immediate values to float type variables Appendix A 51 Appendix A Command Option Reference Wno warning stdlib WNWS Function Specifying this option while Wnon prototype or Wall is specified inhibits Alarm for standard libraries which do not have prototype declarationsi Wno used argument WNUA Function Outputs a warning for unused arguments function Appendix A 52 Appendix A Command Option Reference Wno used static function WNUSF Function Supplement Note For one of the following reasons a static function name is output that does not require code generation 9 static functions are made in line by use of the Ostatic to inline option The static function is not referenced from anywhere in the file In the entry version this option cannot be specified Code generation for the static functions output by the compiler when this op tion is specified can be suppressed by specifying the ferase static function option 6 f you want to suppress code generation for the static functions output by the compiler when the Ostatic to inline OSTI option is specified be sure to use ferase static function fESF to suppress code generation The entities of the static functions output by the compiler when this option is specified can never be deleted from the C source file If any function name is written in an ar
113. uart2 receive for user vector 16 word dummy in uartO transmit for user vector 17 word dummy in uartO receive for user vector 18 word dummy in uartl transmit for user vector 19 word dummy in uartl receive for user vector 20 word dummy in timer AO for user vector 21 word dummy in timer Al for user vector 22 word dummy in timer A2 for user vector 23 word dummy in timer A3 for user vector 24 word dummy in timer A4 for user vector 25 word dummy in timer BO for user vector 26 word dummy in timer Bl for user vector 27 word dummy in timer B2 for user vector 28 word dummy in int0 for user vector 29 word dummy in intl for user vector 30 word dummy in int2 for user vector 31 Figure 2 14 Startup Program List 9 sect30 inc 3 11 NC30 MANUAL 30 Chapter 2 Basic Method for Using the Compiler endif word dummy in vector 32 or user or MR30 word dummy in vector 33 or user or MR30 word dummy in vector 34 or user or MR30 word dummy in vector 35 or user or MR30 word dummy in vector 36 or user or MR30 word dummy in vector 37 or user or MR30 word dummy in vector 38 or user or MR30 word dummy in vector 39 or user or MR30 word dummy in vector 40 or user or MR30 word dummy in vector 41 or user or MR30 word dummy in vector 42 or user or MR30 word dummy in vector 43 or user or MR30 word dummy int vector 44 or user or MR30 word dummy i
114. user function that bear the same name as one of the standard library functions 1 Inline padding of functions Regarding functions strcpy and memopy the system performs inline padding of func tions if the conditions in Table E 13 are met Table E 13 Optimization Conditions for Standard Library Functions Function Name Optimization Condition Description Example strcpy First argument far pointer strcpy str sample Second argument string constant memcpy First argument far pointer memopy str sample 6 Second argument far pointer memopy str fp 6 Third argument constant 2 Selection of high speed library NC30 only Some standard library functions have a pointer in argument NC30 normally handles such pointers as the far pointer For this reason NC30 does not generate efficient code if the argument is a near pointer Therefore if the argument is a near pointer the system performs optimization to choose a library function provided for use as near The table below lists the functions that are subject to such optimization Table E 14 Library Functions Subject to Optimization bcopy strcat strnicmp strstr bzero strchr strlen strspn memchr strcmp strncat strtod memcmp strcoll strncmp strtok memcpy strcpy strncpy strtol memicmp strcspn strnicmp strtoul memmove strerror strpbrk strxfrm memset stricmp strrchr Appendix E 84 E 3 E 3 1 Appendix E Standard Lib
115. word In the entry version this option is always enabled i e assumed to be speci fied Therefore it cannot be enabled or disabled by specification Appendix A 28 Appendix A Command Option Reference fnot reserve far and near fNRFAN Modify generated code Function Removes far and near from list of reserved words However _far and _near which have the same functions remain reserved words In the entry version this option is always enabled i e assumed to be speci fied Therefore it cannot be enabled or disabled by specification fnot_reserve_inline INRI Modify generated code Function Does not handle inline as a reserved word However _inline that has the same function is handled as a reserved word In the entry version this option is always enabled i e assumed to be speci fied Therefore it cannot be enabled or disabled by specification Appendix A 29 Appendix A Command Option Reference fextend to int fETI Function Extends char type or signed char type data to int type data to perform opera tion extension as per ANSI rules In the entry version this option is always enabled i e assumed to be speci fied Therefore it cannot be enabled or disabled by specification Supplement n ANSI standards the char type or singed char type data is always extended into the int type when evaluated This extension is provided to prevent a prob lem in char type arithmetic operations e g c1
116. 0 COPYRI GHT C XXXX XXXX RENESAS TECHNOLOGY CORPORATI ON AND RENESAS SOLUTIONS CORPORATION ALL RIGHTS RESERVED Written by X Xxxxx sect30 inc section definition This program is applicable when using the basic 1 0 library Id sect30 inc v 1 22 XXXX XX XX XX XX XX xxxxxxxx Exp df R8C 1 51 for M16C 60 30 20 10 Arrangement of section Near RAM data area SBDATA area section data_SE DATA org 400H data_SE_top section bss_SE DATA ALI GN bss SE top section data SO DATA data SO top section bss SO DATA bss 50 top near RAM area Section data NE DATA ALI GN data NE top Section bss NE DATA ALI GN bss NE top section data NO DATA data NO top section bss NO DATA bss NO top Stack area Section Stack DATA bl kb STACKSI ZE stack top blkb I STACKSI ZE istack top section heap DATA heap_top bikb HEAPSI ZE Figure 2 12 Startup Program List 7 sect30 inc 1 11 NC30 MANUAL 28 Chapter 2 Basic Method for Using the Compiler Near ROM data area section rom_NE ROMDATA ALI GN rom_NE_top section rom NO ROMDATA rom NO top Section data FE DATA 0rg 10000H data FE top section bss_FE DATA ALI GN bss FE top section data_F0 DATA data_FO top
117. 0365 111 23 G 1 G 2 G 3 G 4 G 5 no UWS Ols RO NT 1 6 1 1 Introduction of utl80 prOCeSses uice betreten cR secti cr ente dg 1 Stanno Wig e EUER 2 3 2 1 wtl30 Command Line Format uu oret heeled atl a a diene 2 G 2 2 Selecting Outputnformations i 3 G 2 3 utls0 Command Line Option ec pec tet obe 4 10 Conditions to establish SBDATA declaration amp SPECIAL Page Function declaration 10 G 4 1 Conditions to establish SBDATA declaration ccecceeceeeeeeeceeeeeeseeeeeeeeeeeeeneeteneenaees 10 G 4 2 Conditions to establish SPECIAL Page Function declaration sss 10 Example f UWB USB c 11 G 5 1 Generating a SBDATA declaration file esee 11 a Generating a SBDATA declarationhifile vite dee Geet etas tpa Ru RR 11 b Adjustment in an instance in which SB declaration is made in asesembler 12 NC30 MANUAL IX 4 5 2 Generating a SPECIAL Page Function declaration file sess a Generating a SPECIAL Page Function declaration file seesss
118. 1 NC30 MANUAL 35 Chapter 2 Basic Method for Using the Compiler section heap DATA HEAPSI heap heap_top Near ROM data area section rom_NE ROMDATA 0rg 0e000H rom NE top section rom NO ROMDATA rom NO top Initial data of data section section data SEI ROMDATA ALI GN data SEI top section data 50 ROMDATA data SOI top section data NEI ROMDATA ALI GN data _ NEI top section data NOI ROMDATA data NOI top Switch Table Section l section switch table ROMDATA switch table top code area section program CODE ALI GN section interrupt CODE ALI GN Jif MVT__ 0 variable vector section section vector ROMDATA variable vector table org VECTOR ADR word dummy in vector 0 word dummy in vector 1 word dummy in vector 2 word dummy in vector 3 word dummy in vector 4 word dummy in vector 5 word dummy in vector 6 word dummy in vector 7 word dummy in vector 8 word dummy in vector 9 word dummy in vector 10 word dummy in vector 11 word dummy in vector 12 word dummy in vector 13 word dummy in vector 14 word dummy in vector 15 word dummy in vector 16 word dummy in vector 17 word dummy in vector 18 word dummy in vector 19 word dummy in vector 20 word dummy in vector 21 word dummy in vector 22 Figure 2 20 NC30 MANUAL 36 Startup Program List 15
119. 1 1 Contents of Standard Header Files sessessssssseeeeeeeneennenenennnnnes 1 E 1 2 Standard Header Files Reference essent 1 NC30 MANUAL VIII 2 616 655 2 10 E 2 1 Qverviewor Standard 15181 10 E 2 2 List of Standard Library Functions by Function esseeeenee 11 a siting Handling PUNCIONS s eius cot C Ane EI ERE IE HEISE EIC CHEER a eee 11 b Character Handling FURCIONS 55 ooo eripiat Ivi ov bap edt e ac cb Pene N 12 E R ee eee 19 d Memory Management FUNCIONS ayani hd es Aiea 13 e Memory Handling aee acct eine tae sie AR 14 Ts Execution Control EU CUOI ean ap t dora nae dan p Duda ciae dis 14 9 Mathematical EUfellanms usse oe sento ee ES ox p E REG REIN DEMER 15 he Integer Arithmetic FUNCIONS us ooh ERR qe rasa mE Ex des eee 15 i Character String Value Convert FUNGHIONS iecit erre et trier te 16 j Multi byte Character and Multi byte Character String Manipulate Function
120. 2 SPECIAL 131 SPECIAL 130 SPECIAL 129 SPECIAL 128 SPECIAL 127 SPECIAL 126 SPECIAL 125 SPECIAL 124 SPECIAL 123 SPECIAL 122 SPECIAL 121 SPECIAL 120 SPECIAL 119 SPECIAL 118 SPECIAL 117 SPECIAL 116 SPECIAL 115 SPECIAL 114 SPECIAL 113 SPECIAL 112 SPECIAL 111 SPECIAL 110 SPECIAL 109 SPECIAL 108 SPECIAL 107 SPECIAL 106 SPECIAL 105 SPECIAL 104 SPECIAL 103 SPECIAL 102 SPECIAL 101 SPECIAL 100 SPECIAL 99 j SPECIAL 98 SPECIAL 97 SPECIAL 96 SPECIAL 95 SPECIAL 94 SPECIAL 93 SPECIAL 92 SPECIAL 91 s SPECIAL 90 SPECIAL 89 SPECIAL 88 SPECIAL 87 SPECIAL 86 SPECIAL 85 A A A SPEC Figure 2 17 Startup Program List 12 sect30 inc 6 11 NC30 MANUAL 33 Chapter 2 Basic Method for Using the Compiler SPECIAL 81 SPECIAL 80 A SPECIAL 79 SPECIAL 78 j SPECIAL 77 A SPECIAL 76 SPECIAL 75 SPECIAL 74 i SPECIAL 73 SPECIAL 72 SPECIAL 71 SPECIAL 70 SPECIAL 69 SPECIAL 68 SPECIAL 67 i SPECIAL 66 SPECIAL 65 SPECIAL 64 SPECIAL 63 SPECIAL 62 SPECIAL 61 SPECIAL 60 SPECIAL 59 SPECIAL 58 SPECIAL 57 SPECIAL 56 SPECIAL 55 SPECIAL 54 SPECIAL 53 SPECIAL 52 i SPECIAL 51 SPECIAL 50 SPECIAL 49 SPECIAL 48 A SPECIAL 47 i SPECIAL 46 SPECIAL 45 A SPECIAL 44 SPECIAL 43 SPECIAL 42 j SPECIAL 41 SPECIAL 40 SPECIAL 39 SPECIAL 38 SPE
121. 21 Appendix A Command Option Reference Ostack_frame_align OSFA Function Aligns the stack frame on an even boudary In the entry version this option cannot be specified Supplement When even sized auto variables are mapped to odd addresses memory ac cess requires one more cycle than when they are mapped to even addresses This option maps even sized auto variables to even addresses thereby speed ing up memory access Notes 1 The following functions apecified in pragma are not aligned pragma INTHANDLER pragma HANDLER pragma ALMHANDLER pragma CYCHANDLER pragma INTERRUPT 2 Be sure that the stack point is initialized to an even address in the startup program Also be sure to compile all programs using this option 3 All files should be compiled using this option Oloop_unroll loop count OLU Function Unrolls code as many times as the loop count without revolving the loop state ment The loop count can be omitted When omitted this option is applied to a loop count of up to 5 In the entry version this option cannot be specified Supplement Unrolled code is output for only the for statements where the number of times they are executed is known Specify the upper limit count for which times for is revolved in the target for statement to be unrolled By default this option is applied to the for statements where for is revolved up to five times Notes The ROM size increases for reasons that the for s
122. 30 inc section definition This program is applicable when using the basic 1 0 library Id sect30 inc v 1 22 XX XX XX xxxxxxxx Exp Lif __R8C__ 1 gt for M16C 60 30 29 10 Arrangement of section Near RAM data area SBDATA area section data_SE DATA org 400H data_SE_top section bss_SE DATA ALI GN bss SE top section data SO DATA data SO top Section bss SO DATA bss SO top near RAM area Section data NE DATA ALI GN data NE top section bss NE DATA ALI GN bss NE top section data NO DATA data NO top Section bss NO DATA bss NO top Stack area section stack DATA bl kb STACKSIZE stack top blkb I STACKSI istack top heap section section heap DATA heap_top blkb HEAPSI ZE Figure 2 32 Listing of sect30 inc in Single Chip Mode 1 4 NC30 MANUAL 50 Chapter 2 Basic Method for Using the Compiler Near ROM data area section rom NE ROMDATA ALIGN rom NE top 2 SOC ON rom NO ROMDATA data FE DATA OF G 10000H SECUN OM bss FE DATA ALI GN EE TOW SOGWI ON data FO DATA data FO top Section bss FO top bss_FO DATA Far ROM data area Section rom FE ROMDATA 0rg 0F0000H rom FE top section rom FO top rom FO ROMDATA Initial data of data section Section data NEI ROMDATA data NE 0p Section data NOI ROMDATA
123. 30A Didentifier constant A lt C source file gt constant is optional Execution nc30 c DMYDEBUG 1 DMSDOS 1 DUNI X sample c example M16C 60 NC30 COMPILER V X XX Release X COPYRIGHT C XXXX XXXX RENESAS TECHNOLOGY CORPORATION ALL RIGHTS RESERVED AND RENESAS SOLUTIONS CORPORATION ALL RIGHTS RESERVED sample c M Notes The number of identifiers that can be defined may be limited by the maximum number of characters that can be specified on the command line of the operat ing system of the host machine Appendix A 3 Appendix A Command Option Reference Idirectory Function Specifies the directory name in which to search for files to be referenced by the preprocess command include Max specified 8 directory Syntax nc30A l directoryA C source file gt Execution le nc30 c l test include I test inc sample c example M16C 60 NC30 COMPILER V X XX Release X COPYRIGHT C XXXX XXXX RENESAS TECHNOLOGY CORPORATION ALL RIGHTS RESERVED AND RENESAS SOLUTIONS CORPORATION ALL RIGHTS RESERVED sample c In this example two directories test include and test inc are specified Notes The number of directories that can be defined may be limited by the maximum number of characters that can be specified on the command line of the operat ing system of the host machine Compile driver control Function Invokes only preprocess commands and outputs results to s
124. 6 shows the command line options for controlling nc30 generated assembly code Table 2 6 1 2 Option Short form Generated Code Modification Options Description fansi None Makes fnot_reserve_far_and_near fnot_reserve_asm and fextend_to_int valid In the entry version this option is always enabled i e assumed to be specified Therefore it cannot be enabled or disabled by specification fnot reserve asm INRA Exclude asm from reserved words Only asm is valid In the entry version this option is always enabled i e assumed to be specified Therefore it cannot be enabled or disabled by specification fnot reserve far and near INRFAN Exclude far and near from reserved words Only _far and near are valid In the entry version this option is always enabled i e assumed to be specified Therefore it cannot be enabled or disabled by specification fnot reserve inline fNRI Exclude far and near from reserved words Only inline is made a reserved word In the entry version this option is always enabled i e assumed to be specified Therefore it cannot be enabled or disabled by specification fextend to int fETI Performs operation after extending char type data to the int type Extended according to ANSI stan dards In the entry version this option is always enabled i e assumed to be specified Therefore it cannot be enabled or disable
125. 8 shows the offsets when the structure shown in Figure B 66 is arranged using pragma STRUCT Va P Membername Type Size Mapped location offset oee i int 16 bits 0 int j j int 16 bits 2 H char 8 bits 4 SS Figure B 68 Example Mapping of Structure Members 3 You must declare pragma STRUCT for inhibiting packing and arranging the structure members before defining the structure members pragma STRUCT TAG unpack struct TAG int char Cs sl Figure B 69 Example of pragma STRUCT Declaration Appendix B 42 Appendix B Extended Functions Reference pragma EXT4MPTR Function A functional extension which shows a variable is a pointer accessing 4 Mbyte ex panded space ROM Syntax pragma EXTAMPTRA pointer name Descripion his feature is provided for extension mode 2 4M byte extension mode which is available with some products in the M16C 62 group Declare a pointer variable for accessing a 4M byte space When so declared the compiler generates code for switching banks as necessary to access a 4M byte space This bank switching code is generated one for each function in the place where the pointer is used first In successive operations therefore the banks are set only once When using multiple pointer variables use the fchange bank always fCBA op tion which sets the banks each time the program accesses the 4M byte space
126. 9 255bytes NC30 NC77 and NC79 with fDPO8 option used Currently nnn bytes have been used Reduce the auto variables parameters and other variables stored in the stack frame area Sorry compilation terminated because of these errors in function name An error occurred in some function indicated by function name Compilation is terminated Correct the errors detected before this message is output Sorry compilation terminated because of too many errors Errors in the source file exceeded the upper limit 50 errors Correct the errors detected before this message is output struct or enum s tag used for union The tag name for structure and enumerated type is used as a tag name for union Change the tag name struct or union s tag used for enum 6 The tag name for structure and union is used as a tag name for enumerated type Change the tag name struct or union enum does not have long or sign 6 Type specifiers long or signed are used for the struct union enum type specifiers gt Write the type specifier correctly switch s condition is floating The float type is used for the expression of a switch statement gt Use the integer type or enumerated type switch s condition is void The void type is used for the expression of a switch statement gt Use the integer type or enumerated type switch s condition must integer Invalid types o
127. A Z Format include ctype h int isupper c Method macro Argument int c Character to be checked ReturnValue Returns any value other than 0 if an upper case letter Returns 0 if not an upper case letter Description Determines the type of character in the parameter Appendix E 41 Appendix E Standard Library isxdigit Character Handling Functions Function Checks whether the character is a hexadecimal character 0 9 A F a f Format include lt ctype h gt int isxdigit c Method macro Argument Character to be checked ReturnValue Returns any value other than 0 if a hexadecimal character Returns 0 if not a hexadecimal character Description Determines the type of character in the parameter labs Integer Arithmetic Functions Function Calculates the absolute value of a long type integer Format include lt stdlib h gt long labs n Method function Argument long n Long integer ReturnValue Returns the absolute value of a long type integer distance from 0 Appendix E 42 Idexp Appendix E Standard Library Localization Functions Function Format Method Argument Calculates the power of a floating point number include lt math h gt double Idexp x exp function double X Float point number int exp Power of number ReturnValue Retu
128. Appendix A Command Option Reference Werror file file name WEF Function Outputs error messages to the specified file Syntax nc30A Werror fileA output error message file name gt Supplement The format in which error messages are output to a file differs from one in which error messages are displayed on the screen When error messages are output to a file they are output in the format suitable for the tag jump function that some editors have Output example test c 12 Error ccom unknown variable i Wstop at warning WSAW Function Stops compiling the source files if a warning occurs during compiling and re turns the compiler end code 10 Supplement If a warning occurs when compiling the compilation by default is terminated with the end code 0 terminated normally Use this option when you are using the make utility etc and want to stop com pile processing when a warning occurs Appendix A 48 Appendix A Command Option Reference Wnesting_comment WNC Function Generates a warning when comments include Supplement By using this option it is possible to detect nesting of comments Wccom max warnings Warning Count WCMW Function This option allows you to specify an upper limit for the number of warnings output by ccom30 Supplement By default there is no upper limit to warning outputs Use this option to adjust the screen as it scrolls for many warnings that are output N
129. Appendix A Command Option Reference fnot address volatile fNAV Function Does not handle the global variables specified by pragma ADDRESS or pragma EQU or the static variables declared outside a function as those that are specified by volatile Supplement If I O variables are optimized in the same way as for variables in RAM the compiler may not operate as expected This can be avoided by specifying volatile for the I O variables Normally pragma ADDRESS or pragma EQU operates on I O variables so that even though volatile may not actually be specified the compiler processes them assuming volatile is specified This option suppresses such processing You do not normally need to use this option however fsmall array fSA Function When referencing a far type array whose total size is unknown when compil ing this option calculates subscripts in 16 bits assuming that the array s total size is within 64 Kbytes Supplement If when referencing array elements in a far type array such as array data in ROM the total size of the far type array is uncertain the compiler calculates subscripts in 32 bits in order that arrays of 64 Kbytes or more in size can be handled Take a look at the example below extern int array int i array j In this case because the total size of the array array is not known to the com piler the subscript j is calculated in 32 bits When this option is specified the compiler assumes the to
130. Appendix F 25 Appendix F Error Messages Table F 24 ccom30 Warning Messages 4 10 Warning message Description and countermeasure cyclic or alarm handler function has argument e The function specified by pragma CYCHANDLER or ALMHANDLER is using an ar gument The function cannot use an argument Delete the argument enumerator value overflow size of unsigned char 6 The enumerator value exceeded 255 Do not use more than 255 for the enumerator otherwise do not specify the startup function fchar_enumerator enumerator value overflow size of unsigned int The enumerator value exceeded 65535 Do not use more than 65535 to describe the enumerator enum s bitfield An enumeration is used as a bit field member Use a different type of member external variable initialized change to public An initialization expression is specified for an ex tern declared variable extern will be ignored Delete extern far pointer implicitly casted by near pointer The far pointer was converted into the near pointer Check the data types near or far function must be far 6 The function is declared with the near type Write it correctly handler function called 6 The function specified by pragma HANDLER is called Be careful not to call a handler handler function can t return value The function specified by pragma HANDLER is using a retur
131. CIAL 30 func pragma SPECIAL 30 func vectz30 c Using MR30 Extended Functions Table B 5 Extended Functions for MR30 Extended function Description pragma ALMHANDLER Declares the name of the MR30 alarm handler function Syntax pragma ALMHANDLER function name Example pragma ALMHANDLER alm func pragma CYCHANDLER Declares the name of the MR30 cycle start handler function Syntax pragma CYCHANDLER function name Example pragma CYCHANDLER cyc func pragma INTHANDLER pragma HANDLER Declares the name of the MR30 interrupt handler function Syntax1 fpragma INTHANDLER function name Syntax2 pragma HANDLER function name Example pragma NTHANDLER int func pragma TASK Declares the name of the MR30 task start function Syntax fpragma TASK task start function name Example pragma TASK taski Supplement The above extended function normally is generated by the configurator so that the user need not be concerned with it Appendix B 35 Appendi x B Extended Functions Reference d The Other Extensions Table B 6 Us Extended feature ing Inline Assembler Description Function Description pragma ASM pragma ENDASM Specifies an area in which statements are written in assembly language Syntax pragma ASM pragma ENDASM Example pragma ASM mov w RO RI add w R1 02H pragma ENDASM pragma JSRA Calls functions using JSR A as the JSR instruction S
132. CIAL 37 SPECIAL 36 SPECIAL 35 SPECIAL 34 SPECIAL 33 SPECIAL 32 SPECIAL 31 SPECIAL 30 i SPECIAL 29 SPECIAL 28 SPECIAL 27 SPECIAL 26 SPECIAL 25 SPECIAL 24 SPECIAL 23 d SPECIAL 22 SPECIAL 21 SPECIAL 20 SPECIAL 19 SPECIAL 18 else Section NC svector ROMDATA 0rg SVECTOR ADR endif MST Figure 2 18 Startup Program List 13 sect30 inc 7 11 NC30 MANUAL 34 Chapter 2 Basic Method for Using the Compiler fixed vector section section fvector ROMDATA org OfffdcH Up s word dummy in OVER FLOW A _ word dummy in BRKI word dummy in ADDRESS MATCH _ word dummy in SINGLE STEP word dummy in WDT word dummy in DBC word dummy in NMI l word dummy_in org OffffcH RESET word start Jel se R8C__ for R8C Ti ny Arrangement of section Near RAM data area SBDATA area section data_SE DATA org 400H data_SE_top section bss SE DATA ALI GN bss SE top section data SO DATA data SO top Section bss SO DATA bss 50 top near RAM area Section data NE DATA ALI GN data NE top section bss NE DATA ALI GN bss NE top section data NO DATA data NO top Section bss NO DATA bss NO top Section Stack DATA ALI GN bl kb STACKSI ZE stack top blkb I STACKSI ZE istack top Figure 2 19 Startup Program List 14 sect30 inc 8 1
133. COPY data FEI top data FE top data FE BCOPY data FOI top data FO top data FO dc stack_top sp Stk 40 heap area initialize 13 if HEAP 1 __mbase glb glb __msize heap_top amp OFFFFH __ mbase mov w heap_top gt gt 16 __mbase 2 mov w heap_top amp OFFFFH __mnext mov w heap_top gt gt 16 __mnext 2 mov w HEAPS ZES amp OFFFFH __msize mov w HEAPSIZE gt gt 16 __msize t2 endi f Initialize standard 1 0 14 if STANDARD 10 1 glb init call _init G jsr a init endif Call main function 15 dc 0h fb for debuger glb main jsr a main else R8C 10 Moves the initial values of the near and SBDATA data section to RAM 11 Clears the far bss section to zeros 12 Moves the initial values of the far data section to RAM 13 Initializes the heap area Comment out this line if no memory management function is used 14 Calls the init function which initializes standard I O Comment out this line if no I O function is used 15 Calls the main function 2 Figure 2 9 Startup Program List 4 ncrt0 a30 4 6 1 Comment out this line if no far area is used 2 Interrupt is not enable when calls main function Therefore permits interrupt by FSET command when uses interrupt function NC30 MANUAL 25 Chapter 2 Basic Method for Using the Compiler for R8C Tiny Interrupt section start insf start 0 g
134. Corporation and Renesas Solutions Corporation assume no responsibility for any damage liability or other loss resulting from the information contained herein Renesas Technology semiconductors are not designed or manufactured for use in a device or system that is used under circumstances in which human life is potentially at stake Please contact Renesas Technology Corporation Renesas Solutions Corporation or an authorized Renesas Technology product distributor when considering the use of a product contained herein for any specific purposes such as apparatus or systems for transportation vehicular medical aerospace nuclear or undersea repeater use The prior written approval of Renesas Technology Corporation and Renesas Solutions Corporation is necessary to reprint or reproduce in whole or in part these materials f these products or technologies are subject to the Japanese export control restrictions they must be exported under a license from the Japanese government and cannot be imported into a country other than the approved destination Any diversion or reexport contrary to the export control laws and regulations of Japan and or the country of destination is prohibited Please contact Renesas Technology Corporation or Renesas Solutions Corporation for further details on these materials or the products contained therein For inquiries about the contents of this document or product fill in the text file the installer generates in
135. D C Language Specification Rules Sign Extension Rules Under the ANSI and other standard C language specifications char type data is sign extended to int type data for calculations etc This specification prevents the maximum value for char types being exceeded with unexpected results when performing the char type calculation shown in Figure D 9 func char c2 c3 c1 c2 2 c3 Figure D 9 Example of C Program To generate code that maximizes code efficiency and maximizes speed NC30 does not by default extend char types to int types The default can however be overridden using the nc30 compile driver command line option fansi or fextend_to_int fETI to achieve the same sign extension as in standard C If you do not use the fansi or fextend_to_int fETI option and your program assigns the result of a calculation to a char type as in Figure D 9 make sure that the maximum or minimum value for a char type does not result in an overflow in the calculation 1 The ranges of values that can be expressed as char types in NC30 are as follows unsigned char type 092255 signed 128 127 Function Call Rules Rules of Return Value When returning a return value from a function the system uses a register to return that value for the integer pointer and floating point types Table D 4 shows rules on calls regarding return values Ta
136. Description Performs conditional compilation Examines the macro defined or not ifndefAidentifier expression endif If an identifier isn t defined ifndef processes the program that follows You can also describe the followings ifA definedAidentifier ifA definedA identifier else is used in a pair with ifndef Do not specify any tokens between else and the line feed You can however insert a comment elif is used in a pair with if ifdef or ifndef endif indicates the end of the range controlled by ifndef Always be sure to enter endif when using command ifndef Combinations of ifndef else endif can be nested There is no set limit to the number of levels of nesting but it depends on the amount of available memory Appendix C 25 Appendix C Overview of C Language Specifications C 3 3 Predefined Macros The following macros are predefined in NC30 M16C NC30 C 3 4 Usage of predefined Macros The predefined macros are used to for example use preprocess commands to switch machine dependent code in non NC30 C programs ifdef NC30 pragma ADDRESS portO 2H pragma ADDRESS porti 3H else pragma AD portA Ox5F pragma AD portB 0x60 endif Figure C 14 Usage Example of Predefined Macros Appendix C 26 Appendix D C Language Specification Rules C Language Specification Rules This appendix describes the internal structure and mapping of data proces
137. E 2 outlines how to modify the I O functions to match the target system a Modify the level 3 I O function s b Set the stream C Compile the modified source program s Figure E 2 Example Sequence of Modifying I O Functions a Modifying Level 3 I O Function The level 3 I O functions perform 1 byte I O via the M16C 60 series I O ports The level 3 I O functions include _sget and _sput which perform I O via the serial communications circuits UART and _pput which performs I O via the Centronics communications circuit Circuit settings Processor mode Microprocessor mode Clock frequency 20MHz External bus size 16 bits Initial serial communications settings Use UART1 Baud rate 9600bps Data size 8 bits Parity None Ge Stop bits 2 bits The initial serial communications settings are made in the init function init c Appendix E 86 Appendix E Standard Library The level 3 I O functions are written in the C library source file device c Table E 13 lists the specifications of these functions Table E 13 Specifications of Level 3 Functions Input functions Parameters Return value int type _sget If no error occurs returns the input character Sput None Returns EOF if an error occurs pput Output functions Parameters int type Return value int type Sput Character to If no error occurs returns 1 pput output Returns EOF if an error occurs
138. ESS MATCH word dummy in SI NGLE_STEP word dummy in WDT word dummy in DBC i dummy in P NMI word dummy in org OfffcH RESET word start endif R8C Figure 2 21 Startup Program List 16 sect30 inc 10 11 NC30 MANUAL 37 Chapter 2 Basic Method for Using the Compiler section rom_FE ROMDATA org 10000H section rom FO ROMDATA Section data FEI ROMDATA ALI GN data FEI top Section data FOI ROMDATA data FOI top C Compiler for R8C Tiny M16C 60 30 20 10 COPYRI GHT C XXXX XXXX RENESAS TECHNOLOGY CORPORATI ON AND RENESAS SOLUTIONS CORPORATION ALL RIGHTS RESERVED Figure 2 22 Startup Program List 17 sect30 inc 11 11 NC30 MANUAL 38 Chapter 2 Basic Method for Using the Compiler 2 2 2 Customizing the Startup Program a Overview of Startup Program Processing About ncrt0 a30 This program is run at the start of the program or immediately after a reset It performs the following process mainly 6 Sets the top address SB of the SBDATA area it is accessing area to used the SB relative addressing mode 6 Sets the processor s
139. Figure E 7 Method of Directly Linking Modified Source Programs make RET Figure E 8 Method of Updating Library Using Modified Source Programs Appendix E 94 Appendix F Error Messages Appendix F This appendix describes the error messages and warning messages output by NC30 and their countermeasures F 1 Message Format If during processing NC30 detects an error it displays an error message on the screen and stops the compiling process The following shows the format of error messages and warning messages nc30 error message Figure F 1 Format of Error Messages from the nc30 Compile Driver Error cpp30 error No filename line No error message Error ccom filename line No error message Fatal ccom filename line No error message 1 Figure F 2 Format of Command Error Messages Warning cpp30 warning No filename line No warning message Warning ccom filename line No warning message Figure F 3 Format of Command Warning Messages The following pages list the error messages and their countermeasures cpp30 messages are listed according to their Nos The messages output by other programs are listed alpha betically symbols followed by letters 1 Fatal error message This error message is not normally output Please contact nearest Renesas office with details of the message if displayed Appendix F 1 F2 Appendix F Error
140. Functions Reference B 4 3 Restrictions on Default Argument Declaration of Function The default argument declaration of a function is subject to some restrictions as listed below These restrictions must be observed When specifying a default value for multiple arguments When specifying a default value in a function that has multiple arguments always be sure to write values beginning with the last argument Figure B 51 shows examples of incorrect description void func int i int j 1 int k 2 correct void func2 int i int int k 2 correct void func3 int i 0 int int k incorrect void func4 int i 0 int int k 1 incorrect Figure B 51 Examples of Prototype Declaration When specifying a variable for a default value When specifying a variable for a default value write the prototype declaration of a function after declaring the variable you specify If a variable is specified for the default value of an argument that is not declared before the prototype declaration of a function it is processes as an error Appendix B 27 Appendix B Extended Functions Reference B 5 inline Function Declaration NC30 allows you to specify the inline storage class in the similar manner as in C By specifying the inline storage class for a function you can expand the function inline This chapter describes specifications of the inline storage class B 5 1 Overview of inline Storage Class Th
141. Furthermore pay careful attention to the functions that will be called while the SB register is modified and the interrupts that may occur during that time 3 Do not modified the FB register by the asm functions because which use for the stack flame pointer C Notes on Labels The assembler source files generated by NC30 include internal labels in the format shown in Figure B 38 Therefore you should avoid using labels in an asm function that might result in duplicate names Labels consisting of one uppercase letter and one or more numerals Examples A1 C9830 Labels consisting of two or more characters preceded by the underscore _ Examples _ LABEL START Figure B 38 Label Format Prohibited in asm Function Appendix B 21 Appendix B Extended Functions Reference B 3 Description of Japanese Characters NC30 allows you to include Japanese characters in your C source programs This chapter describes how to do so B 3 1 Overview of Japanese Characters In contrast to the letters in the alphabet and other characters represented using one byte Japanese characters require two bytes NC30 allows such 2 byte characters to be used in character strings character constants and comments The following character types can be included e kanji 6 hiragana full size katakana half size katakana Only the following kanji code systems can be used for Japanese characters in NC30 EUC excluding user defined chara
142. IBM PC AT or compatible Turbo Linux 7 0 Intel Pentium II Memory 128MB min b C Source File Coding Specifications Table C 4 shows the specifications for coding NC30 C source files Note that estimates are provided for items for which actual measurements could not be achieved TableC 4 Specifications for Coding C Source Files Item Specification Number of characters per line of source 512 bytes characters including the new line file code Number of lines in source file 65535 max Appendix C 2 Appendix C Overview C Language Specifications NC30 Specifications Table C 5 to C 5 lists the NC30 specifications Note that estimates are provided for items for which actual measurements could not be achieved Table C 5 NC30 Specifications Item Specification Maximum number of files that can be specified in NC30 Depends on amount of available memory Maximum length of filename Depends on operating system Maximum number of macros that can be specified in nc30 command line option D Depends on amount of available memory Maximum number of directories that can be specified in nc30 command line option 8max Maximum number of parameters that can be specified in nc30 command line option
143. MOV W RO FB idata asm MOV W RO FB a 2 asm RO FB s i Remainder omitted asm MOV W FB FB s i a 2 Figure B 19 Description example for specifying FB offset Figure B 20 shows an example for referencing an auto variable and its compile result Appendix B 11 Appendix B Extended Functions Reference 6 C source file void func Ht auto variable FB offset value 2 asm MOV W FB RO idata asm CMP W 00001H remainder omitted Assembly language source file compile result 14 FUNCTION func 188 4 FRAME AUTO idata size 2 offset 2 abbreviated H C_SRC asm MOV W FB RO idata HH ASM START MOV W 2 FB RO Transfer FB offset value 2 to RO register line 5 3HE 40 SRC asm CMP W 400001H R0 CMP W 00001H RO 184488 ASM END remainder omitted Figure B 20 Example for Referencing an auto Variables You can also use the format shown in Figure B 21 so that auto variables in an asm function use a 1 bit bit field Can not operate bit fields og greater than 2 bits asm op code b FB bit field name Figure B 21 Format for Specifying FB Offset Bit Position You can only specify one variable name using this format Figure B 22 is an example void func void struct TAG char bit0 1 char bit1 1 char bit2 1 char bit3 1 5 asm bset b FB s bit1 Figure B 22 Example for Spec
144. Makes all gobal variables vaild Function When used simultaneously with the sb30 option Because the usage frequency is low SBDATA declaration is output in the form of a comment for even the variables that are not placed in the SB area When used simultaneously with the sp30 option Because the usage frequency is low SPECIAL declaration is output in the form of a comment for even the functions that are not placed in the SPECIAL page area Execution Output SBDATA declaration example utl 30 sb30 all ncrt0 x30 M16C 60 UTILITY UTL30 for M16C 80 V X XX XX COPYRIGHT C XXXX XXXX RENESAS TECHNOLOGY CORPORATION ALL RIGHTS RESERVED AND RENESAS SOLUTIONS CORPORATI ON ALL RIGHTS RESERVED t ype sample h pragma SBDATA Utility SBDATA Size 255 pragma SBDATA z size 2 ref 2 omit pragma SBDATA vx l size 2 refz 1 Output SPECIAL page Function declaration utl 30 sp30 all ncrt0 x30 M16C 60 UTILITY UTL30 for M16C 80 V X XX XX COPYRI GHT C XXXX XXXX RENESAS TECHNOLOGY CORPORATION ALL RIGHTS RESERVED AND RENESAS SOLUTIONS CORPORATION ALL RIGHTS RESERVED t ype sample h j pragma SPECIAL PAGE Utility asl pragma SPECIAL 255 func J size 200 refz 2 omit pragma SPECIAL 254 funcl size 2000 refz 1 M Supplement Supplement Use of this option helps to find the functions which are not called eve
145. S Generates an assembly language source file extension a30 with a C language source list output as a comment Not deleted even after assembling dsource in list Short form dSL In addition to the dsource function generates an assembly lan guage list file Ist b Options Specifying Output Files Table 2 2 shows the command line option that specifies the name of the output machine language data file Table 2 2 Options for Specifying Output Files Option Function ofilename Specifies the name s of the file s absolute module file map file etc generated by In30 This option can also be used to specify the destina tion directory Do not specify the filename extension dir Specifies the destination directory of the file s absolute module file map file etc generated by In30 1 If you do not specify command line options c E P or S nc30 finishes at In30 and output files up to the absolute load module file extension x30 are created NC30 MANUAL 15 Chapter 2 Basic Method for Using the Compiler c Version and command line Information Display Option Table 2 3 shows the command line options that display the cross tool version data and the command line informations Table 2 3 Options for Displaying Version Data and Command line informations Option Function V Displays the name of the command program and the command line during execution V Displays the startup message
146. Supplement Code example Optimizes code generation by replacing reference to variables to declared by the const qualifier wih constatnts This is effective even when other than the O4 option is specified In the entry version this option cannot be specified Optimization is performed when all of the following conditions are met 1 Variables not including bit fields and unions 2 Variables for which the const qualifier is specified but are not specified to be volatile 3 Variables that are subject to initialization in the same C language soirce file 4 Variablew that are initialized by constatnt or const qualified variables The following example shows code that can be optimized ra int const i 10 const double ad 3 0 0 0 1 0 2 func int k Replaces i with 10 double d ad 1 Replaces ad 1 with 0 1 A Ono_bit ONB Function Supplement Notes Suppresses optimization based on grouping of bit manipulations In the entry version this option cannot be specified When you specify O or OR or OS optimization is based on grouping ma nipulations that assign constants to a bit field mapped to the same memory area into one routine Because it is not suitable to perform this operation when there is an order to the consecutive bit operations as in I O bit fields use this option to suppress optimization This optimization is performed The variables is s
147. TADDRESS declaration is duplicated but the last declared address is valid An error occurs if you include an initialization expression Normally pragma BITADDRESS operates on I O variables so that even though volatile may not actually be specified the compiler processes them assuming volatile is specified MV pragma BITADDRESS io 1 100H Bool io void func void Figure B 72 pragma BITADDRESS Declaration Appendix B 46 Appendix B Extended Functions Reference pragma INTCALL Function Declares a function called by a software interrupt by the int instruction Syntax 1 pragma INTCALLA C JAINT No Aassembler function name register name register name 2 pragma INTCALLA CJAINT No AC function name Description This extended function declares the assembler function called by a software interrupt with the INT number When calling an assembler function its parameters are passed via registers C NC308 ONLY By specifying switch c it is possible to generate code to need the register to saving it to a stack at entry when calling the function Rules 1 Declaring assembler functions 1 Before a pragma INTCALL declaration be sure to include an assembler function prototype declaration If there is no prototype declaration a warning is output and the pragma INTCALL declaration is ignored 2 Observe the following in the prototype declaration a Make sure that the numb
148. The file can be overwritten by specifying fover write simultaneously with the options Appendix G 14 Appendix G The SBDATA declaration amp SPECIAL Page Function declaration Utility utl30 G 6 2 Warning Messages Table G 3 lists the sbutl utility warning messages and their countermeasures Table G 3 sbutl Warning Messages Warning Message Contents of warning and corrective action confllict declare of variable name The variable shown here is declared in multiple files with different storage classes types etc Check how this variable is declared confllict declare of tunction name The function shown here is declared in multiple files with different storage classes types etc Check how this function is declared Appendix G 15 MEMO R8C Tiny M16C 60 30 Tiny 20 10 Series C Compiler Package V 5 30 C Compiler User s Manual Publication Date Feb 01 2005 Rev 2 00 l Sales Strategic Planning Div Published pys Renesas Technology Corp Edited by Microcomputer Tool Development Department Renesas Solutions Corp 2005 Renesas Technology Corp and Renesas Solutions Corp All rights reserved Printed in Japan R8C Tiny M16C 60 30 Tiny 20 10 Series C Compiler Package V 5 30 C Compiler User s Manual 21 NE SAS Renesas Electronics Corporation 1753 Shimonumabe Nakahara ku Kawasaki shi Kanagawa 211 8668 Japan REJ10J0424 0200Z
149. To our customers Old Company Name in Catalogs and Other Documents On April 1 2010 NEC Electronics Corporation merged with Renesas Technology Corporation and Renesas Electronics Corporation took over all the business of both companies Therefore although the old company name remains in this document it is a valid Renesas Electronics document We appreciate your understanding Renesas Electronics website http www renesas com April 131 2010 Renesas Electronics Corporation Issued by Renesas Electronics Corporation http www renesas com Send any inquiries to http www renesas com inquiry 2 NE S AS 10 11 12 Notice All information included in this document is current as of the date this document is issued Such information however is subject to change without any prior notice Before purchasing or using any Renesas Electronics products listed herein please confirm the latest product information with a Renesas Electronics sales office Also please pay regular and careful attention to additional and different information to be disclosed by Renesas Electronics such as that disclosed through our website Renesas Electronics does not assume any liability for infringement of patents copyrights or other intellectual property rights of third parties by or arising from the use of Renesas Electronics products or technical information described in this document No license express implied or otherwise is
150. WDT word dummy in DBC s _ word dummy in NMI word dummy in org OffffcH RESET word start omitted Figure 2 34 Listing of sect30 inc in Single Chip Mode 3 4 NC30 MANUAL 52 Chapter 2 Basic Method for Using the Compiler C Compiler for R8C Tiny M16C 60 30 20 10 COPYRI GHT C XXXX XXXX XXXX RENESAS TECHNOLOGY CORPORATION AND RENESAS SOLUTIONS CORPORATION ALL RIGHTS RESERVED Figure 2 35 Listing of sect30 inc in Single Chip Mode 4 4 NC30 MANUAL 53 Chapter 2 Basic Method for Using the Compiler e Setting Interrupt Vector Table For programs that use interrupt processing set up the interrupt vector table by one of the following two methods 1 Use the compiler option fmake_vector_table fMVT to automatically set up the vari able vector table in an interrupt vector table table 2 Set up the interrupt vector table for the vector section in sect30 inc The content of the interrupt vector varies with each type of microcomputer and must therefore be set up to suit the type of microcomputer used For details refer to the user s manual included with your microcomputer 1 When us
151. a in this compiler may generate the assembler code which carries out operation which is not assumed since the interrupt re quest bit is not normal NC30 MANUAL 3 Example Chapter 1 Introduction to NC30 C language description to SFR area pragma ADDRESS 0055h M16C 60 MCU s Timer AO interrupt control register struct char ILVL 3 char IR 1 An interrupt request bit char dmy 4 TAOIC void wait until IR is ON void while TAOIC IR 0 Waits for TAOIC IR to become 1 TAOIC IR 0 Returns 0 to TAOIC IR when it becomes 1 NC30 MANUAL 4 Chapter 1 Introduction to NC30 1 4 Example Program Development Figure 1 2 shows the flow for the example program development using NC30 The program is described below Items 1 to 4 correspond to the same numbers in Figure 1 2 1 The C source program AA c is compiled using nc30 then assembled using as30 to create the relocatable object file AA r30 2 The startup program ncrt0 a30 and the include file sect30 inc which contains informa tion on the sections are matched to the system by altering the section mapping section size and interrupt vector table settings 3 The modified startup program is assembled to create the relocatable object file ncrt0 a30 4 The two relocatable object files AA r30 and ncrt0 a30 are linked by the linkage editor In30 which is run from nc30 to create the absolute mo
152. able 2 14 shows Attributes Table 2 13 Section Base Names Section base name Content data Stores data with initial values bss Stores data without initial values rom Stores character strings and data specified in pragma ROM or with the const modifier Table 2 14 Section Naming Rules Attribute Meaning Target section base name Section containing initial values of data data N F S N near attribute data bss rom F far attribute S SBDATA attribute data bss E O E Even data size data bss rom O Odd data size 1 near and far are NC30 modifiers used to clarify the addressing mode near accessible from 000000H to faTi accessible from 000000H to NC30 MANUAL 44 Chapter 2 Basic Method for Using the Compiler Table 2 15 shows the contents of sections other than those based on the naming rules described above Table 2 15 Section Names Section name Contents stack This area is used as a Stack Allocate this area at addresses between 0400H to OFFFFH heap This memory area is dynamically allocated during program execution by memory management functions e g malloc This section can be allo cated at any desired location of the Micro Processor RAM area vector This section stores the contents of the Micro Processor s interrupt vec tor table The interrupt vector table can be allocated at any desired location of the Micro P
153. ables are being referenced Check the statement description This warning can occur in the last line of the function In such a case check the description of the auto variables etc in the function If the description is correct ignore this warning non prototyped function used A function is called that is not declared of the prototype This message is output only when you specified the Wnon_prototype option Write prototype declaration Or delete the option Wnon prototype non prototyped function declared A prototype declaration for the defined function cannot be found Displayed only when the WNP option is specified Write a prototype declaration octal constant is out of range 9 The octal constant contains some character that cannot be used in octal notation Use numerals 0 to 7 to describe octal constants octal character is out of range 9 The octal constant contains some character that cannot be used in octal notation Use numerals 0 to 7 to describe octal constants overflow in floating value convert ing to integer 6 very large floating point number that cannot be stored in integer type is being assigned to the integer type Reexamine the assignment expression old style function declaration The function definition is written in format prior to ANSI ISO C Write the function definition in ANSI ISO format prototype function is defined as n
154. acter string wctomb Converts a wide character into a multibyte character O k Localization Functions The following lists localization functions Table E 12 Localization Functions Function Contents Reentrant localeconv Initializes struct Iconv O setlocale Sets and searches the locale information of a program O Appendix E 16 Appendix E Standard Library E 2 3 Standard Function Reference The following describes the detailed specifications of the standard functions provided in NC30 The functions are listed in alphabetical order Note that the standard header file extension h shown under Format must be in cluded when that function is used abort Execution Control Functions Function Terminates the execution of the program abnormally Format include lt stdlib h gt void abort void Method function Variable No argument used ReturnValue No value is returned Description Terminates the execution of the program abnormally Note Actually the program loops in the abort function abs Integer Arithmetic Functions Function Calculates the absolute value of an integer Format include lt stdlib h gt int abs n Methog function Variable Todi Integer ReturnValue e Returns the absolute value of integer n distance from 0 Appendix E 17 Appendix E Standard Library acos Mathematical Functions Function Calculates arc cosine Format include math h double
155. age area Wstdout None Output the warning and error messages to the honst machines standard output device sp lt number gt None Sp lt number gt lt numbers two or more numbers Sp lt number gt lt number gt Does not use the specified number s as SPE CIAL Page Function numbers Use this option simultaneously with the sb30 option fsection None The variables and functions specified by pragma SECTION are also included among those to be processed Appendix G 4 Appendix G The SBDATA declaration SPECIAL Page Function declaration Utility utl30 Sb30 Po Outputs SBDATA declaration Function Outputs SBDATA declaration This option can be specified simultaneously with sp30 Execution uti30 sb30 ncrt0 x30 o sample example M16C 60 UTILITY UTL30 for M16C 80 V X XX XX COPYRIGHT C XXXX XXXX RENESAS TECHNOLOGY CORPORATION ALL RIGHTS RESERVED AND RENESAS SOLUTIONS CORPORATION ALL RIGHTS RESERVED Sp30 Outputs SPECIAL page function declaration Function Outputs SPECIAL page function declaration This option can be specified simultaneously with sb30 Execution utl 30 sp30 ncrt0 x30 o sample example M16C 60 UTILITY UTL30 for M16C 80 V X XX XX COPYRIGHT C XXXX XXXX RENESAS TECHNOLOGY CORPORATION ALL RIGHTS RESERVED AND RENESAS SOLUTIONS CORPORATI ON ALL RIGHTS RESERVED Appendix G 5 Appendix G The SBDATA dec
156. age source files Appendix A 58 Appendix B Appendix B Extended Functions Reference Extended Functions Reference To facilitate its use in systems using the M16C 60 series NC30 has a number of addi tional extended functions This appendix B describes how to use these extended functions excluding those related to language specifications which are only described in outline Table B 1 Extended feature Extended Functions 1 2 Description near far qualifi ers 1 Specifies the addressing mode to access data near Access to an area within 64K bytes OH to OFFFFH far Access to an area beyond 64K bytes all memory areas All functions take on far attributes asm function Assembly language can be directly included in C programs It can also be included outside functions Example asm MOV W 0 RO You can specify variable names within functions only Example 1 asm W RO FB f Example 2 asm MOV W R0 5 Example 3 asm MOV W R0 f You can include dummy asm functions as a means of partially suppressing optimization within functions only Japanese characters Example asm Permits you to use Japanese characters in character strings Example 5 Permits you to use Japanese characters for character constants L i a Example Permits you to write Japanese characters in comments Ex
157. aised to the power of y printf Function Outputs characters with format to stdout Format include lt stdio h gt int printf format argument Method function Argument const char far format Pointer of the format specifying character string The part after the percent 96 sign in the character string given in format has the following meaning The part between and is optional Details of the format are shown below Format flag minimum field width precision modifier 1 L or h conversion specification character Example format 96 05 8ld ReturnValue Returns the number of characters output Returns EOF if a hardware error occurs Description Converts argument to a character string as specified in format and outputs the character string to stdout When giving a pointer to argument it is necessary to be a far type pointer Appendix E 53 Appendix E Standard Library Specifying format in printf format 1 Conversion specification symbol ed Converts the integer in the parameter to a signed decimal u Converts the integer in the parameter to an unsigned decimal eo Converts the integer in the parameter to an unsigned octal e x Converts the integer in the parameter to an unsigned hexadecimal Lowercase abcdef are equivalent to OAH to OFH ex Converts the integer in the parameter to an unsigned hexadecimal Uppercase ABCDEF are equivalent to OAH to OFH ec
158. alter the startup program be careful not to alter irrelevant parts of the program If you are using the M16C alter the program on the if side If you are using the R8C Tiny alter the program on the e se side Sample of Startup Program The NC30 startup program consists of the following two files 1 ncrt0 a30 Write a program which is executed immediately after reset T 2 sect30 inc Included from ncrt0 a30 this file defines section locations memory mapping Figures 2 6 to 2 11 show the ncrt0 a30 source program list Figures 2 12 to 2 22 show the sect30 inc source program list UE E E EE EEE EEEE EEEE EEEE EEEE EEEE EEEE EEE EEEE EEEE EEEE EEEE EEE EEEE EEEE EEEE EEEE EEEE E g n C COMPILER for R8C Tiny M16C 60 30 20 10 COPYRIGHT C XXXX XXXX XXXX RENESAS TECHNOLOGY CORPORATION AND RENESAS SOLUTIONS CORPORATION ALL RIGHTS RESERVED ncrt0 a30 NC30 startup program This program is applicable when using the basic 1 0 library Id ncrt0 a30 v 1 24 XXXXI XXI XX XX XX XX xxxxxxxx Exp HEEP SIZE definition 1 if 1 HEAPSIZE equ OH else if HEAPSIZE 0 HEAPSIZE equ 300H else HEAPSIZE equ HEAPSIZE _ endi endi 1 defines the heap size Figure 2 6 Startup Program List 1 ncrt0 a30 1 6 NC30 MANUAL 22 Chapter
159. am Appendix E 11 Appendix E Standard Library b Character Handling Functions The following lists character handling functions Table E 3 Character Handling Functions Function Contents Reentrant isalnum Checks whether the character is an alphabet or nu meral isalpha Checks whether the character is an alphabet O iscntrl Checks whether the character is a control character O isdigit Checks whether the character is a numeral O isgraph Checks whether the character is printable except a O blank islower Checks whether the character is a lower case letter O isprint Checks whether the character is printable including a O blank ispunct Checks whether the character is a punctuation charac O ter isspace Checks whether the character is a blank tab or new O line isupper Checks whether the character is an upper case letter O isxdigit Checks whether the character is a hexadecimal char O acter tolower Converts the character from an upper case to a lower O case toupper Converts the character from a lower case to an upper O case Appendix E 12 Appendix E Standard Library c Input Output Functions The following lists Input Output functions Table E 4 Input Output Functions Type Function Contents Reentrant Initialize init Initializes M16C series s input outputs x cl
160. ample ase Shift JIS and EUC code are supported but can t use the half size character of Japanese KATA KANA Default argu ment declaration for function Default value can be defined for the argument of a function Example 1 extern int func intzl charz0 Example2 extern int func intza charz0 When writing a variable as a default value be sure to declare the variable used as a default value before declaring the function Write default values sequentially beginning immediately after the argument Inline storage class Functions can be inline developed by using the inline storage class specifier Example inline func int i Always be sure to define the body of an inline function before using the inline function Appendix B 1 Appendix B Extended Functions Reference Table B 2 Extended Functions 2 2 Extended feature Description Extension of 1 You can include C like comments Comments Example This is a comment pragma Extended You can use extended functions for which the hardware of M16C functions 60 series in C language macro assebler You can describe some assembler command as the function of C function language Exampe char dadd b char val char val2 Example int dadd w int valt int val2 B 1 Near and far Modifiers For the M16C 60 20 series microcomputers the addressing modes used for referencing and locating data vary around
161. anguage Specifications Table C 12 Types of Expressions and Their Elements 2 2 Type of expression Elements of expression Relational expressions expression expression lt expression expression gt expression expression lt expression expression gt expression Equivalence expression expression expression expression expression Bitwise AND expression amp expression Bitwise XOR expression expression Bitwise OR expression expression Logical AND expression amp amp expression Logical OR expression expression Conditional expression expression expression expression Assign expression monadic expression 4 expression monadic expression expression monadic expression expression monadic expression expression monadic expression 95 expression monadic expression expression monadic expression gt gt expression monadic expression amp expression monadic expression expression monadic expression expression assignment expression Comma operator expression monadic expression Appendix C 10 Appendix C Overview of C Language Specifications C 2 4 Declaration There are two types of declaration e ariable Declaration 6 unction Declaration a Variable Declaration Use the format shown in Figure C 1 to declare variables storage class specifierAtype declara
162. are equal 9 ReturnValue gt 0 The first character string s1 is greater than the other 9 Return Value O The second character string 52 is greater than the other Description Compares each byte of two character strings ending with NULL However all letters are treated as uppercase letters strerror String Handling Functions Function Converts an error number into a character string Format Hinclude lt string h gt char far strerror errcode Method function Argument int errcode error code Return Value amp Returns a pointer to a message character string for the error code Note stderr returns the pointer for a static array Appendix E 70 Appendix E Standard Library strlen String Handling Functions Function Calculates the number of characters in a character string Format Hinclude lt string h gt size_t strlen s Method function Argument const char far 35 Pointer to the character string to be operated on to calculate length ReturnValue Returns the length of the character string Description Determines the length of character string s to NULL strncat String Handling Functions Function Concatenates character strings n characters Format include lt string h gt char far strncat 51 52 n Method function Argument char _far s1 Pointer to the character string to be concatenated to const char far s2 Pointer to the character
163. as30 Depends on amount of available memory Maximum number of parameters that can be specified in nc30 command line option In30 Depends on amount of available memory Maximum nesting levels of compound statements iteration control structures and selection Depends on amount of available memory control structures Maximum nesting levels in conditional compiling Depends on amount of available memory Number of pointers modifying declared basic types arrays and function declarators Depends on amount of available memory Number of function definitions Depends on amount of available memory Number of identifiers with block scope in one block Depends on amount of available memory Maximum number of macro identifiers that can be simultaneously defined in one source file Depends on amount of available memory Maximum number of macro name replacements Depends on amount of available memory Number of logical source lines in input program Depends on amount of available memory Maximum number of levels of nesting include files 40max Maximum number of case names in one switch statement with no nesting of switch state Depends on amount of available memory ment Total number of operators and operands that can be defined in if and elif Depends on amount of available memory Size of stack frame that can be secured per function in bytes 255 max Number of variables that can be defined in pragma ADDRESS Depends on amount of available memory Maximum number of levels of
164. bat are registered trademarks of Adobe Systems Incorporated Netscape and Netscape Navigator are registered trademarks of Netscape Communications Corporation in the U S and other countries All other brand and product names are trademarks registered trademarks or service marks of their respective holders Keep safety first in your circuit designs Renesas Technology Corporation and Renesas Solutions Corporation put the maximum effort into making semiconductor products better and more reliable but there is always the possibility that trouble may occur with them Trouble with semiconductors may lead to personal injury fire or property damage Remember to give due consideration to safety when making your circuit designs with appropriate measures such as i placement of substitutive auxiliary circuits ii use of nonflammable material or iii prevention against any malfunction or mishap Notes regarding these materials These materials are intended as a reference to assist our customers in the selection of the Renesas Technology product best suited to the customer s application they do not convey any license under any intellectual property rights or any other rights belonging to Renesas Technology Corporation Renesas Solutions Corporation or a third party 9 Renesas Technology Corporation and Renesas Solutions Corporation assume no responsibility for any damage or infringement of any third party s rights originating in the use of a
165. bets handled as upper case letters Format include lt string h gt int memicmp s1 s2 n Method function Argument char far s1 Pointer to the first memory area to be compared char _far s2 Pointer to the second memory area to be compared Size tn Number of bytes to be compared Return Value Return Value 0 The two memory areas are equal Return Value gt 0 The first memory area 51 is greater than the other Return Value lt O The second memory area 52 is greater than the other Description Compares memory areas with alphabets handled as upper case letters When you specify options O OR or OS the system may selects another functions with good code efficiency by optimization Appendix E 50 Appendix E Standard Library memmove Function Format Method Argument ReturnValue Moves the area of a character string include lt string h gt void far memmove 51 s2 n function void far s1 Pointer to be moved to const void _far s2 Pointer to be moved from size tn Number of bytes to be moved Returns a pointer to the destination of movement When you specify options O OR or OS the system may selects another functions with good code efficiency by optimization memset Memory Handling Functions Function Format Method Argument ReturnValue Description Set a memory area include
166. ble D 4 Return Value related Calling Rules TypeofRetun Value Rules Boll ROL Register char int RO Register near pointer float Least significant 16 bits returned by storing in RO register Most long significant 16 bits returned by storing in R2 register far pointer double Values are stored in 16 bits beginning with the high order bits long double sequentially in order of registers R3 R2 R1 and RO as they are returned long long Values are stored in 16 bits beginning with the high order bits sequentially in order of registers R3 R1 R2 and RO as they are returned Structure Type Immediately before the function call save the far address for Union Type the area for storing the return value to the stack Before execu tion returns from the called function that function writes the return value to the area indicated by the far address saved to the stack Appendix D 6 Appendix D D 3 2 Rules on Argument Transfer C Language Specification Rules NC30 uses registers or stack to pass arguments to a function 1 Passing arguments via register When the conditions below are met the system uses the corresponding Registers Used listed in Table D 5 and D 6 to pass arguments Function is prototype declared and the type of argument is known when calling the function Variable argument is not used in prototype declaration For the type of the argument of a function the Argument an
167. carry addition to the high 16 bits of far type pointers 32 bit pointer assuming that the data is not mapped across the 64 Kbyte boundary As a result the code will be more efficient Note When far type pointers are used to indirectly access memory dynamically allo cated using the malloc function etc or ROM data mapped to the far area be sure that the data is not accessed spanning a 64 Kbyte boundary This option cannot used simultaneously with the R8C option This option cannot used simultaneously with the R8C option fauto 128 fA1 Function Limits the usable stack frame to 128 bytes Appendix A 36 Appendix A Command Option Reference fuse DIV fUD Function This option changes generated code for divide operation In the entry version this option cannot be specified supplement For divide operations where the dividend is a 4 byte value the divisor is a 2 byte value and the result is a 2 byte value or when the dividend is a 2 byte value the divisor is a 1 byte value and the result is a 1 byte value the compiler generates div w divu w and div b divu b microcomputer instructions Note If the divide operation results in an overflow when this option is specified the compiler may operate differently than stipulated in ANSI The div instruction of the M16C has such a characteristic that when the opera tion resulted in an overflow the result becomes indeterminate Therefore when the program
168. characters after conversion 29 EOF in comment 6 End of file encountered in a comment Correct the source file Appendix F 5 Appendix F Error Messages Table F 5 cpp30 Error Messages 3 4 No Error message Description and countermeasure 31 EOF in preprocess command End of file encountered in a preprocess command Correct the source file 32 unknown preprocess An unknown preprocess command has been command specified Only the following preprocess commands can be used in CPP30 include define undef if ifdef ifndef else endif elseif line assert pragma error 33 line in string A new line code was included in a character constant or character string constant Oorrect the program 34 string literal out of range S A character string exceeded 509 characters 509 characters Reduce the character string to 509 characters max 35 macro replace nesting over amp Macro nesting exceeded the limit 20 Reduce the nesting level to a maximum of 20 41 include file error 6 Error in include instruction OCorrect 43 illegal id name Error in following macro name or argument in define command FILE LINE DATE _ TIME Correct the source file 44 token buffer over flow Token character buffer of define overflowed Reduce the number of token characters 45 illegal undef command usage Error in undef Correct
169. cified with no sign they are processed as unsigned Can not specifies bit fields of long long type Appendix D 1 Appendix D C Language Specification Rules D 1 2 Floating Type Table D 2 shows the number of bytes used by floating type data Table D 2 Data Size of Floating Type Type Existence of sign Bit Size Range of values float Yes 32 1 17549435e 38F 53 40282347e 38F double Yes 64 2 225073858507201 4e 308 long double 1 7976931348623157e 308 NC30 s floating point format conforms to the format of IEEE Institute of Electrical and Electronics Engineers standards The following shows the single precision and double precision floating point formats 1 Single precision floating point data format Figure D 1 shows the format for binary floating point float data Fixed point location s fixed point part sign 1bit e characteristic part 8bits m fixed point part 23bits Figure D 1 Single precision floating point data format 2 Double precision floating point data format Figure D 2 shows the format for binary floating point double and long double data Fixed point location s fixed point part sign 1 bit e characteristic part 1 1bits m fixed point part 52bits Figure 2 Double precision floating point data format Appendix D 2 Appendix D C Language Specification Rules D 1 3 Enumerator Type Enumerator types have the same internal representation as unsigned int types Unless other
170. const OC Optimizes code generation by replacing reference to vari ables to declared by the const qualifier wih constatnts Ono_bit ONB Suppresses optimization based on grouping of bit ma nipulations Ono break source debug ONBSD _ Suppresses optimization that affects source line data Ono float const fold ONFCF Suppresses the constant folding processing of floating point numbers Ono stdlib ONS Inhibits inline padding of standard library functions and modification of library functions Osp adjust OSA Optimizes removal of stack correction code This allows the necessary ROM capacity to be reduced However this may result in an increased amount of stack being used Ostack_frame_align OSFA Aligns the stack frame on an every boundary Oloop unroll 2 oop count OLU Unrolls code as many times as the loop count without revolving the loop statement The loop count can be omitted When omitted this option is applied to a loop count of up to 5 Ono logical or combine ONLOC _ Suppresses the optimization that puts consecutive ORs together Ono asmpot ONA Inhibits starting the assembler optimizer aopt30 Ostatic to inline OSTI A static function is treated as an inline function Oforward function to inline OFFTI Expands all inline functions in line Oglb jmp OGJ Global jump is optimized NC30 MANUAL 17 Chapter 2 Basic Method for Using the Compiler f Generated Code Modification Options Table 2
171. cters made up of 3 byte code Shift JIS SJIS B 3 2 Settings Required for Using Japanese Characters The following environment variables must be set in order to use kanji codes default specifies UNIX version EUC NCKIN NCKOUT MS Windows version SJIS NCKIN NCKOUT 6 Environment variable specifying input code system NCKIN 6 Environment variable specifying output code system NCKOUT Figure B 39 is an example of setting the environment variables UNIX This example sets the input to EUC codes and the output to Shift JIS codes 96 setenv NCKIN EUC 96 setenv NCKOUT SJIS MS Windows Include the following in your autoexec bat file set NCKIN SJIS set NCKOUT SuJIS Figure B 39 Example Setting of Environment Variables NCKIN and NCKOUT In NC30 the input kanji codes are processed by the cpp30 preprocessor cpp30 changes the codes to EUC codes In the last stage of token analysis in the ccom30 compiler the EUC codes are then converted for output as specified in the environment variable Appendix B 22 Appendix B Extended Functions Reference B 3 3 Japanese Characters in Character Strings Figure B 40 shows the format for including Japanese characters in character strings L REM FSI Figure B 40 Format of Kanji code Description in Character Strings If you write Japanese using the format FX F3 as with normal character strings it is processed as a pointer type to a cha
172. ction Defines error number Appendix E 2 Appendix E Standard Library float h eer eee Function Defines the limits of internal representation of floating point values The following lists the macros that define the limits of floating point values In NC30 long double types are processed as double types Therefore the limits apply ing to double types also apply to long double types Macro name Contents Defined value DBL_DIG Maximum number of digits of double type decimal preci 15 sion DBL_EPSILON Minimum positive value where 1 0 DBL_EPSILON is 2 2204460492503131e 16 found not tobe 1 0 DBL_MANT_DIG Maximum number of digits in the mantissa part when a double type floating point value is matched to the radix in its representation 53 DBL_MAX Maximum value that a double type variable can take on as 1 7976931348623157e 308 value DBL MAX 10 EXP Maximum value of the power of 10 that can be represented 308 as a double type floating point numeric value DBL MAX EXP Maximum value of the power of the radix that can be repre 1024 sented as a double type floating point numeric value DBL MIN Minimum value that a double type variable can take on as 2 225073858507201 4e 308 value DBL MIN 10 EXP Minimum value of the power of 10 that can be represented 307 as a double type floating point numeric value DBL MIN EXP Minimum value of the power of the radix that can be rep
173. ction WNUF Displays unused global functions when linking Wundefined macro WUM Warns you that undefined macros are used in if Wstop link WSAL Stops linking the source files if a warning occurs during linking to suppress generation of absolute module files Also a return value 10 is returned to the host OS Appendix A 45 Appendix A Command Option Reference Wnon prototype WNP Function Outputs warning messages for functions without prototype declarations or if the prototype declaration is not performed for any function supplement Function arguments can be passed via a register by writing a prototype decla ration Increased speed and reduced code size can be expected by passing argu ments via a register Also the prototype declaration causes the compiler to check function arguments Increased program reliability can be expected from this Therefore Renesas recommends using this option whenever possible Wunknown pragma WUP Function Outputs warning messages for non supported pragma supplement By default no alarm is generated even when an unsupported unknown pragma is used When you are using only the NC series compilers use of this option helps to find misspellings in pragma When you are using only the NC series compilers Renesas recommends that this option be always used when compiling Appendix A 46 Appendix A Command Option Reference Wno stop WNS Function Preven
174. ctronics products or if you have any other inquiries Note 1 Renesas Electronics as used in this document means Renesas Electronics Corporation and also includes its majority owned subsidiaries Note 2 Renesas Electronics product s means any product developed or manufactured by or for Renesas Electronics 424 NE SAS C 7 D me on lt D C R8C Tiny M16C 60 30 Tiny 20 10 Series C Compiler Package V 5 30 C Compiler User s Manual R Electroni enesas Electronics Rev 2 00 2005 02 www renesas com Microsoft MS DOS Windows and Windows NT are either registered trademarks or trademarks of Microsoft Corporation in the United States and other countries HP UX is a registered trademark of Hewlett Packard Company Sun Java and all Java based trademarks and logos are trademarks or registered trademarks of Sun Microsystems Inc in the U S or other countries and are used under license UNIX is a registered trademark of The Open Group in the United States and other countries Linux is a trademark of Linus Torvalds Turbolinux and its logo are trademarks of Turbolinux Inc IBM and AT are registered trademarks of International Business Machines Corporation HP9000 is a product name of Hewlett Packard Company SPARC and SPARCstation are registered trademarks of SPARC International Inc Intel and Pentium are registered trademarks of Intel Corporation Adobe and Acro
175. d ReturnValue Copies the number of bytes specified in size from the beginning of the area speci fied in src to the area specified in dtop Description Appendix E 21 Appendix E Standard Library bsearch Integer Arithmetic Functions Function Performs binary search in an array Format include lt stdlib h gt void _far bsearch key base nelem size cmp Method function Variable const void far s Search key const void far s Start address of array size t nelem Element number size_t size Element size int Compare function ReturnValue Returns a pointer to an array element that equals the search key Returns a NULL pointer if no elements matched Note The specified item is searched from the array after it has been sorted in ascend ing order bzero Memory Handling Functions Function Initializes a memory area by clearing it to zero Format include lt string h gt void bzero top size Method function Argument char far Start address of the memory area to be cleared to zero unsigned long size Number of bytes to be cleared to zero ReturnValue No value is returned Description Initializes to 0 the number of bytes specified in size from the starting address of the area specified in top Appendix E 22 Appendix E Standard Library calloc Memory Management Function
176. d Type of Argument in Table D 5 and D 6 are matched Table D 5 Rules on Argument Transfer via Register NC30 Argument First Argument Registers Used First argument char type _Bool type R1iL register int type R1 register near pointer type Second argument int type R2 register near pointer type Table D 6 Rules on Argument Transfer via Register NC308 Argument First Argument Registers Used First argument char type _Bool type R1L register int type near pointer type R1 register 2 Passing arguments via stack All arguments that do not satisfy the register transfer requirements are passed via stack The table D 7 and D 8 summarize the methods used to pass arguments Table D 7 Rules on Passing Arguments to Function NC30 Type of Argument First Argument Second Argument Third and Following Arguments char type RiL register Stack Stack _ Bool type int type R1 register R2 register Stack near pointer type Other types Stack Stack Stack Table D 8 Rules on Passing Arguments to Function NC308 Type of Argument First Argument Second Argument Third and Following Arguments char type ROL register Stack Stack _ Bool type int type RO register Stack Stack near pointer type Other types Stack Stack Stack 1 NC30 uses a via register transfer only when entering prototype declaration i e when writing a new format Consequently all
177. d by specification fchar_enumerator Handles the enumerator type as an unsigned char type not as an int type fno_even INE Allocate all data to the odd section with no separat ing odd data from even data when outputting ffar RAM fFRAM Changes the default attribute of RAM data to far fnear_ROM fNROM Changes the default attribute of ROM data to near In the entry version this option cannot be specified fconst_not_ROM fCNR Does not handle the types specified by const as ROM data fnot address volatile INAV Does not regard the variables specified by pragma ADDRESS pragma EQU as those specified by volatile 1 char type data or signed char type data evaluated under ANSI rules is always extended to int type data This is because operations on char types c1 c2 2 c3 for example would other wise result in an overflow and failure to obtain the intended result NC30 MANUAL 18 Chapter 2 Basic Method for Using the Compiler Table 2 6 2 2 Generated Code Modification Options Option Short form Description fsmall_array fSA When referencing a far type array whose total size is unknown when compiling this option calculates subscripts in 16 bits assuming that the array s total size is within 64 Kbytes In the entry version this option cannot be specified fenable register fER Make register
178. d iet ad a cube dide Dn 62 3 2 1 Programming Techniques for Greater Code Efficiency ssssees 62 a Regarding Integers and Variables iio erii rre mies ere roto Hop rp E E br 62 5 Tar ype aA ay ere 62 e SUS CHI OIS utc eara e 63 d Using Prototype declaration Efficlenily ooo recti 63 e Using SB Register 5 63 f Compressing ROM Size Using Option 45 64 q Other melliQds uui serene geet rtetrerrere eter terererreeey Age AUREAS AMO SALA ECL mast t ELA crete tere st 64 3 2 2 Speeding Up Startup Processing eessssseseeeeenene nennen nnns 65 Linking Assembly Language Programs with C 8 5 66 3 3 1 Calling Assembler Functions from C Programs 66 a Calling Assembler FUNCTIONS co acus Loose eh actio Eve dep 66 b When assigning arguments to assembler functions eessssssssssss 67 Limits on Parameters in pragma PARAMETER Declaration ssssse 68 3 3 2 Writing Assembler 68 a Method for writing the called assembler functions sess 68
179. data NO 0p Section data FEI ROMDATA data FE 0p Section data FOI ROMDATA data FO 0p Section switch table top switch table ROMDATA Code area section program section interrupt 0rg mist be set internal ROM area Section program 5 if __MVT__ 0 You can remove this part because it is unnecessary In this case you need to remove the initialize program in the far area of ncrtO a30 Figure 2 33 Listing of sect30 inc in Single Chip Mode 2 4 NC30 MANUAL 51 Chapter 2 Basic Method for Using the Compiler variable vector section Section vector ROMDATA variable vector table org VECTOR ADR if 1 word dummy int vector 0 BRK omitted wor d dummy int vector 63 else MT section NC rvector ROMDATA Lorg VECTOR_ADR fixed vector section section svector ROMDATA Specialpage vector table org SVECTOR_ADR special page defination macro is defined in ncrt0 a30 A Format SPECIAL number SPECIAL 255 omitted SPECIAL 18 else section NC_svector ROMDATA ECTOR_ADR e e wi lt I endif __ MST fixed vector section section fvector ROMDATA org OfffdcH UD dummy in OVER FLOW word dummy in BRKI word dummy in ADDRESS MATCH word dummy in SI NGLE_STEP word dummy in
180. ddress 6 pragma EQUAvariable name absolute address 7 pragma BITADDRESSAvariable nameAbit position absolute address 8 pragma INTCALLAint No Aassembler function name register name register name 8 pragma INTCALLAint No AC language function name 9 pragma INTERRUPTA B E Ainterrupt handling function name 9 pragma INTFAinterrupt handling function name 10 pragma PARAMETERAassembler function name register name register name 11 pragma SPECIALAspecial No Afunction name 12 pragma ALMHANDLERAalarm handler function name 19 pragma CYCHANDLERAcyclic handler function name 14 pragma INTHANDLERAinterrupt handler function name 14 pragma HANDLERAinterrupt handler function name 15 pragma TASKAtask start function name 16 pragma ASM 16 pragma ENDASM 17 pragma JSRAAfunction name 18 pragma JARWAfunction name 19 pragma PAGE Description 1 5 WD 12 18 14 15 16 17 18 19 Facility to arrange in the rom section Facility to describe variables using SB relative addressing Facility to alter the section base name Facility to control the array of structures Facility to declare pointer for access 4M byte ROM area Facility to specify absolute addresses for input output variables Facility to declare functions using software interrupts Facility to specify absolute with bit position addresses for input output variables Facility to write interrupt functions Facility to declare assembler
181. dence in which uppercase and lowercase are considered to be equivalent Appendix B 33 Appendix B Extended Functions Reference b Using Extended Functions for Target Devices Table B 4 Extended Functions for Use with Target Devices 1 Extended function Description pragma ADDRESS pragma EQU Specifies the absolute address of a variable For near variables this specifies the address within the bank Syntax pragma ADDRESS Avariable nameAabsolute address Example pragma ADDRESS port0 2H k pragma EQU can also be used for maintaining compatibility with C77 pragma BITADDRESS A variable is assigned to the bit position which the specified abso lute address specified Syntax pragma Bl TADDRESS Avariable nameAbit position absolute address Example pragma BI TADDRESS io 1 100H pragma INTCALL Declares a function written in assembler called in a software inter rupt int instruction Syntax pragma INTCALL AINT No Afunction name register name Example pragma NTCALL 25 func RO RI Syntax pragma NTCALL INT No function namel Example pragma I NTCALL 25 func Always be sure to declare the prototype of the function before entering this declaration pragma INTERRUPT pragma INTF Declares an interrupt handling function written in C language This declaration causes code to perform a procedure for the interrupt handling function to be generated at the entry or exit to and from th
182. directory An example section location in the section definition file is shown below EOD0H 400H EM FEDCH rvastar FFFFH Figure 3 17 Example section locationfor R8C Tiny 3 4 6 About the Standard Function Library When the R8C option is specified always be sure that the standard function library you should link is the r8clib lib file If you inadvertently link the nc3Olib lib file a link error will be assumed or the program may not operate normally NC30 MANUAL 74 Chapter 3 Programming Technique 3 5 Other 3 5 1 Precautions on Transporting between NC Series Compilers NC30 basically is compatible with Mitsubishi C compilers NCxxx at the language speci fication level including extended functions However there are some differences between the compiler this manual and other NC series compilers as described below a Difference in default near far The default near far in the NC series are shown in Table 3 3 Therefore when transport ing the compiler this manual to other NC series compilers the near far specification needs to be adjusted Table 3 3 Default near far in the NC Series Compiler RAM data ROM data Program NC308 near far far Fixed However pointer type is far NC30 near far far Fixed NC79 near near far NC77 near near far NC30 MANUAL 75 Appendix A Command Option Reference Appendix A Command Option Reference This appendix describes how to
183. dix E Standard Library Isprint Character Handling Functions Function Checks whether the character is printable including a blank 0x20 0x7e Format include ctype h int isprint c Method macro Argument int c Character to be checked ReturnValue amp Returns any value other than 0 if printable Returns 0 if not printable Description Determines the type of character in the parameter ispunct Character Handling Functions Function Checks whether the character is a punctuation character Format include ctype h int ispunct c Method macro Argument Character to be checked ReturnValue Returns any value other than 0 if a punctuation character Returns 0 if not a punctuation character Description Determines the type of character in the parameter Appendix E 40 Appendix E Standard Library isspace Character Handling Functions Function Checks whether the character is a blank tab or new line Format include lt ctype h gt int isspace c Method macro Argument Character to be checked Return Value Returns any value other than 0 if a blank tab or new line Returns 0 if not a blank tab or new line Description Determines the type of character in the parameter isupper Character Handling Functions Function Checks whether the character is an upper case letter
184. dule file AA x30 Figure 1 2 Program Development Flow NC30 MANUAL 5 Chapter 1 Introduction to NC30 Figure 1 3 is an example make file containing the series of operations shown in Figure 1 2 AA x30 ncrt0 a30 AA r30 nc30 oAA ncrt0 r30 AA r30 ncrt0 r30 ncrt0 a30 as30 ncrt0 a30 AA r30 AA C nc30 c AA C Figure 1 3 Example make File Figure 1 4 shows the command line required for nc30 to perform the same operations as in the makefile shown in Figure 1 3 9 nc30 oAA ncrt0 a30 AA C RET 96 Indicates the prompt RET Indicates the Return key Specify ncrt0 a30 first when linking Figure 1 4 Example nc30 Command Line NC30 MANUAL 6 Chapter 1 Introduction to NC30 1 5 NC30 Output Files This chapter introduces the preprocess result C source program output when the sample program smp c is compiled using NC30 and the assembly language source program 1 5 1 Introduction to Output Files With the specified command line options the nc30 compile driver outputs the files shown in Figure 1 5 Below we show the contents of the files output when the C source file smp c shown in Figure 1 6 is compiled assembled and linked See the AS30 User Manual for the relocatable object files extension r30 print files extension Ist and map files extension map output by as30 and In30 C language Source file Preprosesser cpp30 nc30 command option p C source file fr
185. e B 6 Extension of Comments NC30 allows comments enclosed between and as well as C like comments starting with B 6 1 Overview of Comments In C comments must be written between and In C anything following B 6 2 Comment Format When you include on a line anything after the is treated as a comment Figure B 60 shows comment format comments Figure B 60 Comment Format Figure B 61 shows example comments void func void int i This is commentes intj This is commentes Figure B 61 Example Comments B 6 3 Priority of and The priority of and is such that the one that appears first has priority Therefore a written between a to the new line code does not have an effect as signifying the beginning of a comment Also a written between and does not have an effect as signifying the beginning of a comment Appendix B 32 Appendix B Extended Functions Reference 7 pragma Extended Functions B 7 1 Index of pragma Extended Functions Following index tables show contents and formation for pragma extended functions a Using Memory Mapping Extended Functions Table B 3 Memory Mapping Extended Functions Extented function Description pragma BIT Declares that the external variable resides in an area where a 1 bit manipulate instruction can be used in 16 bit absolute ad dressing mode i
186. e a variable residing in addresses from 00000H to 01FFFH Syntax pragma BIT variable name Example pragma BIT bit data pragma ROM Maps the specified variable to rom Syntax pragma ROM variable_name Example pragma ROM This facility is provided to maintain compatibility with NC77 and NC79 The variable normally must be located in the rom section using the const qualifier pragma SBDATA Declares that the data uses SB relative addressing Syntax pragma SBDATA variable name Example pragma SBDATA val pragma SECTION Changes the section name generated by NC30 Syntax pragma SECTION section name new section name Example pragma SECTION bss nonval data pragma STRUCT 1 Inhibits the packing of structures with the specified tag Syntax pragma STRUCT structure tag unpack Example pragma STRUCT TAG1 unpack 2 Arranges members of structures with the specified tag and maps even sized members first Syntax pragma STRUCT structure tag arrange Example pragma STRUCT TAG1 arrange pragma EXTAMPTR A functional extension which shows a variable is a pointer ac cessing 4 Mbyte expanded space ROM Syntax pragma EXT4MPTR variable name Example pragma EXT4MPTR sym 1 In the previous versions words following pragma For example ADDRESS INTERRUPT ASM etc specifying a directive function abbreviate as subcommand needed to be described in uppercase Inthis version subcommand are case indepen
187. e function Furthermore by specifying switch B it is possible to switch the register to a back register instead of saving it to a stack when calling the function Syntax pragma NTERRUPT Al E Ainterrupt handling function name pragma NTERRUPT Al B E Ainterrupt vector numberAinterrupt handling function name pragma NTERRUPT Al E Ainterrupt handling function name vec t interrupt vector number Example pragma INTERRUPT int func Example pragma NTERRUPT B int func Example pragma INTERRUPT 10 int func Example pragma INTERRUPT E 10 int func Example pragma INTERRUPT int func vect 10 Example pragma INTERRUPT E int func vect z20 3 pragma INTF can also be used for maintaining compatibility with C77 pragma PARAMETER Declares that when calling an assembler function the parameters are passed via specified registers Syntax pragma PARAMETER Afunction name register name Example pragma PARAMETER asm func RO R1 Always be sure to declare the prototype of the function before entering this declaration Appendix B 34 Appendix B Extended Functions Reference Table B 4 Extended Functions for Use with Target Devices 2 Extended function Extended function pragma SPECIAL Declares special page subroutine call functions Syntax pragma SPECI AL AnumberAfunction name pragma SPECI AL Afunction name v ect number Example pragma SPE
188. e array subscripts as char types they will be extended to int types each time they are referenced and therefore the code will not be efficient In such cases declare variables that will be array subscripts as int types d Using Prototype declaration Efficiently NC30 allows you to accomplish an efficient function call by declaring the prototype of a function This means that unless a function is declared of its prototype in NC30 arguments of that function are placed on the stack following the rules listed in Table 3 1 when calling the function Table 3 1 Rules for Using Stack for Parameters Data type s Rules for pushing onto stack char Expanded into the int type when stacked signed char float Expanded into the double type when stacked otherwise Not expanded when stacked For this reason NC30 may require redundant type expansion unless you declare the prototype of a function Prototype declaration of functions helps to suppress such redundant type expansion and also makes it possible to assign arguments to registers All this allows you to accomplish an efficient function call e Using SB Register Efficiently Using the SB register based addressing mode you can reduce the size of your applica tion program ROM size NC30 allows you to declare variables that use the SB register based addressing mode by writing the description shown in Figure 3 8 This Compiler assumes as a precondition that the SB regi
189. e following e Labelled Statement Compound Statement Expression Null Statement 6 Selection Statement lteration Statement Jump Statement Assembly Language Statement a Labelled Statement Use the format of labelled statement shown in Figure C 7 Identifier statement case constant statement default statement Figure C 7 Format of Labelled Statement Appendix C 13 Appendix C Overview of C Language Specifications b Compound Statement Use the format of compound statement shown in Figure C 8 list of declarations list of statements opt indicates optional items Figure C 8 Format of Compound Statement c Expression Null Statement Use the format of expression and null statement shown in Figure C 9 expression expression null statement Figure C 9 Format of Expression and Null Statement d Selection Statement Use the format of selection statement shown in Figure C 10 if expression statement if expression statement else statement switch expression statement Figure C 10 Format of Selection Statement e Iteration Statement Use the format of iteration statement shown in Figure C 11 while expression statement do statement while expression for expression expression expression statement opt opt opt opt indicates optional items Figure C 11 Format of Iteration Statement Appendix C 14 Appendix C Overview of C Language S
190. e inline storage class specifier declares that the specified function is a function to be expanded inline The inline storage class specifier indicates to a function that the function declared with it is to be expanded in line The functions specified as inline storage class have codes embedded directly in them at the assembly level B 5 2 Declaration Format of inline Storage Class The inline storage class specifier must be written in a syntactically similar format to that of the static and extern type storage class specifiers when declaring the inline storage class Figure B 52 shows the format used to declare the inline storage class inlineAtype specifierAfunction Figure B 52 Declaration Format of inline Storage Class Figure B 53 shows an example of declaration of a function int S inline int func int i lt Prototype declaration of function return i void main Definition of body of function s func s Figure B 53 Example for Declaring inline Storage Class Appendix B 28 Appendix B Extended Functions Reference LANG 34 M16C 60 C Compiler OUTPUT ccom30 Version X XX XX 44 COPYRIGHT C XXXX XXXX XXXX RENESAS TECHNOLOGY CORPORATI ON ALL RIGHTS RESERVED AND RENESAS SOLUTIONS CORPORATION ALL RIGHTS RE S3 Compile Start Time Thu April 10 18 40 11 1995 1996 1997 1998 1999 2000 2001 2002 2003 34 COMMAND LI NE ccom30 smp i o smp
191. e lt 0 The second character string 52 is greater than the other Description 6 Compares each byte of n characters of two character strings ending with NULL However all letters are treated as uppercase letters When you specify options O OR or OS the system may selects another functions with good code efficiency by optimization strpbrk Function Searches the specified character in a character string from the other character string Format include lt string h gt char far strpbrk 51 s2 Method function Argument const char far st Pointer to the character string to be searched in const char far s2 Pointer to the character string of the character to be searched for ReturnValue 6 Returns the position pointer where the specified character is found first Returns NULL if the specified character cannot be found Description Searches the specified character s2 from the other character string in s1 area 9 You cannot search for When you specify options O OR or OS the system may selects another functions with good code efficiency by optimization Appendix E 73 Appendix E Standard Library strrchr Function Searches the specified character from the end of a character string Format Hinclude lt string h gt char far strrchr s c Method function Argument const char s Pointer to the character string to be searched in MEO soos esu Character to be
192. e of an integer atof Converts a character string into a double type floating point num ber atoi Converts a character string into an int type integer atol Converts a character string into a long type integer bsearch Performs binary search in an array calloc Allocates a memory area and initializes it to zero 0 div Divides an int type integer and calculates the remainder free Frees the allocated memory area labs Calculates the absolute value of a long type integer Idiv Divides a long type integer and calculates the remainder malloc Allocates a memory area mblen Calculates the length of a multibyte character string mbstowcs Converts a multibyte character string into a wide character string mbtowc Converts a multibyte character into a wide character qsort Sorts elements in an array realloc Changes the size of an allocated memory area strtod Converts a character string into a double type integer strtol Converts a character string into a long type integer strtoul Converts a character string into an unsigned long type integer wcstombs Converts a wide character string into a multibyte character string wctomb Converts a wide character into a multibyte character Appendix E 8 Appendix E Standard Library string h ee Function Declares the prototypes of string handling functions and memory handling functions Type Function Contents Copy
193. e used However functions using the standard I O stream cannot be used for standard auxiliary used by UARTO Therefore only use functions that take streams as parameters Figure E 6 shows how to change the init func tion void init void TIT st TM flag _I ORW 2 5 read write mode Tom TEXT 2 5 text mode wm er gt func in sget0 3 set UARTO level 3 input function TE sisi gt func out _sput0 lt 3 set UARTO level 3 input function T le B8 PN 52 lt 4 set UARTO speed function speed 96 _B8 PN 52 init prn 2 to 4 correspond to the items in the description of setting above Figure E 6 Modifying the init Function Appendix E 93 Appendix E Standard Library c Incorporating the Modified Source Program There are two methods of incorporating the modified source program in the target sys tem 1 Specify the object files of the modified function source files when linking 2 Use the makefile under MS Windows makefile dos supplied in the NC30 pack age to update the library file In method 1 the functions specified when linking become valid and functions with the same names in the library file are excluded Figure E 7 shows method 1 Figure E 8 shows method 2 nc30 c g osample ncrt0 a30 device r30 init r30 sample c lt RET gt This example shows the command line when device c and init c are modified
194. ea s1 Description Concatenates character strings s1 and s2 in the sequence 5134561 9 The concatenated string ends with NULL When you specify options O OR or OS the system may selects another functions with good code efficiency by optimization strchr String Handling Functions Function Searches the specified character beginning with the top of the character string Format include lt string h gt char far strchr s c Method function Argument const char far s Pointer to the character string to be searched in IDUC auci Character to be searched for ReturnValue 6 Returns the position of character c that is first encountered in character string s Returns NULL when character string s does not contain character c Description Searches for character c starting from the beginning of area s You can also search for When you specify options O OR or OS the system may selects another functions with good code efficiency by optimization 1 There must be adequate space to accommodate s1 plus s2 Appendix E 67 Appendix E Standard Library strcmp String Handling Functions Function Compares character strings Format include lt string h gt int stremp 51 s2 Method function Argument const char _far s1 Pointer to the first character string to be compared const char far s2 Pointer to the second character string to be compared Retu
195. earerror Initializes clears error status specifiers x Input fgetc Inputs one character from the stream x getc Inputs one character from the stream x getchar Inputs one character from stdin x fgets Inputs one line from the stream x gets Inputs one line from stdin x fread Inputs the specified items of data from the stream x scanf Inputs characters with format from stdin x fscanf Inputs characters with format from the stream x sscanf Inputs data with format from a character string x Output fputc Outputs one character to the stream x putc Outputs one character to the stream x putchar Outputs one character to stdout x fputs Outputs one line to the stream x puts Outputs one line to stdout x fwrite Outputs the specified items of data to the stream x perror Outputs an error message to stdout x printf Outputs characters with format to stdout X fflush Flushes the stream of an output buffer x fprintf Outputs characters with format to the stream x sprintf Writes text with format to a character string x vfprintf Output to a stream with format x vprintf Output to stdout with format x vsprintf Output to a buffer with format x Return ungetc Sends one character back to the input stream x Determi ferror Checks input output errors x nation feof Checks EOF End of File x d Memory Management Functions The following lists memory management functions Table E 5 Memory Management Functions Function Cont
196. eclaration Only global variables are valid in using utl30 Types of variables are as follows 1variables of Bool 2 variables of unsigned char and signed char type 3 variables of unsigned short and signed short type jvariables of unsigned int and signed int type Jvariables of unsigned long and signed long type 6 variables of unsigned long long and signed long long type Variables give below are excluded from SBDATA declaration 1 variables positioned in sections worked on by pragma SECTION 2 variables defined by pragma ADDRESS 3 variables defined by pragma ROM If variables declared by use pragma SBDATA have already been present in a program the declaration is given a higher priority in using utl30 and variables to be allocated are picked out of the remainder of the SB area G 4 2 Conditions to establish SPECIAL Page Function declaration The functions to be processed by utl30 are only those external functions that are listed below 1 Functions which are not declared with static 2 Functions which are called three times or more Note however that even the above functions may not be processed if they belong to one of the following 1 functions positioned in sections worked on by pragma SECTION 2 functions defined by any pragma If variables declared by use pragma SPECIAL have already been present in a program the declaration is given a higher priority in using ult30 and variables to be allocated are picked out of the
197. eclaration of function with near pointer in parameter far pointer implicitly cast as near type n ptr near f ptr far pointer explicitly cast as near type Figure B 11 Type conversion from far to near The warning message far pointer implicitly casted by near pointer is also output when a far pointer is explicitly cast as a near pointer then assigned to a near pointer B 1 8 Declaring functions In NC30 functions are always located in the far area Therefore do not write a near declaration for functions If a function is declared to take on a near attribute NC30 outputss a warning and contin ues processing by assuming the attribute of that function is far Figure B 12 shows a dis play example where a function is declared to be near 30 Ssmp c M16C 60 NC30 COMPILER V X XX Release X COPYRI GHT C XXXX XXXX RENESAS TECHNOLOGY CORPORATION ALL RIGHTS RESERVED AND RENESAS SOLUTIONS CORPORATION ALL RIGHTS RESERVED smp c Warning ccom smp c line3 functi onmust bef ar func M Figure B 12 Example Declaration of Function Appendix B 7 Appendix B Extended Functions Reference B 1 9 Function for Specifying near and far in Multiple Declarations As shown in Figure B 13 if there are multiple declarations of the same variable the type information for the variable is interpreted as indicating a combined type extern int far idata int idata int idata 10 func
198. ectly unknown optimize option Ox The option Ox cannot be specified Specify the option correctly Appendix F 31 Appendix F Error Messages Table F 30 ccom30 Warning Messages 10 10 Warning message Description and countermeasure unknown option x The option x cannot be specified 55 Specify the option correctly unknown pragma pragma specifi cation used Unsupported pragma is written Check the content of pragma This warning is displayed only when the Wunknown pragma WUP option is specified wchar_t array initialized by char string The initialize expression of the wchar_t type is initialized by a character string of the char type gt Make sure that the types of the initialize expres sion are matched zero divide in constant folding The divisor in the divide operator or remainder calculation operator is 0 gt Use any value other than 0 for the divisor zero divide ignored The divisor in the divide operator or remainder calculation operator is 0 gt Use any value other than 0 for the divisor zero width for bitfield The bit field width is 0 Write a bit field equal to or greater than 1 Code generation for static functions xxx can be suppressed by using ferase_static_function fESF option Some static function may not be referenced Code generation for the static function function name can be suppre
199. ects another functions with good code efficiency by optimization strtoul Character String Value Convert Function Function Converts a character string into an unsigned long type integer Format Hinclude lt string h gt unsigned long strtoul s endptr base Method function Argument const char _far s Pointer to the converted character string char _far _far endptr Pointer to the remaining character strings that have not been converted int base Base of values to be read in 0 to 36 Reads the format of integral constant if the base of value is zero ReturnValue ReturnValue OL Does not constitute a number 9 ReturnValue OL Returns the configured number in long type Description When you specify options O OR or OS the system may selects another functions with good code efficiency by optimization Appendix E 77 Appendix E Standard Library strxfrm Character String Value Convert Functions Function Converts a character string using locale information Format Hinclude lt string h gt Size t strxfrm s1 s2 n Method function Argument char far s1 Pointer to an area for storing a conversion result character string const char far s2 Pointer to the character string to be converted size tn Number of bytes converted ReturnValue amp Returns the number of characters converted Description amp When you specify options O OR or OS the system
200. ed in the header of the assembler pseudo instruction PAGE 2 You cannot write a pragma PAGE in an auto variable declaration Example void func int I 5 for iz0 i lt 10 i func2 pragma PAGE itt Figure B 85 Example of pragma PAGE Appendix B 60 Appendix B Extended Functions Reference pragma ASMMACRO Function Declares defined a function by assembler macro Syntax pragma__ASMMACRO A function name register name Rules 1 Always put the prototype declaration before the pragma ASMMACRO declaration Assembler macro function be sure to declare static 2 Can t declare the function of no parameter Parameter is passed via register Please specify the register matching the parameter type 3 Please append the underscore _ to the head of the definition assembler macro name 4 The following is a return value related calling rules You can t declare structure and union type as the return value char and _Bool types ROL float types R2RO int and short types RO double types R3R2R1R0 long types long long type R3R1R2RO0 5 f you change the register s data save the register to the stack in entry processing of assembler macro function and the saved register restore in exit processing Example static long mul int int Be sure to declare static pragma __ASMMACRO mul RO R2 pragma ASM mul macro mul w R2 RO The ret
201. ed may be generated for writing and read out to the register of SFR area When accessing registers in the SFR area in C language make sure that the same correct instructions are generated as done by using asm functions regardless of the compiler s version and of whether optimizing options are used or not When you describe like the following examples as C language description to a SFR area in this compiler may generate the assembler code which carries out operation which is not assumed since the interrupt request bit is not normal Example C language description to SFR area C gt pragma ADDRESS 0055h M16C 60 MCU s Timer AO interrupt control register struct char ILVL 3 char IR 1 An interrupt request bit char dmy 4 TAOIC void wait until IR is ON void while TAOIC IR 0 Waits for TAOIC IR to become 1 TAOIC IR 0 Returns 0 to TAOIC IR when it becomes 1 NC30 MANUAL 58 Chapter 3 Programming Technique 3 1 3 About Optimization a Regular optimization The following are always optimized regardless of whether optimization options are specified or not 1 Meaningless variable access For example the variable port shown below does not use the readout results so that readout operations are deleted extern int port f unC port Figure 3 1 Example of a Meaningless Variable Access Optimized Although the intended operat
202. efault attributes of functions and variables data These are listed in the table below Table nc30 Command Line Options Command Line Options Function fnear_ROM fNROM Assumes near as the default attribute of ROM data ffar_RAM fFRAM Assumes far as the default attribute of RAM data ffar_pointer fFP Assumes far as the default attribute of pointer type variable B 1 6 Function of Type conversion from near to far The program in Figure B 10 performs a type conversion from near to far int func int far int far f ptr int near n ptr main f_ptr n_ptr assigns the near pointer to the far pointer abbreviated func n ptr prototype declaration for function with far pointer to parameter specifies near pointer parameter at the function call Figure B 10 Type conversion from near to far When converting type into far O zero is expanded as high order address B 1 7 Checking Function for Assigning far Pointer to near Pointer When compiling the warning message assign far pointer to near pointer bank value ignored is output for the code shown in Figure B 11 to show that the high part of the address the bank value has been lost Appendix B 6 Appendix B Extended Functions Reference int func int near int far f_ptr int near n_ptr main n_ptr f_ptr Assigns a far pointer to a near pointer abbreviated func f_pyr prototype d
203. eferencing Variables of Each Storage Class 1 Whether it is arranged at which storage class should actually compile and please check it 2 It does not restrict being assigned to a register even if it specifies a register qualified Appendix B 18 Appendix B B 2 6 Selectively suppressing optimization In Figure B 34 the dummy asm function is used to selectively suppress a part of optimi zation Extended Functions Reference pragma char char char char char char char char port func struct port ADDRESS port 02H C Cc c c 5 Ut 5 WY c port port bito bitl 0x01 UR 0x01 Optimization Optimization results in any steps to set the two port bits separately being combined as one step or b 4038 port port bito 0x01 asm dummy Optimization m port bitl 0x01 Optimization is suppressed bset 00H port bset 01H port Figure B 34 Example of Suppressing Optimization by Dummy asm Appendix B 19 Appendix B Extended Functions Reference B 2 7 Notes on the asm Function a Extended Features Concerning asm functions When using the asm function for the following processing be sure to use the format shown in the coding examples 1 Do not specify auto variables or parameters or 1 bit bit fields using the offset from the frame base register FB Use the for
204. elocatable object file corre sponding to the startup program file Note 1 The content of the variable interrupt table generated by this option is output to the map file that the linkage editor generates 2 f this option is used all of the variable interrupt vector tables written in the startup program file are ignored 3 If you specify this option be sure to specify the fMVT option in the assembler AS30 and the linkage editor In30 too fmake special table fMST Function Automatically generates the special page vector table Supplement The special page vector table is automatically generated based on the call num ber and function name specified in pragma SPECIAL see Appendix B 7 Format of pragma SPECIAL pragma SPECIALAcall numberAfunction name pragma SPECIALAfunction name vect call number The generated special page vector table is stored in the relocatable object file corresponding to the startup program file Note 1 The content of the special page vector table generated by this option is output to the map file that the linkage editor generates 2 If this option is used all of the special page vector tables written in the startup program file are ignored The special page vector tables written in the startup program file and the spe cial page table generated by this option cannot be used at the same time 3 If you specify this option be sure to specify the fMST option in the assembler AS30 and the
205. ement within a function Declare it outside a function incomplete array access 6 An attempt is made to reference an array of in complete Define size of array incomplete return type An attempt is made to reference an return vari able of incomplete type Check return variable incomplete struct get by An attempt is made to reference or initialize an array of incomplete structs or unions that do not have defined members Define complete structs or unions first incomplete struct member An attempt is made to reference an struct mem ber of incomplete gt Define complete structs or unions first incomplete struct initialized 6 An attempt is made to initialize an array of incom plete structs or unions that do not have defined members gt Define complete structs or unions first Appendix F 12 Appendix F Error Messages Table F 12 ccom30 Error Messages 5 14 Error message Description and countermeasure incomplete struct return function call An attempt is made to call a function that has as a return value the of incomplete struct or union that does not have defined members gt Define a complete struct or union first incomplete struct union s mem ber access An attempt is made to reference members of an incomplete struct or union that do not have de fined members gt Define a complete struct or union first incomple
206. ents Reentrant calloc Allocates a memory area and initializes it to zero 0 x free Frees the allocated memory area x malloc Allocates a memory area x realloc Changes the size of an allocated memory area x Appendix E 13 Appendix E Standard Library e Memory Handling Functions The following lists memory handling functions Table E 6 Memory Handling Functions Type Function Contents Reentrant Initialize bzero Initializes a memory area by clearing it to zero O Copy bcopy Copies characters from a memory area to another O memcpy Copies characters n bytes from a memory area O to another memset Set a memory area by filling with characters O Compare memcmp Compares memory areas n bytes O memicmp Compares memory areas with alphabets handled O as upper case letters Move memmove Moves the area of a character string O Search memchr Searches a character from a memory area O f Execution Control Functions The following lists execution control functions Table E 7 Execution Control Functions Function Contents Reentrant abort Terminates the execution of the program O longjmp Performs a global jump O setjmp Sets a stack environment for a global jump O Appendix E 14 Appendix E Standard Library g Mathematical Functions The following lists mathematical functions Table E 8 Mathematical Functions
207. ents which will cause the regis ter contents to be destroyed When writing such statements be sure to use the push and pop instructions to save and restore the register contents 2 Within the pragma ASM to pragma ENDASM section do not reference argu ments and auto variables 3 Within the pragma ASM to pragma ENDASM section do not write a branch statement including conditional branch which may affect the program flow Example void func int MED for i 0 i lt 10 i func2 pragma ASM FCLR I This area is output directly to an assembly language file MOV W 0FFH RO omitted FSET I pragma ENDASM M Figure B 82 Example of pragma ASM ENDASM Suppliment t is this assembly language program written between pragma ASM and pr agma ENDASM that is processed by the C preprocessor Appendix B 57 Appendix B Extended Functions Reference pragma JSRA Function Calls a function using the JSR A instruction Syntax pragma JSRAAfunction name Description Calls all functions declared using pragma SRA using the JSR A instruction pragma SRA can be specified to avoid errors in the case of functions that include code generated using the fUSRW option and that cause errors during linking Rules This preprocessing directive has no effect when the fJSRW option not specified Example extern void func int i pragma JSRA func void mai n
208. enumerated type of data Write it correctly Appendix F 17 Appendix F Error Messages Table F 17 ccom30 Error Messages 10 14 Error message Description and countermeasure invalid truth expression 9 The void struct or union type is used in the first expression of a condition expression gt Use scalar type to write this expression invalid type specifier The same type specifier is described twice or more as in int int i or an incompatible type specifier is described as in float int i Write the type specifier correctly invalid type s bitfield bit field of an invalid type is declared gt Use the integer type for bit fields invalid types specifier long long long 6 Specifiers long are described thrice or more Check the type invalid unary operands Use of the unary operator is illegal Check the right side expression of the operator invalid unary operands Use of the unary operator is illegal Check the right side expression of the operator invalid unary operands Use of the unary operator is illegal Check the right side expression of the operator invalid unary operands Use of the unary operator is illegal Check the right side expression of the operator invalid void type 9 The void type specifier is used with long or singed Write the type specifier correctly inva
209. equent characters are alphanumerics or the underscore AtoZ atoz 0to9 or Identifiers can consist of up to 31 characters However you cannot specify Japanese characters in identifiers Appendix C 4 Appendix C Overview of C Language Specifications c Constants Constants consists of the followings Ge Integer constants e Floating point constants Character constants 1 Integer constants In addition to decimals you can also specify octal and hexadecimal integer constants Table C 7 shows the format of each base decimal octal and hexadecimal Table C 7 Specifying Integer Constants Base Notation Structure Example Decimal None 0123456789 15 Octal Start with O zero 01234567 017 Hexadeci Start with OX or Ox 0123456789ABCDEF OXF or Oxf mal 0123456789abcdef Determine the type of the integer constant in the following order according to the value Octal and hexadecimal signed int 2unsigned int signed long unsigned long signed long long unsigned long long eDecimal signed int 2signed long signed long long Adding the suffix U or u or L or l or LL or results in the integer constant being processed as follows t Unsigned constants Specify unsigned constants by appending the letter U or u after the value The type is determined from the value in the following order unsigned int 2unsigned long unsigned long long 2 long type constants Specify long type constants by ap
210. er certain use conditions Further Renesas Electronics products are not subject to radiation resistance design Please be sure to implement safety measures to guard them against the possibility of physical injury and injury or damage caused by fire in the event of the failure of a Renesas Electronics product such as safety design for hardware and software including but not limited to redundancy fire control and malfunction prevention appropriate treatment for aging degradation or any other appropriate measures Because the evaluation of microcomputer software alone is very difficult please evaluate the safety of the final products or system manufactured by you Please contact a Renesas Electronics sales office for details as to environmental matters such as the environmental compatibility of each Renesas Electronics product Please use Renesas Electronics products in compliance with all applicable laws and regulations that regulate the inclusion or use of controlled substances including without limitation the EU RoHS Directive Renesas Electronics assumes no liability for damages or losses occurring as a result of your noncompliance with applicable laws and regulations This document may not be reproduced or duplicated in any form in whole or in part without prior written consent of Renesas Electronics Please contact a Renesas Electronics sales office if you have any questions regarding the information contained in this document or Renesas Ele
211. er of parameters in the prototype declaration matches those in the pragma INTCALL declaration b You cannot declare the following types in the parameters in the assembler function Structure types and union types double types long long types You cannot declare the following functions as the return values of assembler functions 6 Functions that return structures or unions 3 You can use the following registers for parameters when calling float types long types 32 bit registers R2RO R8R1 and A1A0 far pointer types 24 bit registers R2RO R3R1 and A1A0 6 near pointer types 16 bit registers AO A1 R0 R1 R2 and R3 6 char types 8 bit registers ROL ROH R1L and R1H There is no differentiation between uppercase and lowercase letters in register names 4 You can only use decimals for the INT Numbers 2 Declaring functions of which the body is written in C 1 Before a pragma INTCALL declaration be sure to include a prototype declaration If there is no prototype declaration a warning is output and the pragma INTCALL declaration is ignored 2 You cannot specify register names in the parameters of functions that include the pragma INTCALL declaration 3 Observe the following in the prototype declaration a In the prototype declaration you can only declare functions in which all parameters are passed via registers as in the function calling rules b You cannot declare the following functions as the return val
212. erating routine Format include lt stdlib h gt void srand seed Method function Argument unsigned int seed Series value of random number ReturnValue No value is returned Description Initializes seeds the pseudo random number series produced by rand using seed sscanf Input Output Functions Function Reads data with format from a character string Format include lt stdio h gt int sscanf string format argument Method function Argument const char _ far string Pointer of the input character string const char _ far format Pointer of the format specifying character string ReturnValue 6 Returns the number of data entries stored in each argument 9 Returns EOF if null character 0 is input as data Description Converts the characters input as specified in format and stores them in the variables shown in the arguments Argument must be a far pointer to the respective variable Format is specified in the same way as in scanf Appendix E 66 Appendix E Standard Library strcat String Handling Functions Function Concatenates character strings Format include lt string h gt char far strcat 51 52 Method function Argument char far s1 Pointer to the character string to be concatenated to const char far s2 Pointer to the character string to be concatenated from ReturnValue Returns a pointer to the concatenated character string ar
213. erator Write the operand correctly can t get size of function unit size 1 assumed The pointer to the function is incremented or decremented Processing will be continued by assuming the increment or decrement value is 1 Do not increment or decrement the pointer to a function char array initialized by wchar_t string The array of type char is initialized with type wchar t gt Make sure that the types of initializer are matched case value is out of range The value of case exceeds the switch parameter range Specify correctly character buffer overflow The size of the string exceeded 512 characters Do not use more than 511 characters for a string character constant too long There are too many characters in a character constant characters enclosed with single quotes Write it correctly constant variable assignment In this assign statement substitution is made for a variable specified by the const qualifier Check the declaration part to be substituted for cyclic or alarm handler always Bank 0 NC77 NC79 only Function specified in pragma CYCHANDLER or ALMHANDLER are always compiled in bank 0 addresses below 10000H None cyclic or alarm handler always load DT NC77 NC79 only There is no need to pragma LOADDT a function specified in pragma CYCHANDLER or ALMHANDLER Delete pragma LOADDT
214. erlapping a function call do not use a register variable NC30 MANUAL 64 Chapter 3 Programming Technique 3 2 2 Speeding Up Startup Processing The ncrt0 a30 startup program includes routines for clearing the bss area This routine ensures that variables that are not initialized have an initial value of 0 as per the C lan guage specifications For example the code shown in Figure 3 9 does not initialize the variable which must therefore be initialized to 0 by clearing the bss area during the startup routine static int i Figure 3 9 Example Declaration of Variable Without Initial Value In some instances it is not necessary for a variable with no initial value to be cleared to 0 In such cases you can comment out the routine for clearing the bss area in the startup program to increase the speed of startup processing N BZERO bss SE top bss SE N BZERO bss SO top bss SO N BZERO bss NE top bss N BZERO bss NO top bss NO omitted BZERO bss FE top bss FE BZERO bss FO top bss FO Figure 3 10 Commenting Out Routine to Clear bss Area 1 The external variables in RAM which do not have initial values are referred to as bss NC30 MANUAL 65 3 3 3 3 1 Chapter 3 Programming Technique Linking Assembly Language Programs with C Programs Calling Assembler Functions from C Programs a Calling Assembler Functions Assembler functions are called from C programs using the name of the assembler fu
215. ers are passed via registers float types long types 32 bit registers R2RO R3R1 and A1A0 far pointer types 24 bit registers R2R0 R3R1 and A1A0 near pointer types 16 bit registers AO A1 RO R1 R2 and R3 6 char types 8 bit registers ROL ROH R1L and R1H Register names are NOT case sensitive C NC308 ONLY By specifying switch c it is possible to generate code to need the register to saving it to a stack at entry when calling the function Rules 1 Always put the prototype declaration for the assembler function before the pragma PARAMETER declaration If you fail to make the prototype declaration a warning is output and pragma PARAMETER is ignored 2 Follow the following rules in the prototype declaration a Note also that the number of parameters specified in the prototype declaration must match that in the pragma PARAMETER declaration b The following types cannot be declared as parameters for an assembler function in a pragma PARAMETER declaration structure type and union type double type long long types c The assembler functions shown below cannot be declared Functions returning structure or union type 3 An error occurs when you write the function entity specified in oragma PARAMETER in C language Example int asm func unsigned int unsigned int Prototype declaration for pragma PARAMETER asm func RO R1 the assembler function void main int Zr i Ox7FFD j 0x007F
216. es pragma PARAMETER amp function prototype mismatched The function specified by pragma PARAMETER does not match the contents of argument in pro totype declaration Make sure it is matched to the argument in proto type declaration pragma PARAMETER s function argument is struct or union The struct or union type is specified in the proto type declaration for the function specified by pragma PARAMETER 55 Specify the int or short type 2 byte pointer type or enumeration type in the prototype declaration pragma PARAMETER must be declared before use A function specified in the pragma PARAMETER declaration is defined after call for that function Declare a function before calling it pragma INTCALL function s argument on stack When the body of functions declared in pragma INTCALL are written in C the parameters are passed via the stack When the body of functions declared in pragma INTCALL are written in C specify the parameters are being passed via the stack pragma PARAMETER function s register not allocated A register which is specifed in the function decleared by pragma PARAMETER can not be allocated gt Use the correct register const is duplicate 6 const is described more than twice Write the type qualifier correctly far amp near conflict 6 far near is described more than twice Write near far correctly far is duplica
217. eturn Value c Referencing C Variables Because assembler functions are written in different files from the C program only the C global variables can be referenced When including the names of C variables in an assembler function precede them with an underscore Also in assembler language programs external variables must be declared using the assembler pseudo instruction GLB Figure 3 17 is an example of referencing the C program s global variable counter from the assembler function asm func NC30 MANUAL 69 Chapter 3 Programming Technique C program unsigned int counter C program global variable mai n omitted Assembler function GLB Counter External declaration of C program s asm func global variable omitted MOV W Counter RO Reference Figure 3 17 Referencing a C Global Variable d Notes on Coding Interrupt Handling in Assembler Function If you are writing a program function for interrupt processing the following processing must be performed at the entry and exit 1 Save the registers RO R1 R2 R3 AO A1 and FB at the entry point 2 Restore the registers RO R1 R2 R3 AO A1 and FB at the exit point 3 Use the REIT instruction to return from the function Figure 3 18 is an example of coding an assembler function for interrupt processing section program glb func dint func pushm RO RI R2 R3 A0 Al FB Push registers MOV B 01H ROL omitted
218. eturnValue Returns 0 if output normally Returns 1 EOF if an error occurs Description Outputs one line to stdout The null character 0 at the end of the character string is replaced with the new line character n qsort Integer Arithmetic Functions Function Sorts elements in an array Format include lt stdlib h gt void _far qsort base nelen size cmp e1 e2 Method function Argument void _far base Start address of array size t nelen Element number size t size Element size int cmp Compare function ReturnValue 6 No value is returned Description amp Sorts elements in an array Appendix E 58 Appendix E Standard Library rand Integer Arithmetic Functions Function Generates a pseudo random number Format include lt stdlib h gt int rand void Method function Argument No argument used Returnvalue 6 Returns the seed random number series specified in srand The generated random number is a value between 0 and RAND MAX realloc Memory Management Functions Function Changes the size of an allocated memory area Format include lt stdlib h gt void far realloc cp nbytes Method function Argument void _ far cp Pointer to the memory area before change size t nbytes Size of memory area in bytes to be changed ReturnValue Returns the pointer of the memory area which has had its size changed 6
219. fice equipment communications equipment test and measurement equipment audio and visual equipment home electronic appliances machine tools personal electronic equipment and industrial robots High Quality Transportation equipment automobiles trains ships etc traffic control systems anti disaster systems anti crime systems safety equipment and medical equipment not specifically designed for life support Specific Aircraft aerospace equipment submersible repeaters nuclear reactor control systems medical equipment or systems for life support e g artificial life support devices or systems surgical implantations or healthcare intervention e g excision etc and any other applications or purposes that pose a direct threat to human life You should use the Renesas Electronics products described in this document within the range specified by Renesas Electronics especially with respect to the maximum rating operating supply voltage range movement power voltage range heat radiation characteristics installation and other product characteristics Renesas Electronics shall have no liability for malfunctions or damages arising out of the use of Renesas Electronics products beyond such specified ranges Although Renesas Electronics endeavors to improve the quality and reliability of its products semiconductor products have specific characteristics such as the occurrence of failure at a certain rate and malfunctions und
220. fierAtype declaratorAdeclaration specifierAmain program function declaration prototype declaration storage class specifierAtype declaratorAdeclaration specifier Figure C 4 Declaration Format of Function 1 Storage class Specifier NC30 supports the following storage class specifier extern static 2 Type Declarators NC30 supports the following type declarators 6 Bool echar eint es hort eong ong long loat double unsigned signed struct union enum 3 Declaration Specifier Use the format of declaration specifier shown in Figure C 5 in NC30 Appendix C 12 Appendix C Overview of C Language Specifications Declarator Pointer p declarator2 Declarator2 identifier list of dummy argument declarator declarator constant expression declarator list of dummy argument opt apil opt Only the first array can be omitted from constant expressions showing the number of arrays opt indicates optional items The list of dummy arguments is replaced by a list of type declarators in a prototype declaration Figure C 5 Format of Declaration Specifier 4 Body of the Program Use the format of body of the program shown in Figure 0 6 List of Variable Declarator Compound Statement There is no body of the program in a prototype declaration which ends with a semicolon opt indicates optional items Figure C 6 Format of Body of the Program C 2 5 Statement NC30 supports th
221. filenameA C source file name gt Execution 9 5 nc30 v lusrlib ncrt0 a30 sample c example M16C 60 NC30 COMPILER V X XX Release X COPYRIGHT C XXXX XXXX RENESAS TECHNOLOGY CORPORATION ALL RIGHTS RESERVED AND RENESAS SOLUTIONS CORPORATION ALL RIGHTS RESERVED ncrt0 a30 as30 N ncrt0 a30 sample c Cpp30 sample c o sample i DM16C DNC30 ccom30 sample i o sample a30 main as30 N sample a30 1n30 ncrt0 r30 sample r30 l usrlib o nerto 9 In this example the option is used to specify a library named usrlib lib Notes 1 Infile specification the extension can be omitted If the extension of a file is omitted it is processed assuming an extension lib 2 If you specify a file extension be sure to specify lib 3 NC30 links by default a library nc30lib lib in the directory that is specified in environment variable LIB30 If you specify multiple libraries nc30lib lib is given the lowest priority as it is referenced Appendix A 44 Appendix A Warning Options Command Option Reference Table A 8 shows the command line options for outputting warning messages for contra ventions of nc30 language specifications Table A 8 Warning Options Option Short form Function Wnon_prototype WNP Outputs warning messages for functions without proto type declarations Wunknown pragma WUP Outputs warning messages for non supp
222. floor Mathematical Functions Function Calculates an integer borrow value Format include lt math h gt double floor x Method function Argument double x arbitrary real number ReturnValue The real value is truncated to form an integer which is returned as a double type fmod Mathematical Functions Function Calculates the remainder Format include lt math h gt double fmod x y Method function Argument double dividend double y divisor ReturnValue amp Returns a remainder that derives when dividend x is divided by divisor y Appendix E 30 Appendix E Standard Library fprintf Input Output Functions Function Outputs characters with format to the stream Format include lt stdio h gt int fprintf stream format argument Method function Argument FILE far stream Pointer of stream const char far format Pointer of the format specifying character string Return Value Returns the number of characters output Returns EOF if a hardware error occurs Description Argument is converted to a character string according to format and output to the stream Interprets code 0x1A as the end code and ignores any subsequent data Format is specified in the same way as in printf fputc Function Outputs one character to the stream Format include lt stdio h gt int fputc c stream Method function Argu
223. functions passed via register 11 Facility to declare special page subroutine call functions Facility to describe alarm handler functions Facility to describe cyclic handler functions Facility to describe interrupt handler functions Facility to describe taskstart functions Facility to describe inline assembler Facility to declare functions calling with JSR A instruction Facility to declare functions calling with JSR W instruction Facility to output PAGE Appendix C 21 Appendix C Overview of C Language Specifications You can only specify the above 17 processing functions with pragma If you specify a character string or identifier other than the above after pragma it will be ignored By default no warning is output if you specify an unsupported pragma function Warnings are only output if you specify the nc30 command line option Wunknown_pragma WUP Appendix C 22 Appendix C Overview of C Language Specifications if elif else endif a eS Function Format Description Performs conditional compilation Examines the expression true or false ifAconstant expression sielificdhistant expression endif f the value of the constant is true not 0 the commands if and elif process the program that follows elif is used in a pair with if ifdef or ifndef else is used in a pair with if Do not specify any tokens between else and the line feed You can howe
224. g to the machine in the M16C 60 series See the User Manual for your machine for details Change the interrupt vector address table as follows 1 Externally declare the interrupt processing function in the GLB as30 pseudo in struction The labels of functions created by NC30 are preceded by the underscore _ Therefore the names of interrupt processing functions declared here should also be preceded by the underscore 2 Replace the names of the interrupt processing functions with the names of inter rupt processing functions that use the dummy interrupt function name dummy_int corresponding to the appropriate interrupt table in the vector address table Figure 2 37 is an example of registering the UART1 send interrupt processing function uarttrn I word dummy int uartO trance for user I word dummy int uartO receive for user glb uarttrn Process 1 above word uarttrn uartl trance for user Process 2 above omitted Figure 2 37 Example Setting of Interrupt Vector Addresses sect30 inc NC30 MANUAL 55 Chapter 2 Basic Method for Using the Compiler f Setting SPECIAL Page Vector Table When using pragma SPECIAL you need to set up the special page vector table To set up the special page vector table follow one of the following two methods 1 Use the compiler option fmake_special_table fMST to automatically set up the special page vector table 2 Set up the special page vec
225. gma STRUCTAstructure_tagAarrange Description In NC30 structures are packed For example the members of the structure in Figure and B 66 are arranged in the order declared without any padding Examples Member name Type Size Mapped location offset b s 5 What e i int 16 bits 0 int E char 8 bits 2 hn j int 16 bits 3 Figure B 66 1 Inhibiting packing Example Mapping of Structure Members 1 This NC30 extended function allows you to control the mapping of structure members Figure B 67 is an example of mapping the members of the structure in Figure B 66 using pragma STRUCT to inhibit packing struct s ns i Member name Type Size Mapped location offset char c int 16 bits 0 int E char 8 bits 2 H j int 16 bits 3 Padding char 8 bits Figure B 67 Example Mapping of Structure Members 2 As shown Figure B 67 if the total size of the structure members is an odd number of bytes 2pragma STRUCT adds 1 byte as packing after the last member Therefore if you use Zpragma STRUCT to inhibit padding all structures have an even byte size Appendix B 41 Appendix B Extended Functions Reference pragma STRUCT Control structure mapping Description Examples 2 Arranging members This NC30 extended function allows you to map the all odd sized structure members first followed by even sized members Figure B 6
226. gned char val2 to high of val2 from low of val1 unsigned char movhl unsigned char val1 unsigned char val2 to low of val2 from high of val1 unsigned char movhh unsigned char val1 unsigned char val2 to high of val2 from high of val1 ROLC Function The value of val is returned after rotating it left by 1 bit including the C flag Syntax include lt asmmacro h gt unsigned char rolc b unsigned char val1 When calculated in 8 bits unsigned int rolc w unsigned int val1 When calculated in 16 bits RORC Function The value of val is returned after rotating it right by 1 bit including the C flag Syntax include lt asmmacro h gt unsigned char rorc_b unsigned char val When calculated in 8 bits unsigned int rorc_w unsigned int val When calculated in 16 bits Appendix B 66 Appendix B Extended Functions Reference ROT Function The value of val is returned after rotating it as many times as indicated by count Syntax include lt asmmcaro h gt unsigned char rot b signed char count unsigned char val When calculated in 8 bits unsigned int rot w signed char count unsigned int val When calculated in 16 bits Function The value val is returned after arithmetically shifting it as many times as indicated by count Syntax include lt asmmacro h gt unsigned char sha b signed char count unsigned char val When calculated in 8 bit
227. granted hereby under any patents copyrights or other intellectual property rights of Renesas Electronics or others You should not alter modify copy or otherwise misappropriate any Renesas Electronics product whether in whole or in part Descriptions of circuits software and other related information in this document are provided only to illustrate the operation of semiconductor products and application examples You are fully responsible for the incorporation of these circuits software and information in the design of your equipment Renesas Electronics assumes no responsibility for any losses incurred by you or third parties arising from the use of these circuits software or information When exporting the products or technology described in this document you should comply with the applicable export control laws and regulations and follow the procedures required by such laws and regulations You should not use Renesas Electronics products or the technology described in this document for any purpose relating to military applications or use by the military including but not limited to the development of weapons of mass destruction Renesas Electronics products and technology may not be used for or incorporated into any products or systems whose manufacture use or sale is prohibited under any applicable domestic or foreign laws or regulations Renesas Electronics has used reasonable care in preparing the information included in this document
228. gument to func i nt j Argument to func int Argument to func k func i int func int x int y int int sum 1 11 return sum Return value to main Figure D 14 Example of C Language Sample Program FUNCTION main FRAME AUTO k size offset FRAME AUTO j size offset FRAME AUTO size offset ARC Si ze 0 Auto Si ze 6 ontext Size 5 section program file proto2 c line 5 glb main enter 06 line 6 C SRC int i 0x1234 mov W 1234H 2 FB NE ine 7 C SRC int j 0x5678 mov W 5678H 4 line 8 C SRC int Ox9abc mov W 9abCH 6 K line 9 C SRC k func i j k push w 6 FB mov w A FB R2 j mov w 2 FB R1 jsr func add b 402 SP mov w RO 2 FB line 10 exit Figure D 15 Assembly language sample program 1 2 Appendix D 11 Appendix D C Language Specification Rules FUNCTI ON func FRAME AUTO x size 2 offset 2 FRAME AUTO sum size 2 offset 2 FRAME ARG y size 2 offset 5 FRAME ARG 2 size 2 offset 8 REGI STER ARG x size 2 REGI STER RO ARG Si ze 4 Auto Size 2 Context Size 8 line 13 C SRC glb func enter 80 2 mov W RO 2 FB line 16 S98 C SRC sum x mov w 2 FB RO add w 8 FB RO add w 10 FB RO W RO 2 FB line 17 S98 C SRC return sum mov W 2 FB RO exitd END Figure D 16 Assembly language sample program 2
229. has argument The interrupt handling function specified by pragma INTERRUPT is using an argument Arguments cannot be used in an interrupt func tion Delete the argument invalid pragma EQU The description of pragma EQU contains an er ror This line will be ignored Write the description correctly invalid pragma SECTION un known section base name The section name in pragma SECTION contains an error The section names that can be speci fied are data bss program rom interrupt and bas This line will be ignored Write the description correctly invalid pragma operand ignored An operand of pragma contains an error This line will be ignored Write the description correctly invalid function argument The function argument is not correctly written Write the function argument correctly Appendix F 27 Appendix F Error Messages Table F 26 ccom30 Warning Messages 6 10 Warning message Description and countermeasure invalid asm s M flag NC77 NC79 only 6 Error in M flag value in asm statement Specify an integer constant 0 1 or 2 invalid asm s MX flag ignored NC77 NC79 only Error in MX flag value in asm statement Specify an interger constant 0 1 or 2 invalid asm s X flag NC77 NC79 only 6 Error in X flag value in asm statement Specify an integer constant 0 1 or 2 invalid return type
230. he power of a floating point number log Calculates natural logarithm log10 Calculates common logarithm modf Calculates the division of a real number into the mantissa and exponent parts pow Calculates the power of a number sin Calculates sine sinh Calculates hyperbolic sine sqrt Calculates the square root of a numeric value tan Calculates tangent tanh Calculates hyperbolic tangent Appendix E 5 Appendix E Standard Library 0 D 3 o Function Defines the structures used in branch functions Function Contents longjmp Performs a global jump setjmp Sets a stack environment for a global jump signal h Function Defines declares necessary for processing asynchronous interrupts stdarg h Function Defines declares the functions which have a variable number of real arguments o r Q Q D Function Defines the macro names which are shared among standard include files Appendix E 6 stdio h Appendix E Standard Library Function Defines the FILE structure stream name and declares I O function prototypes Proto type declarations are made for the following functions Type Function Contents Initialize init Initializes M16C 60 family input outputs clearerr Initializes clears error status specifiers Input fgetc Inputs one character from the stream getc Inputs one character
231. he results of d i o u and x conversion are stored as long int and unsigned long int The results of e E f g and G conversion are stored as double h The results of d i o u and x conversion are stored as short int and unsigned short int If or h are specified in other than d i o u or x conversion they are ignored L The results of e E f g and G conversion are stored as float Appendix E 62 Appendix E Standard Library setjmp Execution Control Functions Function Saves the environment before a function call Format include setjmp h int setimp env Method function Argument jmp_buf env Pointer to the area where environment is saved ReturnValue Returns the numeric value given by the argument of longjmp Description Saves the environment to the area specified in env setlocale Function Sets and searches the locale information of a program Format include lt locale h gt char far setlocale category locale Method function Argument int category Locale information search section information const char _ far locale Pointer to a locale information character string ReturnValue Returns a pointer to a locale information character string 9 Returns NULL if information cannot be set or searched Appendix E 63 Appendix E Standard Library sin Mathematical Functions Function Calculates sine Format include lt math h gt double sin x
232. he stack size calculation utility STK Viewer amp stk e Heap Section Size Set the heap to the maximum amount of memory allocated using the memory manage ment functions calloc and malloc in the program Set the heap to 0 if you do not use these memory management functions Make sure that the heap section does not exceed the physical RAM area HEEP SIZE definition if HEAP HEAPSIZE equ OH else if HEAPSIZE 0 HEAPSIZE equ 300H else HEAPSIZE equ HEAPSIZE endif endif Figure 2 26 Example of Setting Heap Section Size ncrt0 a30 f Setting the interrupt vector table Set the top address of the interrupt vector table to the part of Figure 2 27 in ncrt0 a30 The INTB Register is initialized by the top address of the interrupt vector table INTERRUPT VECTOR ADDRESS definition if R6C 1 VECTOR ADR equ Offd00h SVECTOR ADR equ Offe00h else VECTOR ADR equ Ofedch endif Figure 2 27 Example of Setting Top Address of Interrupt Vector Table ncrt0 a30 The sample startup program has had values set for the tables listed below OFFDOOH lt OFFDFFH Interrupt vector table 5 OFFFFFH Special page vector table and fixed vector table Normally these set values do not need to be modified 1 The stack is used within the startup program as well Although the initial values are reloaded before calling the main function consideration is required if the s
233. he upper case letter if the argument is a lower case letter Otherwise returns the passed argument as is Description Converts the character from a lower case to an upper case ungetc Input Output Functions Function Returns one character to the stream Format include lt stdio h gt int ungetc c stream Method macro Argument Character to be returned FILE far stream Pointer of stream ReturnValue Returns the returned one character if done normally Returns EOF if the stream is in write mode an error or EOF is encountered or the character to be sent back is EOF Description Returns one character to the stream Interprets code Ox1A as the end code and ignores any subsequent data Appendix E 80 Appendix E Standard Library vfprintf Function Output to a stream with format Format include lt stdarg h gt include lt stdio h gt int vfprintf stream format ap Method function Argument FILE far stream Pointer of stream const char far format Pointer of the format specifying character string va list ap Pointer of argument list ReturnValue Returns the number of characters output Description Output to a stream with format When writing pointers in variable length variables make sure they are a far type pointer vprintf Function Output to stdout with format Format include lt stdarg h gt include lt stdio
234. her than d i 0 u x X or n conversion they are ignored L e E f g and G conversion is performed on double parameters 1 In the standard C specifications variables e E f and g conversions are performed in the case of L on long double parameters In NC30 long double types are processed as double types Threfore if you specify L the parameters are processed as double types Appendix E 56 Appendix E Standard Library putc Input Output Functions Function Outputs one character to the stream Format include lt stdio h gt int putc stream Method macro Argument X int c Character to be output FILE far stream Pointer of the stream ReturnValue Returns the output character if output normally Returns EOF if an error occurs Description Outputs one character to the stream putchar Function Outputs one character to stdout Format include lt stdio h gt int putchar c Method macro Argument int c Character to be output ReturnValue Returns the output character if output normally Returns EOF if an error occurs Description Outputs one character to stdout Appendix E 57 Appendix E Standard Library puts Input Output Functions Function Outputs one line to stdout Format include lt stdio h gt int puts str Method macro Argument char far str Pointer of the character string to be output R
235. id Delete the option fDPO8 You have made an error in the format of pragma DP n DATA Correct the format pragma JSRA illegal location ignored NC30 NC308 only Do not put pragma JSRA inside function scope Write pragma JSRA outside a function pragma JSRW illegal location ignored NC30 NC308 only 6 Do not put pragma JSRW inside function scope Write pragma JSRW outside a function pragma PARAMETER function s address used The address of function specified pragma PA RAMETER is assigned to the pointer variable As don t assign write correctly pragma control for function dupli cate ignored NC30 NC308 only Two or more of INTERRUPT TASK HANDLER CYCHANDLER or ALMHANDLER are specified for the same function in pragma Be sure to specify only one of INTERRUPT TASK HANDLER CYCHANDLER or ALMHANDLER auto is illegal storage class An incorrect storage class is used Specify the correct storage class register is illegal storage class An incorrect storage class is used Specify the correct storage class argument is define by typedef typedef ignored 6 Specifier typedef is used in argument declaration Specifier typedef will be ignored Delete typedef assign far pointer to near pointer bank value ignored 6 The bank address will be nullified when substitut ing the far pointer for the near pointer Check the da
236. ified with no sign it is processed as a sign long long type 6 the bit field members of a structure are specified with no sign they are processed as unsigned e Can not specifies bit fields of long long type C 2 3 Expressions Tables C 11 and Table C 12 show the relationship between types of expressions and their elements Table C 11 Types of Expressions and Their Elements 1 2 Type of expression Elements of expression Primary expression identifier constant character literal expression primary expression Postpositional expression Postpositional expression expression Postpositional expression list of parameters Postpositional expression identifier Postpositional expression identifier Postpositional expression Postpositional expression Postpositional expression Monadic expression monadic expression monadic expression monadic operator cast expression sizeof monadic expression sizeof type name Monadic expression Cast expression type name cast expression cast expression Expression expression expression expression expression expression expression Additional and subtraction expressions expression expression expression expression Bitwise shift expression expression expression expression expression Appendix C 9 Appendix C Overview of C L
237. ifying FB Offset Bit Position Appendix B 12 Appendix B Extended Functions Reference Figure B 23 shows examples of referencing auto area bit fields and the results of compil ing 6 C source file void func void struct TAG char bit0 1 char bit1 1 char bit2 1 char bit3 1 s asm bset b FB s bit1 Assembly language source file compile result 148 FUNCTION func 14 FRAME AUTO S size 1 offset 1 4 ARG Size 0 Auto Size 1 Context Size 5 section program file bit c line 3 glb func _ func enter 01H line 11 JHHHE ASM START bset 1 1 FB s AHHHE ASM END line 12 exitd Figure B 23 Example of Referencing auto Area Bit Field When referencing a bit field in the auto area you must confirm that it is located within the range that can be referenced using bit operation instructions within 32 bytes of the FB register value Appendix B 13 Appendix B Extended Functions Reference B 2 3 Specifying Register Name of register Variable The storage class auto and register variables including arguments may be mapped to registers by the compiler The variables mapped to registers can be used in the asm function by writing the program as shown in Figure B 24 below asm op code Variable name Figure B 24 Description Format for Register Variables You can only specify two variable name using this format Figure B 25 shows examples of referencing register variables
238. ilable on the market C language specifica tions include extended functions for embedded system C 1 Performance Specifications C 1 1 Overview of Standard Specifications NC30 is a cross C compiler targeting the M16C 60 20 series In terms of language specifications it is virtually identical to the standard full set C language but also has specifications to the hardware in the M16C 60 20 series and extended functions for embedded system 6 Extended functions for embedded system near far modifiers and asm function etc 6 Floating point library and host machine dependent functions are contained in the stan dard library Appendix C 1 Appendix C Introduction to NC30 Performance This section provides an overview of NC30 performance a Test Environment Overview of C Language Specifications Table C 1 shows the standard EWS environment assumed when testing performance TableC 2 shows the standard PC environment TableC 1 Standard EWS Environment Item Type of EWS UNIX Version EWS environment SPARCstation SunOS V 4 1 3 JLE1 1 3 Nihongo Solaris 2 5 HP 9000 700 Series HP UX V 10 20 Available swap area 100MB min TableC 2 Standard PC Environment Item Type of PC OS Version PC environment IBM PC AT or compatible Windows ME Windows 2000 Type of CPU Intel Pentium II Memory 128MB min TableC 3 Standard Linux Environment Item Type of PC OS Version PC environment Type of CPU
239. imized In the entry version this option cannot be specified Appendix A 25 2 6 Appendix A Command Option Reference Generated Code Modification Options Table 2 6 shows the command line options for controlling nc30 generated assembly code Table A 6 1 2 Generated Code Modification Options Option Short form Description fansi None Makes fnot_reserve_far_and_near fnot_reserve_asm and fextend to int valid In the entry version this option is always enabled i e assumed to be specified Therefore it cannot be enabled or disabled by specification not reserve asm Exclude asm from reserved words Only _asm is valid In the entry version this option is always enabled i e assumed to be specified Therefore it cannot be enabled or disabled by specification not reserve far and near fNRFAN Exclude far and near from reserved words Only _far and near are valid In the entry version this option is always enabled i e assumed to be specified Therefore it cannot be enabled or disabled by specification fnot reserve inline fNRI Exclude far and near from reserved words Only inline is made a reserved word In the entry version this option is always enabled i e assumed to be specified Therefore it cannot be enabled or disabled by specification fextend to int fETI Performs operation after extending char type data to the int type Extended according to ANSI stan
240. ing the compiler option fmake_vector_table fMVT to set up Refer to fmake_vector_table fMVT in Appendix A Command Option Refer ence and pragma INTERRUPT in Appendix B Extended Function Referen ce 2 When setting up the interrupt vector table in sect30 inc For programs that use interrupt processing change the interrupt vector table for the vector section in sect30 inc Figure 2 36 shows an example interrupt vector table variable vector section section vector ROMDATA variable vector table org VECTOR ADR Jif M60TYPE l word dummy int vector 0 BRK word dummy int vector 1 omitted word dummy int vector 10 word dummy int DMAO for user vector 11 l word dummy int DMA1 2 for user vector 12 l word dummy int input key for user vector 13 word dummy int AD Convert for user vector 14 omitted d wor d dummy int INTL for user vector 30 word dummy int INT2 for user vector 31 Jel se word dummy int BRK vector 0 word dummy int i vector 1 omitted dummy_int is a dummy interrupt processing function word dummy int Silo4 int5 for user vector 8 I word dummy int Silo3 int4 for user vector 9 word dummy int Bus collision detection for user v10 Figure 2 36 Interrupt Vector Address Table sect30 inc NC30 MANUAL 54 Chapter 2 Basic Method for Using the Compiler The contents of the interrupt vectors varies accordin
241. inter to a function that does not have a register argument i e a non prototyped function Change the declaration of a pointer variable for function to a prototype declaration multi character character constant 6 A character constant consisting of two characters or more is used Use a wide character L xx when two or more characters are required near far is conflict beyond over typedef The type defined by specifying near far is again defined by specifying near far when referencing it Write the type specifier correctly No hex digit no hex digit 6 The hex constant contains some character that cannot be used in hex notation Use numerals 0 to 9 and alphabets A to F and a to f to describe hex constants Appendix F 28 Appendix F Error Messages Table F 27 ccom30 Warning Messages 7 10 Warning message Description and countermeasure No initialized of valiable name It is probable that the register variables are used without being initialized Make sure the register variables are assigned the appropriate value No storage class amp data type in declare global storage class amp int type assumed The variable is declared without storage class and type specifiers It will be handled as int when processed Write the storage class and type specifiers non initialized variable 6variable name is used It is probable that uninitialized vari
242. ion e data SO section Gbss SO section e data NO section Gbss NO section rom_NO section b Sections mapped only to OF0000H OFFFFFH e program 5 fvector c Sections mapped to any area for the M16C 60 series data_FE section rom_FE section data_SEIl section edata NEI section e data FEI section 0055 FE section Ge program e data FO section rom_FO section e data SOI section e data NOI section edata FOI section bss FO section G vector NC vectorr If any of the following data sections have a size of 0 they need not be defined e data SE data SEI section e data SO data SOI section edata NE data NEI section e data NO data NOI section edata FE data FEI section e data FO data FOI section Gbss SE section 0055 SO section Gbss NE section Gbss NO section bss FE section 0055 FO section Grom NE section rom_NO section Grom FE section Grom FO section NC30 MANUAL 49 Chapter 2 Basic Method for Using the Compiler 2 Example Section Mapping in Single Chip Mode Figures 2 32 to 2 35 are examples of the sect30 inc include file which is used for map ping sections to memory in single chip mode p RRR RRR RRR RR KERR EERE RRR RRR EG EEG EG E EO KR RRR KERR RR KERR RK RRR KR RRR KERR RK ERR GG KER KE GGG X C Compiler for R8C Tiny M16C 60 30 20 10 COPYRIGHT C XXXX XXXX XXXX RENESAS TECHNOLOGY CORPORATION AND RENESAS SOLUTIONS CORPORATION ALL RIGHTS RESERVED Written by X Xxxxx sect
243. ion has its arguments passed via only a stack int func proto int int func proto int i int j return i j k int func_no_proto int i int j int k return i j mai n voi d int sum sum func proto 1 2 3 15 func no proto 1 2 3 etel 1 This is the prototype declaration of function func proto 2 This is the body of function func proto Prototype declaration is entered so this is a new format 3 This is the body of function func no proto This is a description in K amp R format that is an old format 4 This is the body of function main 5 This calls function func_proto 6 This calls function func_no_proto Figure D 10 Sample Program for Calling a Function sample c The compile result of the above sample program is shown in the next page Figure D 11 shows the compile result of program part 2 that defines function func_proto Figure D 12 shows the compile result of program part 3 that defines function func_no_proto Figure D 13 shows the compile result of program part 4 that calls function func_proto and function func_no_proto 1 However function names are not output for the functions that are specified by pragma INTCALL Appendix D 8 Appendix D C Language Specification Rules FUNCTI ON func proto FRAME AUTO j size FRAME AUTO FRAME ARG REGISTER ARG i size u 2 offset 4 i size 2 offset 2 size 2 offset 5 7 2 REGISTER R1 lt 8 REGISTER ARG
244. ion in this example is only to read out port the readout code actually is not optimized before being output To suppress optimization add the volatile qualifier as shown in Figure 3 2 extern int volatile port f unC port Figure 3 2 Example of a Meaningless Variable Access Optimization Suppressed 2 Meaningless comparison int func char c Int 1 fe 1 jp 1s else i20 return i Figure 3 3 Meaningless Comparison In the case of this example because the variable c is written as char the compiler treats it as the unsigned char type Since the range of values representable by the unsigned char type is 0 to 255 the variable c will never take on the value 1 Accordingly if there is any statement which logically has no effect like this example the compiler does not generate assembler code NC30 MANUAL 59 Chapter 3 Programming Technique 3 Programs not executed No assembler codes are generated for programs which logically are not executed void func int i func2 i return i210 lt Fragment not executed Figure 3 4 Program Not Executed 4 Operation between constants Operation between constants is performed when compiling void func int i int i 1 2 Operation on this part is performed when compiling return i Figure 3 5 Program Not Executed b Selection of optimum instructions Selection of optimum instructions as
245. ional compilation Preprocess Commands Reference The NC30 preprocess commands are described in more detail below They are listed in the order shown in Table C 13 Appendix C 16 Appendix C Overview of C Language Specifications define ess Function Defines macros Format 1 defineAindentifierAlexical string opt 2 defineAidentifier identifier list opt Alexical string opt Description 1 Defines an identifier as macro 2 Defines an identifier as macro In this format do not insert any space or tab between the first identifier and the left parenthesis The identifier in the following code is replaced by blanks define SYMBOL When a macro is used to define a function you can insert a backslash so that the code can span two or more lines The following four identifiers are reserved words for the compiler Name of source file Current source file line No Date compiled mm dd yyyy Time compiled hh mm ss The following are predefined macros in NC30 M16C NC30 You can use the token string operator and token concatenated operator with tokens as shown below define debug s t printf x s d x t 2 d x THE s x t When parameters are specified for this macro debug s t as debug 1 2 they are interpreted as follows define debug s t printf x1 d x2 d x1 x2 Appendix C 17 Appendix C Overview of C Language Specifications define
246. ions located in areas whose section names have been altered by pragma SECTION are also included among those to be pro cessed Notes If pragma SECTION is used for an explicit purpose of locating a particular variable or function at a given address do not specify this option because the variable or function may be located at an unintended different address by SBDATA or SPECIAL page declaration fover write FOW Outputs SBDATA declaration or SPECIAL function declaration to a file Function Does not check whether the output file specified by already exists If such file exists it is overwritten This option must be specified along with the option Appendix G 9 Appendix G The SBDATA declaration amp SPECIAL Page Function declaration Utility utl30 G 3 Notes In using utl30 sbsym declared in files described in assembler cannot be counted For this reason you need to make adjustment if a sosym declared in assembler is present so that the results effected after having executed utl30 are put in the SB area In using utl30 SPECIAL Page Function declared in files described in assembler cannot be counted For this reason you need to make adjustment if a SPECIAL Page Function declared in assembler is present so that the results effected after having executed utl30 are put in the SPECIAL Page area G 4 Conditions to establish SBDATA declaration SPECIAL Page Function declaration G 4 1 Conditions to establish SBDATA d
247. items read up to the end of the stream Interprets code Ox1A as the end code and ignores any subsequent data Appendix E 32 Appendix E Standard Library free Memory Management Function Function Frees the allocated memory area Format include lt stdlib h gt void free cp Method function Argument void far cp Pointer to the memory area to be freed ReturnValue No value is returned Description Frees memory areas previously allocated with malloc or calloc No processing is performed if you specify NULL in the parameter frexp Mathematical Functions Function Divides floating point number into mantissa and exponent parts Format include lt math h gt double frexp x prexp Method function Argument double x float point number int far prexp Pointer to an area for storing a 2 based exponent ReturnValue Returns the floating point number x mantissa part Appendix E 33 Appendix E Standard Library fscanf Input Output Function Function Reads characters with format from the stream Format include lt stdio h gt int fscanf stream format argument Method function Argument FILE far stream Pointer of stream const char far format Pointer of the input character string ReturnValue Returns the number of data entries stored in each argument 9 Returns EOF if EOF is input from the stream as data Description Converts the characte
248. ition amp Assembler SPECIAL Page Function definition utility MAP Viewer as30 utl30 MapViewer STK Viewer Relocatable fi le StkViewer SBDATA SPECIAL Page definition file unction definition file Absolute _ Motorola S format file module or file Intel HEX format file package File processed File by NC30 Figure1 1 NC30 Processing Flow 1 MapViewer is included for only the Windows TM version To verify the map information while using the UNIX version generate a map file with the linker and check that file for map information NC30 MANUAL 1 1 2 1 1 2 2 1 2 3 1 2 4 1 2 5 1 2 6 Lae Chapter 1 Introduction to NC30 nc30 nc30 is the executable file of the compile driver By specifying options nc30 can perform the series of operations from compiling to linking You can also specify for the as30 relocatable macro assembler and four for the In30 linkage editor by including the as30 and In30 command line options when you start nc30 cpp30 cpp30 is the executable file for the preprocessor cop30 processes macros starting with define include etc and performs conditional compiling if else endif etc ccom30 ccom30 is the executable file of the compiler itself C source programs processed by cpp30 are converted to assembly language source programs that can be processed by 8530 aopt30 aopt30 is the assembler optimizer It optimize
249. izer aopt30 In the entry version this option cannot be specified Appendix A 23 Appendix A Command Option Reference Ostatic to inline OSTI Function A static function is treated as an inline function and the assembling code which carried out inline deployment is generated In the entry version this option cannot be specified Supplement When the following conditions are fulfilled a static function is treated as an inline function and the assembling code which carried out inline deployment is generated 1 Substance is described before the function call It is aimed at a static function When you specify Oforward function to inline option ignore this condi tion 2 When address acquisition is omitted in the program to the static function 3 When the recursive call of the static function has not been carried out 4 When construction of a frame reservation of an auto variable etc is not per formed in the assembling code output of a compiler The situation of the exist ence of frame construction changes with combined use with the contents of description of the target function and another optimization option When you specify Oforward function to inline option ignore this condi tion Below inline deployment is carried out The example of description of a static function is shown A Function func is a function inline deployment is carried Tut in each place currently static int fu
250. k statements 6 The break statement is put where it cannot be used Make sure that it is written in switch while do while and for invalid case statements 6 The switch statement contains an error Write the switch statement correctly invalid case value The case value contains an error Write an integral type or enumerated type con stant invalid cast operator Use of the cast operator is illegal Write the expression correctly invalid continue statements 6 The continue statement is put where it cannot be used gt Use it in a while do while and for block invalid default statements The switch statement contains an error Write the switch statement correctly invalid enumerator initialized 6 The initial value of the enumerator is incorrectly specified by writing a variable name for example Write the initial value of the enumerator correctly invalid function argument An argument which is not included in the argu ment list is declared in argument definition in function definition Declare arguments which are included in the ar gument list invalid function s argument declara tion 6 The argument of the function is erroneously de clared Write it correctly invalid function declare 9 The function definition contains an error Check the line in error or the immediately preced ing function definition invalid initia
251. laration SPECIAL Page Function declaration Utility utl30 O Outputs the declared SBDATA result display file Function Outpus the result of SBDATA declaration or SPECIAL Page Function declaration to a file With this option not specified outputs the result to the host machine s either EWS or per sonal computer standard output device If the specified file already exists the result is written to the standard output device Execution Output SBDATA declaration example utl 30 sb30 ncrt0 x30 o sample M16C 60 UTILITY UTL30 for M16C 80 V X XX XX COPYRIGHT C XXXX XXXX RENESAS TECHNOLOGY CORPORATION ALL RIGHTS RESERVED AND RENESAS SOLUTIONS CORPORATION ALL RIGHTS RESERVED t ype sample h pragma SBDATA Utility x SBDATA Size 255 3 pragma SBDATA 7 size 2 refz 2 3 omit pragma SBDATA vx l size 2 refz 1 Output SPECIAL page Function declaration utl 30 sp30 ncrt0 x30 o sample M16C 60 UTILITY UTL30 for M16C 80 V X XX XX COPYRIGHT C XXXX XXXX RENESAS TECHNOLOGY CORPORATION ALL RIGHTS RESERVED AND RENESAS SOLUTIONS CORPORATION ALL RIGHTS RESERVED t ype sample h pragma SPECIAL PAGE Utility pragma SPECIAL 255 func size 200 refz 2 omit pragma SPECIAL 254 funcl size 200 refz 1 Appendix G 6 Appendix G The SBDATA declaration amp SPECIAL Page Function declaration Utility utl30 all
252. lb start section interrupt start 16 after reset this program will start dc istack_top isp set istack pointer mov b 02h Oah mov b 00h 04h set processer mode lt 17 mov b 00h Oah Idc 0080h flg 18 dc stack top sp set stack pointer dc amp data SE top sb set sb register di ntb VECTOR_ ADR NEAR area initialize 19 bss zero clear BZERO bss SE top bss SE BZERO bss 50 top bss 50 BZERO bss NE top bss NE BZERO bss NO top bss NO initialize data section 20 _BCOPY data SEI top data SE top data SE _BCOPY data SOI top data SO top data 50 BCOPY data NEI top data NE top data NE BCOPY data NOI top data NO top data NO FAR area initialize bss zero clear BZERO bss FE top bss FE BZERO bss FO top bss FO Copy edata 0 section from edata_El Ol section BCOPY data FEI top data FE top data FE BCOPY data FOI top data FO top data FO dc stack_top sp i stk 40 16 For R8C Tiny After a reset execution starts from this label start 17 For R8C Tiny Sets processor operating mode 18 For R8C Tiny Sets IPL and each flags 19 For R8C Tiny Clears the near and SBDATA bss section to zeros 20 Moves the initial values of the near and SBDATA data section to RAM Figure 2 10 Startup Program List 5 ncrt0 a30 5 6 NC30 MANUAL 26 Chapter 2 Basic Method for Using the Compiler heap area initialize 21 I5 HEAP 1 b __ mbase b __mnext
253. le M16C 60 NC30 COMPILER V X XX Release X COPYRIGHT C XXXX XXXX RENESAS TECHNOLOGY CORPORATION ALL RIGHTS RESERVED AND RENESAS SOLUTIONS CORPORATION ALL RIGHTS RESERVED Sample c cpp30 sample c o sample i DM16C DNC30 ccom30 sample i o sample a30 g as30 N N sample a30 1n30 sample r30 G MS o sample omitted Is sample rwWer r 1 toolusr 2894 Aug 17 14 51 sample c TP We D 1 toolusr 7048 Aug 17 15 53 sample map 1 toolusr 53570 Aug 17 15 53 sample x30 Note When debugging your program at the C language level always specify this option Specification of this option does not affect the code generated by the compiler Appendix A 12 Appendix A Command Option Reference genter Function Always output an enter instruction when calling a function In the entry version this option is always enabled i e assumed to be speci fied Therefore it cannot be enabled or disabled by specification Note When using the debugger s stack trace function always specify this option Without this option you cannot obtain the correct result When this option is specified the compiler generates code to reconstruct the stack frame using the enter command at entry of the function regardless of whether or not it is necessary Consequently the ROM size and the amount of stack used may increase gno_reg Suppresses debugging information about register variables Function Suppresses the ou
254. lid void type int assumed 9 The void type variable cannot be declared Pro cessing will be continued by assuming it to be the int type Write the type specifier correctly invalid size of bitfield Get the bitfield size Not write bitfield on this decraration invalid switch statement 6 The switch statement is illegal Write it correctly label label redefine The same label is defined twice within one func tion Change the name for either of the two labels long long type s bitfield 6 Specifies bitfield by long long type Can not specifies bit fields of long long type mismatch prototyped parameter type The argument type is not the type declared in prototype declaration Check the argument type No pragma ENDASM pragma ASM does not have matching pragma ENDASM gt Write pragma ENDASM No declarator The declaration statement is incomplete Write a complete declaration statement Not enough memory UNIX version The swap area is insufficient gt Increase the swap area MS Windows 95 98 NT version The memory area is insufficient Increase the memory or the swap area Appendix F 18 Appendix F Error Messages Table F 18 ccom30 Error Messages 11 14 Error message Description and countermeasure not have long char Type specifiers long and char are simultaneously used Write the type s
255. linking to suppress generation of absolute module files Also a return value 10 is returned to the host OS NC30 MANUAL 20 Chapter 2 Basic Method for Using the Compiler i Assemble and Link Options Table 2 9 shows the command line options for specifying as30 and In30 options Table 2 9 Assemble and Link Options Option Function as30A option Specifies options for the as30 link command If you specify two or more options enclose them in double quotes In the entry version this option cannot be specified In380A lt option gt Specifies options for the In30 assemble command If you specify two or more options enclose them in double quotes In the entry version this option cannot be specified NC30 MANUAL 21 2 2 2 2 1 Chapter 2 Basic Method for Using the Compiler Preparing the Startup Program For C language programs to be burned into ROM NC30 comes with a sample startup program written in the assembly language to initial set the hardware M16C 60 locate sections and set up interrupt vector address tables etc This startup program needs to be modified to suit the system in which it will be installed The following explains about the startup program and describes how to customize it Note however the startup program is separated between the M16C use and the R8C Tiny use by conditional assemble instructions if else endif with a condi tional expression R8C 1 When you
256. lizer 6 The initialization expression contains an error This error includes excessive parentheses many initialize expressions a static variable in the function initialized by an auto variable or a vari able initialized by another variable Write the initialization expression correctly invalid initializer of variable name 6 The initialization expression contains an error This error includes a bit field initialize expression described with variables for example Write the initialization expression correctly Appendix F 16 Appendix F Error Messages Table F 16 ccom30 Error Messages 9 14 Error message Description and countermeasure invalid initializer on array The initialization expression contains an error Check to see if the number of initialize expres sions in the parentheses matches the number of array elements and the number of structure mem bers invalid initializer on char array 9 The initialization expression contains an error Check to see if the number of initialize expres sions in the parentheses matches the number of array elements and the number of structure mem bers invalid initializer on scalar 9 The initialization expression contains an error Check to see if the number of initialize expres sions in the parentheses matches the number of array elements and the number of structure mem bers invalid initializer on struct 9 The initializa
257. ll storage classes such as extern and static for variables specified in pragma AD DRESS are invalid 2 Variables specified in pragma ADDRESS are valid only for variables defined outside the function 3 pragma ADDRESS is valid for previously declared variables 4 pragma ADDRESS is invalid if you specify other than a variable 5 No error occurs if a pragma ADDRESS declaration is duplicated but the last de clared address is valid 6 A warning occurs if you include an initialization expression and an initialization ex pression is invalid 7 Normally pragma ADDRESS or pragma EQU operates on I O variables so that even though volatile may not actually be specified the compiler processes them as suming volatile is specified However as follows when the variable is used before specification of pragma AD DRESS specification of oragma ADDRESS is invalid char port void func port 0 pragma ADDRESS port 100H Appendix B 44 Appendix Extended Functions Reference pragma ADDRESS pragma EQU Specify absolute address of I O variable Example Hpragma ADDRESS io 24H int io func io 10 Figure B 71 pragma ADDRESS Declaration Note For compatibility with C77 versions prior to V 2 10 before can accept files that include pragma EQU The absolute address using this format is written using the C conven tions Appendix B 45 Appendix B Exte
258. lso declare the parameter type s 2 Declare the name of the register used by pragma PARAMETER in the assembler function s parameter list Figure 3 13 is an example of using pragma PARAMETER when calling the assembler function asm func extern unsigned int asm func unsigned int unsigned int pragma PARAMETER asm func R0 RI Parameters are passed via the RO and R1 registers to the void main assembler function int i 0x02 int j 0x05 asm func i j Calling assembler function Figure 3 13 Example of Calling Assembler Function With Parameters smp2 c glb main main enter 04H mov w 0002H 4 FB sod mov w 0005H 2 FB mov w 2 FB RI Parameters are passed via the RO and R1 mov w 4 FB RO So qq f registers to the assembler function jsr asm func Calls assembler function preceded by _ exitd X Figure 3 14 Compiled result of smp2 c smp2 a30 NC30 MANUAL 67 Chapter 3 Programming Technique c Limits on Parameters in pragma PARAMETER Declaration The following parameter types cannot be declared in a pragma PARAMETER declara tion structure types and union type parameters 64bit integer type flong longparameters Floating point type float and double parameters 3 3 2 Writing Assembler Functions a Method for writing the called assembler functions The following shows a procedure for writing the entry processing of assembler functions
259. lt string h gt char _far memset s c n function void far s Pointer to the memory area to be set at ss Data to be set Size tn Number of bytes to be set Returns the pointer to the memory area which has been set Sets n bytes of data c in memory s When you specify options O OR or OS the system may selects another functions with good code efficiency by optimization Appendix E 51 Appendix E Standard Library modf Mathematical Functions Function Calculates the division of a real number into the mantissa and exponent parts Format include lt math h gt double modf val pd Method function Argument double val arbitrary real number double far pd Pointer to an area for storing an integer ReturnValue Returns the decimal part of a real number perror Input Output Functions Function Outputs an error message to stderr Format Hinclude lt stdio h gt void perror s Method function Argument const char far s Pointer to a character string attached before a message ReturnValue No value is returned Appendix E 52 Appendix E Standard Library pow Mathematical Functions Function Calculates the power of a number Format include math h double pow x y Method function Argument double x multiplicand double y power of a number ReturnValue Returns the multiplicand x r
260. ludes line try again with the E option Compile driver control Function Creates assembly language source files extension a30 and ext and stops processing Execution nc30 S sample c example M16C 60 NC30 COMPILER V X XX Release X COPYRIGHT C XXXX XXXX RENESAS TECHNOLOGY CORPORATION ALL RIGHTS RESERVED AND RENESAS SOLUTIONS CORPORATION ALL RIGHTS RESERVED sample c Is sample 1 toolusr 2059 Aug 17 11 30 sample 830 rwer r 1 toolusr 2835 Aug 17 11 28 sample c A Notes When this option is specified no relocatable object files extension r30 abso lute module files extension x30 or other files output by as30 or In30 are gener ated Appendix A 5 Appendix A Command Option Reference Upredefined macro Function Undefines predefined macro constants Syntax nc30A U predefined macroA lt C source file gt Execution example nc30 c UNC30 UMI6C sample c M16C 60 NC30 COMPILER V X XX Release X COPYRIGHT C XXXX XXXX RENESAS TECHNOLOGY CORPORATION ALL RIGHTS RESERVED AND RENESAS SOLUTIONS CORPORATION ALL RIGHTS RESERVED sample c In this example macro definitions NC30 and M16C are undefined 2 Notes The maximum number of macros that can be undefined may be limited by the maximum number of characters that can be specified on the command line of the operating system of the host machine STDC LINE FILE DATE and TIME cannot be undefined
261. mat shown in Figure B 35 to specify auto variables and parameters asm MOV W 01H FB i lt Format for referencing auto variables asm BSET FB 5 010 lt Format for checking auto bit fields Figure B 35 Example Coding of asm Function 1 2 2 You can specify the register storage class in NC30 When register class variables are compiled with option fenable_register fER use the format shown in Figure B 36 for register variables in asm functions asm MOV W 0H i Format for checking register variables Figure B 36 Example Coding of asm Function 2 2 Note that when you specify option O 1 5 OR or OS parameters passed via the reg isters may to improve code efficiency be processed as register variables rather than being moved to the auto area In this case when parameters are specified in an asm function the assembly language is output using the register names instead of the variable s FB offset 3 When referencing arguments in the asm function The compiler analyzes program flow in the interval in which variables including arguments and auto variables are effective as it processes the program For this reason if arguments or auto variables are referenced directly in the asm function management of such effective interval is destroyed and the compiler cannot output codes correctly Therefore to reference arguments or auto variables in the asm function you are writing always be sure to use the
262. may selects another functions with good code efficiency by optimization tan Mathematical Functions Function Calculates tangent Format include lt math h gt double far tan x Method function Argument double X arbitrary real number ReturnValue 6 Returns the tangent of given real number x handled in units of radian Appendix E 78 Appendix E Standard Library tanh Mathematical Functions Function Calculates hyperbolic tangent Format include lt math h gt double tanh x Method function Argument double X arbitrary real number ReturnValue 6 Returns the hyperbolic tangent of given real number x tolower Character Handling Functions Function Converts the character from an upper case to a lower case Format include int tolower c Method macro Argument into Character to be converted Return Value Returns the lower case letter if the argument is an upper case letter Otherwise returns the passed argument as is Description Converts the character from an upper case to a lower case Appendix E 79 Appendix E Standard Library toupper Character Handling Functions Function Converts the character from a lower case to an upper case Format Hinclude int toupper c Method macro Argument Character to be converted ReturnValue amp Returns t
263. mber of levels of nesting is 40 An include error results if the specified file does not exist error eee Function Suspends compilation and outputs the message to the standard output device Format errorAcharacter string Description Suspends compilation lexical string is found this command outputs that character string to the standard output device Appendix C 19 Appendix C Overview of C Language Specifications line ae ees 64 Function Changes the line number in the file Format lineAintegerA file name Description e Specify the line number in the file and the filename You can change the name of the source file and the line No ftassert Function Issues a warning if a constant expression results in zero 0 Format assertAconstant expression Description lssues a warning if a constant expression results in zero 0 Compile is contin ued however Warning cpp30 82 x c line xx Jassertion warning Appendix C 20 Appendix C Overview of C Language Specifications pragma ee eee Function Instructs the system to process NC30 s extended functions Format 1 pragma ROMAvariable name 2 pragma SBDATAAvariable name 3 pragma SECTIONApredetermined section nameAaltered section name 4 pragma STRUCTAtag name of structureAunpack 4 pragma STRUCTAtag name of structureAarrange 5 pragma EXT4MPTRAname of pointer 6 pragma ADDRESSAvariable nameAabsolute a
264. me No error occurs if you duplicate pragma INTERRUPT declarations You cannot specify both switch E and switch B at the same time If different interrupt vector numbers are written in the same interrupt handling func tion the vector number declared later is effective Example pragma INTERRUPT intr vect 10 pragma INTERRUPT intr vect 20 The interrupt vector number 20 is effective NO On f Appendix B 49 Appendix B Extended Functions Reference pragma INTERRUPT pragma INTEF Declare interrupt function Rules 8 A compile warining occurs if you use any function specified in one of the following declarations in pragma INTERRUPT e pragma ALMHANDLER e pragma INTHANDLER e pragma HANDLER e pragma CYCHANDLER 6 pragma TASK Example pragma INTERRUPT i func i void i func int_counter 1 Figure B 75 Example of pragma INTERRUPT Declaration Note For compatibility with C77 versions prior to V 2 10 before can accept files that include pragma INTF Appendix B 50 Appendix B pragma PARAMETER Extended Functions Reference Declare assembler function that passed arguments via register Function Declares an assembler function that passes parameters via registers Syntax pragma PARAMETERAI CjAassembler function name register name register name Description This extended function declares that when calling an assembler function its paramet
265. me buffer has overflowed Note flow that the filename includes the path Reduce the length of the filename and path use the I option to specify the standard directory 18 not enough memory for 6 Insufficient memory for macro name and contents macro identifier of macro UNIX Increase the swap area MS Windows Increase the swap area 21 include file not found The include file could not be opened The include files are in the current directory and that specified in the option and environment variable Check these directories 22 illegal file name error 6 Illegal filename Specify a correct filename 23 include file nesting over 6 Nesting of include files exceeds the limit 8 Reduce nesting of include files to a maximum of 8 levels 25 llegal identifier 6 Error in define OCode the source file correctly 26 illegal operation Error in preprocess commands if elseif as sert operation expression Rewrite operation expression correctly 27 macro argument error Error in number of macro parameters when ex panding macro Check macro definition and reference and correct as necessary 28 linput buffer over flow Input line buffer overflow occurred when reading source file s Or buffer overflowed when con verting macros Reduce each line in the source file to a maximum of 1023 characters If you anticipate macro con version modify the code so that no line exceeds 1023
266. ment Character to be output FILE far stream Pointer of the stream ReturnValue 6 Returns the output character if output normally Returns EOF if an error occurs Description Outputs one character to the stream Appendix E 31 Appendix E Standard Library fputs Function Outputs one line to the stream Format include lt stdio h gt int fputs str stream Method function Argument const char far str Pointer of the character string to be output FILE far stream Pointer of the stream ReturnValue Returns 0 if output normally Returns any value other than 0 EOF if an error occurs Description 9 Outputs one line to the stream fread Input Output Functions Function Reads fixed length data from the stream Format include lt stdio h gt size_t fread buffer size count stream Method function Argument void far buffer Pointer of the location to be stored in Size t size Number of bytes in one data item Size t count Maximum number of data items FILE far stream Pointer of stream ReturnValue Returns the number of data items input Description Reads data of the size specified in size from the stream and stores it in the buffer This is repeated by the number of times specified in count If the end of the stream is encountered before the data specified in count has been input this function returns the number of data
267. mon logarithm include lt math h gt double log10 x function double x arbitrary real number 6 Returns the common logarithm of given real number x longjmp execution Control Functions Function Format Method Argument ReturnValue Description Restores the environment when making a function call include setjmp h void longjmp env val function jmp_buf env Pointer to the area where environment is restored int val Value returned as a result of setjmp No value is returned Restores the environment from the area indicated in env 9 Program control is passed to the statement following that from which setjmp was called 9 The value specified in val is returned as the result of setimp However if val is 0 it is converted to 1 Appendix E 45 Appendix E Standard Library malloc Memory Management Functions Function Allocates a memory area Format include lt stdlib h gt void far malloc nbytes Method function Argument size_t nbytes Size of memory area in bytes to be allocated Return Value Returns NULL if a memory area of the specified size could not be allocated Description 9 Dynamically allocates memory areas Rule 9 malloc performs the following two checks to secure memory in the appropriate location 1 memory areas have been freed with free 1 1 If the amount of memory to be secu
268. n 3 Only the function definition put after pragma TASK are valid 4 No processing occurs if you specify other than a function name 5 No error occurs if you duplicate pragma TASK declarations 6 A compile warinig occurs if you use any function specified in one of the following declarations in pragma TASK pragma INTERRUPT e pragma INTHANDLER e pragma HANDLER e pragma ALMHANDLER e pragma CYCHANDLER Example include lt mr30 h gt include id h pragma TASK main pragma TASK tskl void main void lt Be sure to declare as type void omitted Sta tsk ID idle Sta tsk ID tsk1 ext tsk lt You need not use ext tsk void tsk1 remainder omitted Figure B 81 Example of pragma TASK Declaration Appendix B 56 Appendix B Extended Functions Reference B 7 5 The Other Extensions NC30 includes the following extended function for embedding assembler description inline pragma ASM pragma ENDASM Function Specifies assembly code in C Syntax pragma ASM assembly statements pragma ENDASM Description The line s between pragma ASM and pragma ENDASM are output without modify ing anything to the generated assembly source file Rules Writing pragma ASM be sure to use it in combination with pragma ENDASM NC30 suspends processing if no pragma ENDASM is found the corresponding pr agma ASM In assembly language description do not write statem
269. n This option specifies that the double type be handled in 32 bit data length as is the float type Note 1 For this option to be used a function prototype must always be expressly written Without a prototype declaration the compiler may not be able to gen erate the correct code 2 When you specify this option the debug information of the type double is pro cessed as the type float So the data of the type double is displayed as the type float on C watch window and global window of Debug tool PDXX and PDXXSIM fno switch table fNST Function When this option is specified the code which branches since it compares is generated to a switch statement In the entry version this option cannot be specified Supplement Only when code size becomes smaller when not specifying this option the code which used the jump table is generated Appendix A 40 Appendix A Command Option Reference fmake_vector_table fMVT Function Automatically generates the variable interrupt vector table Supplement The variable interrupt table is automatically generated based on the interrupt vector number and interrupt handling function name specified in pragma IN TERRUPT see Appendix B 7 Format of pragma INTERRUPT pragma INTERRUPTAinterrupt vector numberAinterrupt handling function name oragma INTERRUPTAinterrupt handling function name vect interrupt vector number The generated interrupt vector table is stored in the r
270. n vector 45 or user or MR30 word dummy in vector 46 or user or MR30 word dummy in vector 47 or user or MR30 word dummy in vector 48 word dummy in vector 49 word dummy in vector 50 word dummy in vector 51 word dummy in vector 52 word dummy in vector 53 word dummy in vector 54 word dummy in vector 55 word dummy in vector 56 word dummy in vector 57 word dummy in vector 58 word dummy in vector 59 word dummy in vector 60 word dummy in vector 61 word dummy in vector 62 I word dummy in vector 63 else MT section NC rvector ROMDATA Lorg VECTOR_ADR endif MVT__ if MST 0 fixed vector section section svector ROMDATA specialpage vector table org SVECTOR ADR Special page defination macro is defined in ncrt0 a30 Format SPECIAL number SPECIAL 255 SPECIAL 254 SPECIAL 253 SPECIAL 252 SPECIAL 251 SPECIAL 250 s SPECIAL 249 SPECIAL 248 SPECIAL 247 i SPECIAL 246 SPECIAL 245 SPECIAL 244 i SPECIAL 243 j SPECIAL 242 SPECIAL 241 SPECIAL 240 SPECIAL 239 i SPECIAL 238 SPECIAL 237 SPECIAL 236 SPECIAL 235 SPECIAL 234 Figure 2 15 Startup Program List 10 sect30 inc 4 11 NC30 MANUAL 31 Chapter 2 Basic Method for Using the Compiler i SPECIAL 233 SPECIAL 232 SPECIAL 231 SPECIAL 230 SPECIAL 229 A SPECIAL 228 SPECIAL 227 SPECIAL 226 SPECIAL 225 SPECIAL 224 j SPECIAL 223 j SPECIAL 222 SPECIAL 221
271. n flag indicating error or EOF Table E 15 Stream Information Stream information Name stdin Standard input stdout Standard output stderr Standard error output error is output to stdout stdaux Standard auxiliary I O stdprn Standard printer output The stream corresponding to the NC30 standard library functions shown shaded in Figure E 3 are fixed to standard input stdin and standard output stdout The stream cannot be changed for these functions The output direction of stderr is defined as stdout in define The stream can only be changed for functions that specify pointers to the stream as parameters such as fgetc and fputc Appendix E 88 Appendix E Standard Library vfprintf Figure E 3 Relationship of Functions and Streams Figure E 4 shows the stream definition in stdio h Appendix E 89 Appendix E Standard Library x standard 1 0 header file omitted typedef struct iobuf char buff Store buffer for ungetc int cnt Strings number in buff 1 or 0 int flag Flag int mod Mode int func in voi d Pointer to one byte input function int func out int Pointer to one byte output function define _ OBUF_DEF omitted extern FILE iob define
272. n for once in program execution However the functions which are called only indirectly require the user s at tention because such functions are indicated to have been called 0 times Appendix G 7 Appendix G The SBDATA declaration SPECIAL Page Function declaration Utility utl30 Wstdout Function Outputs error and warning messages to the host machine s standard output stdout Execution 1130 o sample ncrt0 x30 Wstdout example M16C 60 UTILITY UTL30 for M16C 80 V X XX XX COPYRI GHT C XXXX XXXX RENESAS TECHNOLOGY CORPORATION ALL RIGHTS RESERVED AND RENESAS SOLUTIONS CORPORATION ALL RIGHTS RESERVED warning cannot open file ncrt0 x30 Sp lt number gt Specifying numbers not be used as SPECIAL Page Function number option Function Specifies numbers not to be used as SPECIAL Page Function numbers Execution Te if ingl ber Sane To specify a single number SP lt number gt Example utl30 sp30 sp 255 ncrt0 x30 To specify two or more numbers SP lt number gt lt numbers Example utl30 sp30 sp 255 254 ncrt0 x30 To specify a range of numbers SP lt number gt number Example utl30 sp 255 250 ncrt0 x30 Appendix G 8 Appendix G The SBDATA declaration amp SPECIAL Page Function declaration Utility utl30 fsection Outputs SBDATA declaration and SPECIAL page function declaration in 2pragma SECTIONS Function The variables and funct
273. nc tion in the same way that functions written in C would be The first label in an assembler function must be preceded by an underscore _ However when calling the assembly function from the C program the underscore is omitted The calling C program must include a prototype declaration for the assembler function Figure 3 11 is an example of calling assembler function asm_func extern void near asm_func void Assembler function prototype declaration void mai n omitted asm func Calls assembler function Figure 3 11 Example of Calling Assembler Function Without Parameters smp1 c glb main main omitted jsr asm f unc Calls assembler function preceded by rts Figure 3 12 Compiled result of smp1 c smp1 a30 NC30 MANUAL 66 Chapter 3 Programming Technique b When assigning arguments to assembler functions When passing arguments to assembler functions use the extended function pragma PARAMETER This pragma PARAMETER passes arguments to assembler functions via 32 bit general purpose registers R2RO R3R1 A1A0 16 bit general purpose registers RO R1 R2 R3 or 8 bit general purpose registers ROL ROH R1L R1H and address registers AO A1 The following shows the sequence of operations for calling an assembler function using pragma PARAMETER 1 Write a prototype declaration for the assembler function before the pragma PA RAMETER declaration You must a
274. nc voi d me called within main return i extern int i void main void int s s func s func Notle The assembler code to description of substance of the static function which became inline function treatment is always generated About a function it is compulsorily In treating as an inline function it is in a function Please make an inline declaration Appendix A 24 Appendix A Command Option Reference Oforward function to inline OFFTI Function Supplement Notle Expands all inline functions in line In the entry version this option cannot be specified Although inline functions require that an inline function be declared before its entity definition can be made use of this option allows the entity definition of an inline function to be made before declaring it 1 When specifying inline storage class for a function be sure that inline storage class and this body definition is written in the same file as the function is written 2 The parameter of an in line function cannot be used by structure and union It becomes a compile error 3 The indirect call of an in line function cannot be carried out It becomes a compile error when a indirect call is described 4 The recursive call of an in line function cannot be carried out It becomes a compile error when a recursive call is described Oglb jmp OGJ Function Global jump is opt
275. nclude assembly language routines asm functions in your C source programs The asm function also has extended functions for manipulating the m and x flags and referencing variables written in C Overview of asm Function The asm function is used for including assembly language code in a C source program As shown in Figure B 16 the format of the asm function is asm where an assembly language instruction that conforms to the AS30 language specifications is included be tween the double quote marks pragma ADDRESS ta0 int 55H char 80 int void func abbreviated taO_int 0x07 lt Permits timer AO interrupt asm FSETI Sets interrupt enable flag Figure B 16 Example of Description of asm Function 1 2 Compiler optimization based on the positional relationship of the statements can be partially suppressed using the code shown in Figure B 17 asm Figure B 17 Example of Coding asm Function 2 2 The asm function used in NC30 not only allows you to include assembly language code but also has the following extended functions Specifying the FB offset of storage class auto variables in the C program using the names of the variables in C 6 Specifying the register name of storage class register variables in the C program using the names of the variables in C Specifying the symbol name of storage class extern and static variables in the C program using the names of the variables in C The following sho
276. nded Functions Reference pragma BITADDRESS The bit position specification absolute address allotment function of an input and output variable Function Syntax Description Rules Example A variable is assigned to the bit position which the specified absolute address specified pragma BITADDRESSAvariable nameAbit position absolute address The absolute address specified in this declaration is expanded as a character string in an assembler file and defined in pseudo instruction BITEQU The format for writing the numerical values therefore depends on the assembler as follows O A o N The bit position itis the range of 0 65535 Only the decimal digit The Address Append B or b to binary numbers Append O or o to octal numbers Write decimal integers only Append H or h to hexadecimal numbers If the number starts with letters A to F precede it with O Only a Bool type variable can be specified to be a variable name It becomes an error when variables other than _Bool type are specified All storage classes such as extern and static for variables specified in pragma BITADDRESS are invalid Variables specified in pragma BITADDRESS are valid only for variables defined outside the function pragma BITADDRESS is valid for previously declared variables pragma BITADDRESS is invalid if you specify other than a variable error occurs if a pragma BI
277. ned value The function specified by pragma HANDLER cannot use a returned value Delete the return value handler function has argument The function specified by pragma HANDLER is using an argument gt The function specified by pragma HANDLER cannot use an argument Delete the argument hex character is out of range The hex character in a character constant is ex cessively long Also some character that is not a hex representation is included after V Reduce the length of the hex character identifier member name is dupli cated this declare ignored The member name is defined twice or more This declaration will be ignored Make sure that member names are declared only once identifier variable name is duplicate 6 The variable name is defined twice or more This declaration will be ignored Make sure that variable names are declared only once identifier variable name is shad owed 6 The auto variable which is the same as the name declared as an argument is used Use any name not in use for arguments Appendix F 26 Appendix F Error Messages Table F 25 ccom30 Warning Messages 5 10 Warning message Description and countermeasure illegal storage class for argument extern ignored An invalid storage class is used in the argument list of function definition 55 Specify the correct storage class incompatible pointer types
278. nesting parentheses Depends on amount of available memory Number of initial values that can be defined when defining variables with initialization expres Depends on amount of available memory sions Maximum number of levels of nesting modifier declarators Depends on stack size of YACC Maximum number of levels of nesting declarator parentheses Depends on stack size of YACC Maximum number of levels of nesting operator parentheses Depends on stack size of YACC Maximum number of valid characters per internal identifier or macro name Depends on amount of available memory Maximum number of valid characters per external identifier Depends on amount of available memory Maximum number of external identifiers per source file Depends on amount of available memory Maximum number of identifiers with block scope per block Depends on amount of available memory Maximum number of macros per source file Depends on amount of available memory Maximum number of parameters per function call and per function Depends on amount of available memory Maximum number of parameters or macro call parameters per macro 3imax Maximum number of characters in character string literals after concatenation Depends on amount of available memory Maximum size in bytes of object Depends on amount of available memory Maximum number of members per structure union Depends on amount of available memory Maximum number of enumerator constants per enumerator Depends on amount of available memory Maximum
279. ng type integer and calculates the remainder O qsort Sorts elements in an array O rand Generates a pseudo random number O srand Imparts seed to a pseudo random number generating rou O tine Appendix E 15 Appendix E Standard Library i Character String Value Convert Functions The following lists character string value convert functions Table E 10 Character String Value Convert Functions Function Contents Reentrant atof Converts a character string into a double type floating O point number atoi Converts a character string into an int type integer O atol Converts a character string into a long type integer O strtod Converts a character string into a double type integer O strtol Converts a character string into a long type integer O strtoul Converts a character string into an unsigned long type O integer j Multi byte Character and Multi byte Character String Manipulate Functions The following lists Multibyte Character and Multibyte Character string Manipulate Func tions Table E 11 Multibyte Character and Multibyte Character String Manipulate Functions Function Contents Reentrant mblen Calculates the length of a multibyte character string O mbstowcs Converts a multibyte character string into a wide char O acter string mbtowc Converts a multibyte character into a wide character O wcstombs Converts a wide character string into a multibyte char O
280. noiera aaia 22 2 2 1 Sample ot Start p PrOQELdiicz s escono rooted tem estere eve teet pee 22 2 2 2 Customizing the Startup PEOQGFalm s ceci corte rni inei eene tbe 39 a Overview of Startup Program Processing xi accidet case rabo Spice petes t Udo eet 39 b Modiiving the Startup Progr aliis speci ost eser vea co RD SER e tee ee ae a 40 NC30 MANUAL IV 3 2 3 3 c Examples of startup modifications that require caution ssssssssssssss 40 1 Settings When Not Using Standard I O Functions eessssesssssss 40 2 Settings When Not Using Memory Management Functions 41 3 Notes on Writing Initialization Programs siisii annesini 41 d lie Stack Section SAE e echec ra cendo mida cci men eiie oie sd tu Ras Fel esa its 42 6 Heap Sehon SZE uerai d uio aet ba sod EIE 42 k Setingthe intesrupt Vector table 42 g Seting the Processor Mode Register 2 iiit cheated cones tone docebat festa tipa eot ados pos 43 2 2 8 Customizing for NC30 Memory Mapping eeeeeeenennneeneneennnn 44 a Ol SSCHOMS ER UP SEU ERIS EH 44 b Qutline or memory mapping setup fle 1 1 tmt rettet etr nN E 47 G Moding THE IG s uo ener eoim PE Hes 47 d Mapping and Order Sections and Specifying Starting Address
281. not be specified fenable register fER Make register storage class available fno_align Does not align the start address of the function In the entry version this option cannot be specified fUSRW None Changes the default instruction for calling functions to JSR W fbit fB Generates code assuming that bitwise manipulat ing instructions can be executed using absolute ad dressing for all external variables mapped into the near area fno_carry INC Suppresses carry flag addition when data is indi rectly accessed using far type pointers fauto_128 fA1 Limits the usable stack frame to 128 byte fuse DIV fUD This option changes generated code for divide op eration In the entry version this option cannot be specified finfo None Outputs the information required for the Inspector STK Viewer Map Viewer and utl30 In the entry version this option cannot be specified fswitch other section fSOS This option outputs a ROM table for a switch state ment to some other section than a program section fchange bank always fCBA This option allows you to write multiple variables to an extended area fauto over 255 fAO2 Changes the stack frame size per function that can be reserved to 64 Kbytes ferase static function fESF If the function specified by this option is a static function name function name function no codes are generated for that functio fdouble 32
282. ns When returning values from an assembler function to a C language program registers can be used through which to return the values for the integer pointer and floating point types Table 3 2 lists the rules on calls regarding return values Figure 3 16 shows an example of how to write an assembler function to return a value Table 3 2 Calling Rules for Return Values Return value type Rules Bool type ROL register char type int type RO register near pointer type float type The 16 low order bits are stored in the RO register and the 16 high long type order bits are stored in the R2 register as the value is returned far pointer type double type The value is stored in 16 bits each beginning with the MSB in order of long double type registers R3 R2 R1 and RO as it is returned long long type The value is stored in 16 bits each beginning with the MSB in order of registers R3 R1 R2 and RO as it is returned Compound type Immediately before calling the function the far address indicating the area for storing the return value is pushed to the stack Before the return to the calling program the called function writes the return value to the area indicated by the far address pushed to the stack SECTION program GLB _asm_func _asm_func omitted MOV W 01000H R2 32 bit data MOV W 0A00H RO RTS END Figure 3 16 Example of Coding Assembler Function to Return long type R
283. ns any value other than 0 if a numeral Returns 0 if not a control character Description Determines the type of character in the parameter isdigit Character Handling Functions Function Checks whether the character is a numeral 0 9 Format include ctype h int isdigit Method macro Argument int c Character to be checked ReturnValue amp Returns any value other than 0 if a numeral Returns 0 if not a numeral Description Determines the type of character in the parameter Appendix E 38 Appendix E Standard Library isgraph Character Handling Functions Function Checks whether the character is printable except a blank 0x21 0x7e Format include lt ctype h gt int isgraph c Method macro Argument int c Character to be checked ReturnValue Returns any value other than 0 if printable Returns 0 if not printable Description Determines the type of character in the parameter islower Character Handling Functions Function Checks whether the character is a lower case letter a z Format include lt ctype h gt int islower c Method macro Argument Character to be checked ReturnValue Returns any value other than 0 if a lower case letter Returns 0 if not a lower case letter Description Determines the type of character in the parameter Appendix E 39 Appen
284. nter to the first memory area to be compared NC308 only const void far s2 Pointer to the second memory area to be compared const void s2 Pointer to the second memory area to be compared NC308 only size tn Number of bytes to be compared Return Value 0 The two memory areas are equal Return Value gt 0 The first memory area 51 is greater than the other Return Value lt O The second memory area 52 is greater than the other Compares each of n bytes of two memory areas When you specify options O OR or OS the system may selects another functions with good code efficiency by optimization Appendix E 49 Appendix E Standard Library memcpy Memory Handling Functions Function Copies n bytes of memory Format include lt string h gt void far memcpy s1 52 n void memocpy 51 52 n NC308 only Method function Argument void far s1 Pointer to the memory area to be copied to const void far 2 Pointer to the memory area to be copied from Size tn Number of bytes to be copied ReturnValue Returns the pointer to the memory area to which the characters have been copied Description Copies n bytes from memory S2 to memory S1 When you specify options O OR or OS the system may selects another functions with good code efficiency by optimization memicmp Memory Handling Functions Function Compares memory areas with alpha
285. ntil IR is ON voi d while TAOIC IR 0 Waits for TAOIC IR to become 1 TAOIC IR 0 Returns 0 to TAOIC IR when it becomes 1 M Please compile after taking the following measures if the manipulation in structions is generated to bit operation of SFR area Make sure that no BTSTC and BTSTS instructions are generated after these side steppings 9 Optimization options other than O5 are used An instruction is directly described in a program using an ASM function Appendix A 17 Appendix A Command Option Reference OR Function Optimizes ROM size in preference to speed This option can be specified with g and O options In the entry version this option cannot be specified Supplement When this option is used the source line information may partly be modified in the course of optimization Therefore if this options is specified when your program is running on the debugger your program is a possibility of different actions If you do not want the source line information to be modified use the One_break_source_debug ONBSD option to suppress optimization OS Function Although the ROM size may somewhat increase optimization is performed to obtain the fastest speed possible This option can be specified along with the g option In the entry version this option cannot be specified Appendix A 18 Appendix A Command Option Reference Oconst OC Function
286. number of levels of nesting of structures or unions per struct declaration list Depends on amount of available memory Maximum number of characters per character string Depends on operating system Maximum number of lines per file Depends on amount of available memory Appendix C 3 Appendix C Overview of C Language Specifications C 2 Standard Language Specifications The chapter discusses the NC30 language specifications with the standard language specifications C 2 1 Syntax This section describes the syntactical token elements In NC30 the following are pro cessed as tokens e Key words Identifiers Constants Character literals Operators e Punctuators Comment a Key Words NC30 interprets the followings as key words Table 6 6 Key Words List asm default int switch far do long typedef hear double near union asm else register unsigned auto enum restrict void Bool extern return volatile break far short while case float signed inline char for sizeof const goto static continue if struct In the entry version the keywords listed below are not handled as keywords near far inline asm When using these keywords add the underscore before the first character of each keyword used near far inline asm b Identifiers Identifiers consist of the following elements The ist character is a letter or the underscore A to Z atoz or e The 2nd and subs
287. ny product data diagrams charts programs algorithms or circuit application examples contained in these materials All information contained in these materials including product data diagrams charts programs and algorithms represents information on products at the time of publication of these materials and are subject to change by Renesas Technology Corporation and Renesas Solutions Corporation without notice due to product improvements or other reasons It is therefore recommended that customers contact Renesas Technology Corporation Renesas Solutions Corporation or an authorized Renesas Technology product distributor for the latest product information before purchasing a product listed herein The information described here may contain technical inaccuracies or typographical errors Renesas Technology Corporation and Renesas Solutions Corporation assume no responsibility for any damage liability or other loss rising from these inaccuracies or errors Please also pay attention to information published by Renesas Technology Corporation and Renesas Solutions Corporation by various means including the Renesas home page http www renesas com When using any or all of the information contained in these materials including product data diagrams charts programs and algorithms please be sure to evaluate all information as a total system before making a final decision on the applicability of the information and products Renesas Technology
288. ny variable written in C language can be used in the asm function by writing it in the format shown in Figure B 32 asm op code variable name Figure B 32 Description Format Not Dependent on Variable s Storage Class You can only specify one variable name using this format Figure B 33 shows examples of referencing register variables and the results of compiling C source file extern int e val extern variable void func void int f val auto variable register int r val register variable static int s val static variable Reference to external variable Reference to auto variable Reference to register variable Reference to static variable 1 e val 2 f val 3 r val 4 s val f_val r_val m amp amp Assembly language source file compile result glb func enter 02H line 10 C_SRC asm mov w 1 e_val JHHHE ASM START mov w 31 e val Reference to external variable line 11 18 40 9 asm mov w 2 val mov w 2 2 FB lt Reference to auto variable line 12 8 40 9 asm mov w 3 r_val mov w 3 RO val lt Reference to register variable line 13 C_SRC asm mov w 4 Q s val mov w 44 50 s val lt Reference to static variable H 40 9 asm mov w f_val r_val mov w 2 FB RO f val r val JHHHE ASM END Figure B 33 Example for R
289. o processing occurs if you specify other than a function name 5 No error occurs if you duplicate pragma CYCHANDLER declarations 6 A compile warinig occurs if you use any function specified in one of the following declarations in pragma CYCHANDLER 6 pragma INTERRUPT e pragma INTHANDLER e pragma HANDLER e pragma ALMHANDLER e pragma TASK Example include lt mr30 h gt include Aq pragma CYCHANDLER cyc void cyc void Be sure to declare as type void omitted Figure B 79 Example of pragma CYCHANDLER Declaration Appendix B 54 Appendix B Extended Functions Reference pragma INTHANDLER pragma HANDLER Function Declares an MR30 OS dependent interrupt handler Syntax 1 pragma INTHANDLERAinterrupt handler name 2 pragma HANDLERAinterrupt handler name Description By using the above format to declare an interrupt handler a function written in C NC30 generates the code for the handling shown below to be used at the entry and exit points of the function 1 At the entry point Push i e save the registers onto the current stack 2 At the exit point Returns from the interrupt with the ret int system call Also re turns from the interrupt by the ret_int system call when returning at a return statement partway through the function To declare an MR30 OS independent interrupt handler use pragma INTERRUPT You canNOT write interrupt handlers that take parameters The
290. om preprocesser Compiler ccom30 nc30 command option P Assembly S language source file Assembler nc30 command option Absolute nc30 command module file option Relocatable object file Linker Stack size calculation utility stk SBDATA definition amp SPECIAL Page Function definition STK Viewer utility StkViewer Stack utilization SBDATA SPECIAL Page calculation definition file Function result file definition file 2 output file of nc30 Figure 1 5 Relationship of nc30 Command Line Options and Output Files NC30 MANUAL 7 Chapter 1 Introduction to NC30 include lt stdio h gt define CLR 0 define PRN 1 void main int flag flag CLR ifdef PRN printf flag d n flag endi f Figure 1 6 Example C Source File smp c 1 5 2 Preprocessed C Source Files The cpp30 processes preprocess commands starting with Such operations include header file contents macro expansion and judgements on conditional compiling The C source files output by the preprocessor include the results of cpp30 processing of the C source files Therefore do not contain preprocess lines other than pragma and line You can refer to these files to check the contents of programs processed by the compiler The file extension is i Figures 1 7 and 1 8 are examples of file output typedef struct iobuf char buff int cnt int flag int mod int
291. ompiler If the version numbers in the Release Notes do not match those displayed us ing this option the package may not have been installed correctly See the M3T NC30WA Guide for details of how to install the NC30 package 1 Use uppercase V for this option 2 If you specify this option all other options are ignored Appendix A 11 Appendix A Command Option Reference A 2 4 Options for Debugging Table A 4 shows the command line options for outputting the symbol file for the C source file Table A 4 Options for Debugging Option Function g Outputs debugging information to an assembler source file extension a30 Therefore you can perform C language level debugging genter Always outputs an enter instruction when calling a function Be sure to specify this option when using the debugger s stack trace function In the entry version this option is always enabled i e assumed to be specified Therefore it cannot be enabled or disabled by specifica tion gno_reg Suppresses the output of debugging information for register variables In the entry version this option cannot be specified gold outputs debugging information for old version debuggers and third party debuggers In the entry version this option cannot be specified Outputting debugging information Function Outputs debugging information to an assembler source file extension a30 Execution nc30 g v sample c examp
292. on this option cannot be specified Supplement This option suppresses the following optimization Optimization for replacing the standard library functions such as strcpy and memopy with the SMOVF instructions etc 9 Optimization for changing to the library functions that conform to the arguments near and far Notes Specify this option when make a function which name is same as standard library function Osp adjust OSA Function Optimizes code generation by combining stack correction codes after function calls In the entry version this option cannot be specified Supplement Because the area for arguments to a function normally is deallocated for each function call made processing is performed to correct the stack pointer If this option is specified processing to correct the stack pointer is performed collec tively rather than for each function call made Example In the example shown below the stack pointer is corrected each time func1 and then func2 is called so that the stack pointer is correcte twice If this option is specified the stack pointer is corrected only once int func18 int int int func2 int void main void int i 1 int j 2 int k k funcl i j n func2 k Notes Use of the option Osp adjust helps to reduce the ROM capacity and at the same time to speed up the processing However the amount of stack used may increase Appendix A
293. on prototype function before The non prototyped function is redefine proto type declaration Unite ways to declare function type redefined type 6 Redwfine typedef Check typedef redefined type name of qualify The same identifier is defined twice or more in typedef Write identifier correctly register parameter function used before as stack parameter function The function for register argument is used as a function for stack argument before Write a prototype declaration before using the function Appendix F 29 Appendix F Error Messages Table F 28 ccom30 Warning Messages 8 10 Warning message Description and countermeasure RESTRECT qualifier can set only pointer type e The RESTRICT qualifier is declared outside a pointer Declare it in only a pointer section name interrupt no more used The section name specified by pragma SEC TION uses interrupt A section name interrupt cannot be used Change it to another sorry get stack s address but DT not 0 NC77 NC79 only This error occurs when the bank option is speci fied When the address of an auto variable is assigned to a pointer and an object referenced using that pointer DT points to outside bank 0 preventing bank 0 from being referenced Declare the variable as a far type size of incomplete type An undefined structure or union is used in the
294. onsecutive ORs together Ono asmpot ONA Inhibits starting the assembler optimizer aopt30 Ostatic to inline OSTI A static function is treated as an inline function Oforward function to inline Expands all inline functions in line Oglb jmp OGJ Global jump is optimized Effect of each Optimization Options Option O OR OS OSA OSFA SPEED faster lower faster faster faster ROM size decrease decrease increase decrease same usage of stack decrease same same increase increase Appendix A 15 Appendix A Command Option Reference O 1 5 Function Optimizes speed and ROM size to the maximum This option can be specified with g options O3 is assumed if you specify no numeric no level In the entry version this option cannot be specified O1 Makes O3 Ono bit Ono break source debug Ono float const fold and Ono stdlib valid O2 Makes no diffrence with O1 O3 Optimizes speed and ROM size to the maximum O4 Makes O3 and Oconst valid O5 Effect the best possible optimization in common subexpressions if the option OR is concurrentlyspecofied effects the best possible optimization in transfer and comparison of character strings if the option OS is concurrently specified However a normal code may be unable to be outputted when fulfilling the following conditions 9 With a different variable points out the same memory posi
295. op code H1 variable name Figure B 26 Description Format for Specifying Symbol Name Only two variable name can be specified by using this description format The following types are supported for variable names e Variable name 6 Array name integer Struct name member name not including bit field members int idata int a 3 struct TAG int i int k 5 void func asm MOV W RO idata asm RO a 2 asm MOV W RO s i Remainder omitted Figure B 27 Description example for specifying FB offset See Figure B 28 for examples of referencing extern and static variables Appendix B 15 Appendix B Extended Functions Reference 6 C source file extern int ext val extern variable func static int s_val static variable asm mov w 01H ext_val asm mov w 4Z01H s val Assembly language source file compile result glb func line 8 SRC asm mov w 01H ext_val 1888 ASM START mov w 401 ext val Move to ext val line 9 H C_SRC asm mov w 01H s_val mov w 01H 580 s val 90 s val 1848 ASM END line 12 1840 SRC rts SECTION bss NE DATA 50 s val 3HHE C s name is 5 val blkb 2 glb ext val ext val blkb 2 END Figure B 28 Example of Referencing extern and static Variables You can use the format shown in Figure B 29 to use 1 bit bit fields of
296. operating mode 6 Initializes the stack pointer ISP Register and USP Register 6 Initializes SB register 6 Initializes INTB register 6 Initializes the data near area bss NE bss NO bss SE and bss SO sections are cleared to 0 Also the initial values in the ROM area data NEI data NOI data SEI data SOI are transferred to RAM data NE data NO data SE and data SO Initializes the data far area bss FE and bss FO sections are cleared to 0 Also the initial values in the ROM area data data FOI storing them are transferred to RAM data FE and data FO Initializes the heap area Initializes the standard function library Initializes FB register Calls the main function NC30 MANUAL 39 Chapter 2 Basic Method for Using the Compiler b Modifying the Startup Program Figure 2 23 summarizes the steps required to modify the startup programs to match the target system Set the size of stack sections Set the size of heap sections oee Set the interrupt base register Set the processor operating mode ourocioes 2 2 3 Customizing Memory Allocations Figure 2 23 Example Sequence for Modifying Startup Programs c Examples of startup modifications that require caution 1 Settings When Not Using Standard I O Functions The init function initializes the M16C 60 Series I O It is called before main in ncrt0 a30 Figure 2 24 shows the part where
297. operation contains an error Check the expressions on the left and right sides of the operator Appendix F 14 Appendix F Error Messages Table F 14 ccom30 Error Messages 7 14 Error message Description and countermeasure invalid gt gt operands The gt gt operation contains an error Check the expressions on the left and right sides of the operator invalid operands The left side expression of is not array type or pointer type Use an array or pointer type to write the left side expression of invalid z operands The operation contains an error Check the expressions on the left and right sides of the operator invalid operands The operation contains an error Check the expressions on the left and right sides of the operator invalid operands The operation contains an error Check the expressions on the left and right sides of the operator invalid operands The operation contains an error Check the expressions on the left and right sides of the operator invalid operands The unary operator or postfix operator con tains an error gt For the unary operator check the right side ex pression For the postfix operator check the left side expression invalid operands The unary operation or postfix operation con tains an error For the unary ope
298. operator is used for an inline function the software assumes an error See Figure B 58 int func int i return i int f int amp func Error Message Error ccom smp c line 10 can t get inline function s address by amp operator f amp func Sorry compilation terminated because of these errors in mai n Figure B 58 Example of inappropriate code of inline function 3 6 Declaration of static data If static data is declared in an inline function the body of the declared static data is allocated in units of files For this reason if an inline function consists of two or more files this results in accessing different areas Therefore if there is static data you want to be used in an inline function declare it outside the function If a static declaration is found in an inline function NC30 generates a warning Renesas does not recommend entering static declarations in an inline function See Figure B 59 inline int func int j static int i 0 itt return i j Warning Message Warning ccom smp c line 3 static valuable in inline function gt static int i 0 Figure B 59 Example of inappropriate code of inline function 4 7 Regarding debug information NC30 does not output C language level debug information for inline functions Therefore you need to debug inline functions at the assembly language level Appendix B 31 Appendix B Extended Functions Referenc
299. or Messages Table F 10 ccom30 Error Messages 3 14 Error message Description and countermeasure can t set argument The type of an actual argument does not match prototype declaration The argument cannot be set in a register argument Correct mismatch of the type case value is duplicated The value of case is used more than one time gt Make sure that the value of case that you used once is not used again within one switch state ment conflict declare of variable name The variable is defined twice with different stor age classes each time Use the same storage class to declare a variable twice conflict function argument type of variable name The argument list contains the same variable name Change the variable name declared register parameter function s body declared The function body for the function declared with pragma PARAMETER is defined in C Do not define in C the body for such function default function argument conflict The default value of an argument is declared more than once in prototype declaration Make sure that the default value of an argument is declared only once default is duplicated The default value is used more than one time Use only one default within one switch statement do while struct union statement The struct or union type is used in the expression of the do while statement Use
300. or declaring the default arguments of a function Appendix B 25 Appendix B Extended Functions Reference main line 5 8 40 SRC func mov w 0002H R2 lt second argument mov w 0001H R1 first argument jer func line 6 8 40 SRC func 3 mov w 0002H R2 second argument mov w 0003H R1 first argument jer func line 7 8 40 SRC func 3 5 mov w 0005H R2 second argument mov w 0003H R1 first argument jer func add b 02H SP line 8 40 SRC rts omitted Note In NC30 arguments are stacked in revere order beginning with the argument that is declared last in the function In this example arguments are passed via regis ters as they are processed Figure B 48 Compiling Result of smp1 c smp1 a30 A variable can be written for the argument of a function Figure B 49 shows an example where default arguments are specified with variables Figure B 50 shows a compile result of the sample program shown in Figure B 49 int near sym int func int i sym lt Default argument is specified with a variable void main void func lt Function is called using variable sym as argument omitted Figure B 49 Example for specifying default argument with a variable smp2 c main line 6 mov w sym R1 lt Function is called using variable sym as argument jer func line 7 rts Figure B 50 Compile Result of smp2 c smp2 a30 Appendix B 26 Appendix B Extended
301. ore A function once used is declared in pragma IN TERRUPT An interrupt function cannot be called Check the content of pragma too big octal character 6 The character constant or the octal constant in the character string exceeded the limit value 255 in decimal Do not use a value greater than 255 to describe the constant too few parameters 6 Arguments are insufficient compared to the num ber of arguments declared in prototype declara tion Check the number of arguments too many parameters Arguments are excessive compared to the num ber of arguments declared in prototype declara tion Check the number of arguments uncomplete struct member An incomplete structure is written as a member Write a complete structure unknown pragma STRUCT xxx 6 pragma STRUCTxxx cannot be processed This line will be ignored Write correctly unknown debug option dx 6 The option dx cannot be specified 55 Specify the option correctly unknown function option Wxxx The option Wxxx cannot be specified Specify the option correctly unknown function option fx 6 The option fx cannot be specified Specify the option correctly unknown function option gx 6 The option gx cannot be specified Specify the option correctly unknown optimize option mx The option mx cannot be specified Specify the option corr
302. ored ReturnValue Returns the number of stored multibyte characters if the character string was converted correctly Returns 1 if the character string was not converted correctly Appendix E 82 Appendix E Standard Library wctomb Multi byte Character Multi byte Character String Manipulate Functions Function Converts a wide character into a multibyte character Format include lt stdlib h gt int wctomb s wchar Method function Argument char far s Pointer to an area for storing conversion multibyte character string wchar t wchar wide character ReturnValue 6 Returns the number of bytes contained in the multibyte characters Returns 1 if there is no corresponding multibyte character 9 Returns 0 if the wide character is 0 Appendix E 83 Appendix E Standard Library E 2 4 Using the Standard Library a Notes on Regarding Standard Header File When using functions in the standard library always be sure to include the specified standard header file If this header file is not included the integrity of arguments and return values will be lost making the program unable to operate normally b Notes on Regarding Optimization of Standard Library If you specify any of optimization options O 3 5 OS or OR the system performs optimization for the standard functions This optimization can be suppressed by specifying Ono stdlib Such suppression of optimization is necessary when you use a
303. orted pragma Wno stop WNS Prevents the compiler stopping when an error occurs Wstdout None Outputs error messages to the host machine s standard output stdout Werror file file name WEF Outputs error messages to the specified file Wstop at warning WSAW Stops compiling the source files if a warning occurs dur ing compiling and returns the compiler end code 10 Wnesting comment WNC _ Outputs a warning for a comment including Wccom max warnings WCMW This option allows you to specify an upper limit for the Warning Count number of warnings output by ccom30 Wall None Displays message for all detectable warnings however not including alarms output by Wlarge to small and Wno used argument Wmake tagfile WMT _ Outputs error messages to the tag file of source file by source file Wuninitialize variable WUV Outputs a warning about auto variables that have not been initialized Wlarge to small WLTS Outputs a warning about the tacit transfer of variables in descending sequence of size Wno warning stdlib WNWS Specifying this option while Wnon prototype or Wall is specified inhibits Alarm for standard libraries which do not have prototype declaration Wno used argument WNUA Outputs a warning for unused argument of functions Wno used static function WNUSF For one of the following reasons a static function name is output that does not require code generation Wno used fun
304. ote For the upper limit count of warning outputs specify a number equal to or greater than 0 Specification of this count cannot be omitted When you specify 0 warning outputs are completely suppressed inhibited Appendix A 49 Appendix A Command Option Reference Wall Warning option Function Note Displays message for all detectable warnings however not including alarms output by Wlarge_to_small WLTS Wno_used_argument WNUA and Wno_used_static_function WNUSF which are displayed with the Wnon_pr ototype WNP and Wunknown_pragma WUP options and in the following cases 1 and 2 Note that these warnings are not all coding errors because they are the compiler s inference Case 1 When the assignment operator is used in the if statement the for statement or a comparison statement with the amp amp or operator Example if i 0 func Case 2 When is written to which should be specified Example i 0 Case 3 When function is defined in old format Example func i int i omitted These alarms are detected within the scope that the compiler assumes on its judgment that description is erroneous Therefore not all errors can be alarmed Wmake_tagfile WMT Function Supplement Outputs error messages to the tag file of source file by source file when an error or warning occurs This option with Werror_file lt file name gt i WEF option canit specify
305. other function 7 Mathematical Functions Functions for calculating sines sin and cosines cos etc These functions require time Therefore pay attention to the use of the watchdog timer 8 Integer Arithmetic Functions Functions for performing calculations on integer values 9 Character String Value Convert Functions Functions for converting character strings to numerical values 10 Multi byte Character and Multi byte Character String Manipulate Functions Functions for processing multi byte characters and multi byte character strings 11 Locale Functions Locale related functions Appendix E 10 Appendix E Standard Library E 2 2 List of Standard Library Functions by Function a String Handling Functions The following lists String Handling Functions Table E 2 String Handling Functions Type Function Contents Reentrant Copy strcpy Copies a character string strncpy Copies a character string n characters Concatenate strcat Concatenates character strings O strncat Concatenates character strings n characters O Compare strcmp Compares character strings strcoll Compares character strings using locale information O stricmp Compares character strings All alphabets are O handled as upper case letters strncmp Compares character strings n characters O strnicmp Compares character strings n characters All al O phabets are handled a
306. oto is not defined in the function Define the jump address label in the function union or enum s tag used for struct The tag name for union and enumerated types is used as a tag name for structure Change the tag name unknown function argument vari able name An argument is specified that is not included in the argument list Check the argument unknown member member name used A member is referenced that is not registered as any structure or union members Check the member name unknown pointer to structure identifier variable name The left side expression of gt is not the structure or union type Use struct or union as the left side expression of gt unknown size of struct or union A structure or union is used which has had its size not determined Declare the structure or union before declaring a structure or union variable unknown structure identifier vari able name The left side expression of dose not have struct or union Use the struct or union as it unknown variable variable name used in asm An undefined variable name is used in the asm statement Define the variable unknown variable variable name An undefined variable name is used Define the variable unknown variable variable name used An undefined variable name is used Define the variable void array is invalid type int ar
307. padding if the total size of the members is odd Figure D 5 is an example of mapping Example pragma STRUCT TAG zi unpack struct TAG char 8 int i padding address higher Figure D 5 Example of Placement of Structure 2 2 D 1 7 Unions Unions occupy an area equal to the maximum data size of their members Figure D 6 is an example of mapping Example union TAG char Cc int T 4 bytes size of lo long lo address higher Figure D 6 Example of Placement of Union Appendix D 4 Appendix D C Language Specification Rules D 1 8 Bitfield Types Bitfield types are mapped from the least significant bit Figure D 7 is an example of mapping Example E char b1 1 char b2 1 char b3 1 char b4 1 char b5 1 char b6 1 char b7 1 s Figure D 7 Example of Placement of Bitfield 1 2 If a bitfield member is of a different data type it is mapped to the next address Thus members of the same data type are mapped contiguously from the lowest address to which that data type is mapped Example struct BTAG char 00 1 char 1 char b2 1 char b3 1 char b4 1 int b56 2 char b7 1 Js address higher Figure D 8 Example of Placement of Bitfield 2 2 Note f no sign is specified the default bitfield member type is unsigned Can not specifies bit fields of long long type Appendix D 5 D 2 D 3 DSA Appendix
308. pecifications f Jump statement Use the format of jump statement shown in Figure C 12 goto identifier continue break return expression p opt indicates optional items Figure C 12 Format of Jump Statement g Assembly Language Statement Use the format of assembly language shown in Figure C 13 asm Literals literals assembly language statement Figure C 13 Format of Assembly Language Statement Appendix C 15 C 3 3 Appendix C Overview of C Language Specifications Preprocess Commands Preprocess commands start with the pound sign and are processed by the cpp30 preprocessor This chapter provides the specifications of the preprocess commands List of Preprocess Commands Available Table C 13 lists the preprocess commands available in NC30 Table C 13 List of Preprocess Commands Command Function define Defines macros undef Undefines macros include Takes in the specified file error Outputs messages to the standard output device and terminates pro cessing line Specifies file s line numbers assert Outputs a warning when a constant expression is false pragma Instructs processing for NC30 s extended function if Performs conditional compilation ifdef Performs conditional compilation ifndef Performs conditional compilation elif Performs conditional compilation else Performs conditional compilation endif Performs condit
309. pecified regardless volatile qualified 9 This option is only valid if you specify option 3 to 5 or OR or OS Appendix A 19 Appendix A Command Option Reference Ono_break_source_debug ONBSD Function Suppresses optimization that affects source line data In the entry version this option cannot be specified Supplement Specifying the OR or O option performs the following optimization which may affect source line data This option ONBSD is used to suppress such optimization Notes This option is valid only when the OR or O option is specified Ono float const fold ONFCF Function Suppresses the constant folding processing of floating point numbers In the entry version this option cannot be specified Supplement By default NC308 folds constants Following is an example before optimization val 1000e250 50 0 after optimization val 20e250 M w In this case if the application uses the full dynamic range of floating points the results of calculation differ as the order of calculation is changed This option suppresses the constant folding in floating point numbers so that the calcula tion sequence in the C source file is preserved Appendix A 20 Appendix A Command Option Reference Ono stdlib ONS Function Suppresses inline padding of standard library functions modification of library functions and similar other optimization processing In the entry versi
310. pecifier correctly not have long float Type specifiers long and float are simultaneously used Write the type specifier correctly not have long short Type specifiers long and short are simulta neously used Write the type specifier correctly not static initializer for variable name The initialize expression of static variable con tains an error This is because the initialize ex pression is a function call for example Write the initialize expression correctly not struct or union type The left side expression of gt is not the structure or union type Use the structure or union type to describe the left side expression of redeclare of variable name An variable name has been declared twice Change the name for either of the two variable name redeclare of enumerator An enumerator has been declared twice Change the name for either of the two enumera tors redefine function function name The function indicated by function name is de fined twice The function can be defined only once Change the name for either of the two functions redefinition tag of enum tag name An enumeration is defined twice Make sure that enumeration is defined only once redefinition tag of struct tag name A structure is defined twice Make sure that a structure is defined only once redefinition tag of union tag name
311. pending the letter L or The type is determined from the value in the following order Octal and hexadecimal signed long unsigned long signed long long unsigned long long eDecimal signed long long unsigned long long 3 long type constants Specify long long type constants by appending the letter LL or Il The type is deter mined from the value in the following order Octal and hexadecimal signed long long unsigned long long eDecimal signed long long Appendix C 5 Appendix C 2 Floating point constants If nothing is appended to the value floating point constants are handled as double types To have them processed as float types append the letter F or f after the value If you append L or they are treated as long double types 3 Character constants Character constants are normally written in single quote marks as in character You can also include the following extended notation escape sequences and trigraph se quences Hexadecimal values are indicated by preceding the value with x Octal values are indicated by preceding the value with Overview of C Language Specifications Table C 8 Extended Notation List Notation Escape sequence Notation Trigraph sequence Y single quote constant octal M quotation mark Wconstant hexadecimal M backslash X express character question mark W express character a bell 7 express character b backspace T ex
312. perands The operation contains an error Check the expressions on the left and right sides of the operator invalid amp amp operands The amp amp operation contains an error Check the expressions on the left and right sides of the operator invalid amp operands The amp operation contains an error Check the expression on the right side of the operator invalid amp operands The amp operation contains an error Check the expressions on the left and right sides of the operator Appendix F 13 Appendix F Error Messages Table F 13 ccom30 Error Messages 6 14 Error message Description and countermeasure invalid operands The expression on the left side of is not a function Write a function or a pointer to the function in the left side expression of invalid operands 6 If multiplication the operation contains an error If is the pointer operator the right side expres sion is not pointer type For a multiplication check the expressions on the left and right sides of the operator For a pointer check the type of the right side expression invalid operands 6 The operation contains an error Check the expressions on the left and right sides of the operator invalid operands The operation contains an error Check the expressions on the left and right sides of the operator
313. pile driver starts the compiler commands cpp30 and ccom30 the as semble command as30 and the link command In30 to create a absolute module file The following information input parameters is needed in order to start nc30 1 C source file s 2 Assembly language source file s 3 Relocatable object file s 4 Command line options optional These items are specified on the command line Figure 2 1 shows the command line format Figure 2 2 is an example In the example the following is performed 1 Startup program ncrt0 a30 is assembled 2 C source program sample c is compiled and assembled 3 Relocatable object files ncrt0 a30 and sample r30 are linked The absolute module file sample x30 is also created The following command line options are used Specifies machine language data file sample x30 0 Specifies output of list file extension Ist at assembling as30 I Specifies output of map file extension map at linking In30 ms NC30 MANUAL 12 Chapter 2 Basic Method for Using the Compiler nc30A command line option A assembly language source file name A relocatable object file name A C source file name 96 Prompt lt gt Mandatory item Optional item A Space Figure 2 1 nc30 Command Line Format nc30 osample as30 I In30 ms ncrt0 a30 sample c lt RET gt lt RET gt Return key Always
314. press character f form feed express character n line feed M express character r return gt express character t horizontal tab 71 express character W vertical tab N express character d Character Literals Character literals are written in double quote marks as in character string The ex tended notation shown in Table C 8 for character constants can also be used for character literals Appendix C 6 Appendix C Overview C Language Specifications e Operators NC30 can interpret the operators shown in Table C 9 Table C 9 Operators List monadic operator He logical operator amp E 1 binary operator conditional operator 3 comma operator address operator amp pointer operator bitwise operator lt lt assignment operators gt gt rm amp E x E amp relational operators gt lt gt lt lt lt gt gt sizeof operator sizeof f Punctuators NC30 interprets the followings as punctuators 9 9 ej e e g Comment Comments are enclosed between and 3 They cannot be nested Comments are enclosed between and the end of line Appendix C 7 Appendix C Overview of C Language Specifications C 2 2 Type a Data Type NC30 supports the following data type
315. processing U predefined macro Undefines the specified predefined macro silent Suppresses the copyright message display at startup dsource Short form dS Generates an assembly language source file extension a30 with a C language source list output as a comment Not deleted even after assembling dsource_in_list Short form dSL In addition to the dsource function generates an assembly lan guage list file Ist 1 If you do not specify command line options c E P or S nc30 finishes at and output files up to the absolute load module file extension x30 are created Appendix A 2 Appendix A Command Option Reference C Compile driver control Function Creates a relocatable object file extension r30 and finishes processing Execution T nc30 c sample c example wi6c 60 NC30 COMPILER V X XX Release X COPYRIGHT C XXXX XXXX RENESAS TECHNOLOGY CORPORATION ALL RIGHTS RESERVED AND RENESAS SOLUTIONS CORPORATION ALL RIGHTS RESERVED sample c Is sample rWer r 1 toolusr 2835 Aug 17 11 28 sample c Peres 1 toolusr 450 Aug 17 11 28 sample 320 2 Notes fthis option is specified no absolute module file extension x30 or other file output by In30 is created Didentifier Compile driver control Function The function is the same as the preprocess command define Delimit multiple identifiers with spaces Syntax nc
316. ption 6 You specified options greater than 100 characters for 8530 or In30 Reduce the options to 99 characters or less Invalid argument 6 This error message is not normally displayed It is an internal error OContact Renesas Solutions Corp Invalid option 6 The required parameter was not specified in option Specify the required parameter after You specified a space between the option and its parameter Delete the space between the option and its param eter Invalid option o 6 No output filename was specified after the o option Specify the name of the output file Do not specify the filename extension Appendix F 2 Appendix F Error Messages Table 2 nc30 Error Messages 2 2 Error message Description and countermeasure Invalid suffix xxx 6 You specified a filename extension not recognized by NC30 other than c i a30 r30 x30 Specify the filename with the correct extension No such file or directory The processing system will not run Check that the directory of the processing system is correctly set in the environment variable Not enough core UNIX Insufficient swap area Increase the swap area by for example adding a sec ondary swap area MS Windows 95 98 NT Insufficient swap area Increase the swap area Permission denied The processing system will not run
317. r 26 0 9 4 Usage of predefined Macros 00 eeceeecessceeseeceseeeeeeeeaeeseaeeeseeseaeeeaeeseaeeseeeseaeeseaeeeaeeeaees 26 Appendix D C Language Specification Rules Nu Dl Internal Representation of Dalai iater borde E 1 51 1 integral TYPE sevens titt Osee ite tme ba trabe ene 1 D 1 2 Floating TY OG Gute niet nest eta 2 DS Enutmefalor Typene 3 Didi Pointer Type 3 Bits Array Ty Pes 3 D 1 6 Structure types uiu RO o D REEL ELLE Legat eie ESAS 3 Di7 UNIONS Gubiandwneenia 4 Doke NB o pp 5 D2 Sigm Extension BUleS a c Edi ui I d oe 6 DS Function 6 D 3 1 RULES Of Return Valle Ret Erie rte utere dete ibt 6 3 2 Rules on Argument 8 518 5 7 D 3 3 Rules for Converting Functions into Assembly Language Symbols 8 D 3 4 Interface between toe Est ctp 11 D 4 Securing auto Variable Aea siioni nesin entente nenne 14 Appendix E Standard Library RN E1 Standard Header ma ocn ic V nici 1 E
318. r st Pointer to the character string to be divided up const char far s2 Pointer to the punctuation character to be divided with ReturnValue Returns the pointer to the divided token when character is found Returns NULL when character cannot be found Description In the first call returns a pointer to the first character of the first token A NULL character is written after the returned character In subsequent calls when s1 is NULL this instruction returns each token as it is encountered NULL is returned when there are no more tokens in s1 When you specify options O OR or OS the system may selects another functions with good code efficiency by optimization Appendix E 76 Appendix E Standard Library strtol Character String Value Convert Function Function Converts a character string into a long type integer Format include lt string h gt long strtol s endptr base Method function Argument const char far s Pointer to the converted character string char _far _far endptr Pointer to the remaining character strings that have not been converted int base Base of values to be read in 0 to 36 Reads the format of integral constant if the base of value is zero ReturnValue ReturnValue OL Does not constitute a number 9 ReturnValue OL Returns the configured number in long type Description amp When you specify options O OR or OS the system may sel
319. r type when manipulating the character string You therefore cannot manipulate them as 2 byte characters To process the Japanese as 2 byte characters precede the character string with L and process it as a pointer type to a wchar t type wchar t types are defined typedef as unsigned short types in the standard header file stdlib h Figure B 41 shows an example of a Japanese character string include lt stdlib h gt void func wchar t JC 4 L XEF 1 remainder omitted Figure B 41 Example of Japanese Character Strings Description Figure B 42 is a memory map of the character string initialized in 1 in Figure B 41 higher Figure B 42 Memory Location of wchar_t Type Character Strings Appendix B 23 Appendix B Extended Functions Reference B 3 4 Using Japanese Characters as Character Constants Figure B 43 shows the format for using Japanese characters as character constants Figure B 43 Format of Kanji code Description in Character Strings As with character strings precede the character constant with L and process it as a wchar t type If as in 3 you use two or more characters as the character constant only the first character becomes the character constant Figure B 44 shows examples of how to write Japanese character constants include lt stdlib h gt void near func wchar_t JC 5 JC 0 L X Je 1 2 L JC 2 L 7 JC 3 L 2 remainder omit
320. ragma SPECIAL func vect 20 pragma SPECIAL func vect 30 X Call number 30 is effective 5 If functions are defined in one file and function calls are defined in another file be sure to write this declaration in both files 6 If the option R8C is used this declaration is ignored Example pragma SPECIAL 20 func void func unsigned int unsigned int void main int i j i Ox7FFD j 0x007F func i j lt special page subroutine call Figure B 77 Example of pragma SPECIAL Declaration 1 f you are using the supplied startup file modify the contents of the fvector section For details of how to modify the startup file see Chapter 2 2 Modifying the Startup Program in the Operation part of the NC30 User s Manual Appendix B 52 Appendix B Extended Functions Reference B 7 4 Using MR30 Extended Functions NC30 has the following extended functions which support the real time operating system MR30 pragma ALMHANDLER Function Declares an MR30 alarm handler Syntax pragma ALMHANDLERAalarm handler name Description By using the above format to declare an alarm handler a function written in C NC30 generates the code for the alarm handler to be used at the entry and exit points of the function The alarm handler is called from the system clock interrupt by the JSR instruction and returns by the RTS or EXITD instruction Rules You canNOT write alarm handlers that take parameters
321. rary Modifying Standard Library The NC30 package includes a sophisticated function library which includes functions such as the scanf and printf I O functions These functions are normally called high level l O functions These high level I O functions are combinations of hardware dependent low level I O functions In M16C 60 series application programs the I O functions may need to be modified ac cording to the target system s hardware This is accomplished by modifying the source file for the standard library This chapter describes how to modify the NC30 standard library to match the target system The entry vedrsion does not come with source files for the standard function library Therefore the standard function library cannot be customized for the entry version Structure of I O Functions As shown in Figure E 1 the I O functions work by calling lower level functions level 2 level 3 from the level 1 function For example fgets calls level 2 fgetc and fgetc calls a level 3 function Only the lowest level 3 functions are hardware dependent I O port dependent in the Micro Processor If your application program uses an I O function you may need to modify the source files for the level 3 functions to match the system Input function Output function Figure E 1 Calling Relationship of I O Functions Appendix E 85 Appendix E Standard Library E 3 2 Sequence of Modifying I O Functions Figure
322. rator check the right side ex pression For the postfix operator check the left side expression invalid gt used The left side expression of gt is not struct or union The left side expression of gt must have struct or union invalid s condition The ternary operator is erroneously written Check the ternary operator Invalid pragma OS Extended function interrupt number The INT No in Zpragma OS Extended function is invalid 9Specify correctly Invalid pragma INTCALL interrupt number The INT No in pragma INTCALL is invalid 9Specify correctly Invalid 2pragma SPECIAL page number The No in pragma SPECIAL is invalid 9Specify correctly invalid CAST operand The cast operation contains an error The void type cannot be cast to any other type it can neither be cast from the structure or union type nor can it be cast to the structure or union type Write the expression correctly Appendix F 15 Appendix F Error Messages Table F 15 ccom30 Error Messages 8 14 Error message Description and countermeasure invalid asm s argument The variables that can be used in asm state ments are only the auto variable and argument Use the auto variable or argument for the state ment invalid bitfield declare 6 The bit field declaration contains an error Write the declaration correctly invalid brea
323. ray assumed An array cannot be declared as void Processing will be continued assuming it has type int Write the type specifier correctly Appendix F 21 Appendix F Error Messages Table F 21 ccom30 Error Messages 13 13 Error message Description and countermeasure void value can t return The value converted to void by cast is used as the return from a function Write correctly while struct union statement struct or union is used in the expression of a while statement Use scalar type while void statement 6 void is used in the expression of a while state ment Use scalar type multiple pragma EXT4MPTR s pointer ignored A pointer variable decleared by pragma EXT4MPTR is duplecate Declare the variable only one time zero size array member the array which size is zero Declare the array size The structure members include an array whose size is zero Arrays whose size is zero cannot be members of a structure function name is resursion then inline is ignored The inline declared function name is called re cursively The inline declaration will be ignored Correct the statement not to call such a function name recursively Appendix F 22 Appendix F Error Messages F 6 ccom30 Warning Messages Tables F 21 to F 30 list the ccom30 compiler warning messages and their countermeasures Table
324. ray initializer in the manner shown below the compiler will process the function assuming that it will be referen ced eventhough it may not actually be referenced during program executi on Example void a 5 void f1 f2 f3 f4 f5 for i 0 i lt 3 i a i In the above example although functions f4 and f5 are not referenced the compiler processes these functions assuming that they will be referenced Wno used function WNUF Warning option Function Displays unused global functions when linking This option must be specified along with the finfo option In the entry version this option cannot be specified Appendix A 53 Appendix A Command Option Reference Wundefined_macro WUM Function Warns you that undefined macros are used in if Wstop at link WSAL Function Stops linking the source files if a warning occurs during linking to suppress generation of absolute module files Also a return value 10 is returned to the host OS Appendix A 54 Appendix A Command Option Reference A 2 9 Assemble and Link Options Table A 9 shows the command line options for specifying as30 and In30 options Table A 9 Assemble and Link Options Option Function as30A lt option gt Specifies options for the as30 link command If you specify two or more options enclose them in double quotes In the entry version this option cannot be specified IN30A lt option gt Specifies options for the
325. re 1021 sented as a double type floating point numeric value FLT DIG Maximum number of digits of float type decimal precision 6 FLT EPSILON Minimum positive value where 1 0 FLT EPSILON is 1 19209290e 07F found not to be 1 0 FLT MANT DIG Maximum number of digits in the mantissa part when a float type floating point value is matched to the radix in its representation 24 FLT MAX Maximum value that a float type variable can take on as value 3 40282347e438F FLT MAX 10 EXP Maximum value of the power of 10 that can be represented as a float type floating point numeric value 38 FLT MAX EXP Maximum value of the power of the radix that can be repre 128 sented as a float type floating point numeric value FLT_MIN Minimum value that a float type variable can take on as 1 17549435e 38F value FLT MIN 10 EXP Minimum value of the power of 10 that can be represented 37 as a float type floating point numeric value FLT MIN EXP Maximum value of the power of the radix that can be repre 125 sented as a float type floating point numeric value FLT_RADIX Radix of exponent in floating point representation 2 FLT ROUNDS Method of rounding off a floating point number 1 Rounded to the nearest whole number Appendix E 3 limits h Appendix E Standard Library Function Defines the limitations applying to the internal processing of the compiler The following lis
326. re included the variables are mapped between 0 and 01FFFH Example pragma BIT bit data struct bit data char bi char char char char char char char bit data C C C C C C C o C Un 5 CO L3 c rm rp PP Pr ee func void bit data bitl 0 omitted Figure B 62 Example Declaration of pragma BIT Note 1 bit instructions are generated under the following either conditions 1 When a fbit fB option is specified and the object to be operated on is a near type variable 2 When the object to be operated on is a variable declared by pragma SBDATA 3 When the object to be operated on is a variable declared by pragma ADDRESS and the variable is located somewhere between address 0000 to address 01FFF 4 When the object to be operated on is a variable declared by pragma BIT 5 Variables mapped to areas within 32 bytes of the value of the FB register Appendix B 37 Appendix B Extended Functions Reference pragma ROM Function Maps specified data variable to rom section Syntax pragma ROMAvariable_name Description This extended function is valid only for variables that satisfy one or other of the follow ing conditions 1 Non extern variables defined outside a function Variables for which an area is se cured 2 Variables declared as static within the function Rules 1 If you specify other than a variable it will be ignored 2 No error occurs if you
327. red is smaller than that freed the area is secured from the high address of the contiguously empty area created by free toward the low address Heap area Freed area Unused area Unused area Unused area 1 2 If the amount of memory to be secured is larger than that freed the area is secured from the lowest address of the unused memory toward the high address Heap area Freed area malloc Freed area Unused area Unused area Appendix E 46 Appendix E Standard Library malloc 2 lf no memory area has been freed with free 2 1 If there is any unused area that can be secured the area is secured from the lowest address of the unused memory toward the high address Heap area Unused area Unused area Unused area High 2 2 there is no unused area that can be secured malloc returns NULL without any memory being secured Note No garbage collection is performed Therefore even if there are lots of small unused portions of memory no memory is secured and malloc returns NULL unless there is an unused portion of memory that is larger than the specified size mblen Multi byte Character Multi byte Character String Manipulate Functions Function Calculates the length of a multibyte character string Format include lt stdlib h gt int mblen s n Method function
328. reserved to 64 Kbytes Note 1 This option cannot be used in combination with pragma SBDATA If a file that contains a description of pragma SBDATA is compiled the warning shown below is output with the description of pragma SBDATA ignored Warning ccom XX c line XX compile option fauto over 255 is specified pragma SBDATA was ignored gt pragma SBDATA xxx 2 Specify this option for the files described below a When a function exists that requires a stack frame of 255 bytes or more hereafter referred to as function A gt Files in which function A is written b When an interrupt occurs while processing function A hereafter referred to as interrupt A and a variable declared by pragma SBDATA is accessed from interrupt A gt Files in which interrupt A is written ferase_static_fucntion function_name fESF tunction name Function If the function specified by this option is a static function no codes are generated for that functio In the entry version this option cannot be specified Example nc30 fESF func1 fESF func2 test c lt ret gt If the functions func1 and func2 are static functions no codes are gene rated for those functions Supplement When you specify this option on HEW HEW outputs the following warning Please ignore this warning gt The Library field is empty Input a library name in the field Appendix A 39 Appendix A Command Option Reference fdouble 32 fD32 Functio
329. return value from the interrupt handler must be type void in the declaration Do NOT use the ret_int system calls from C Only the function definition put after p gt ragma INTHANDLER are valid No processing occurs if you specify other than a function name No error occurs if you duplicate pragma INTHANDLER declarations A compile warinig occurs if you use any function specified in one of the following declarations in pragma INTHANDLER e pragma INTERRUPT e pragma HANDLER e pragma ALMHANDLER e pragma CYCHANDLER pragma TASK Rules NO 5 WD Example include lt mr30 h gt include lg ht pragma INTHANDLER hand void hand void omitted ret int Figure B 80 Example of pragma INTHANDLER Declaration Appendix B 55 Appendix B Extended Functions Reference pragma TASK Function Declares an MR30 task start function Syntax pragma TASKAtask start function name Description By using the above format to declare a task start function written in C NC30 generates the code for processing for the task shown below to be used at the exit points of the function At the exit point Ends by the ext_tsk system call Also returns using the ext_tsk system call even when returning at a return statement part way through function Rules 1 You need not put the ext_tsk system call to return from the task 2 The return value from the task must be type void in the declaratio
330. ria dede de Poza 28 B 5 2 Declaration Format of inline Storage Class ssssseseeeeneeeeeen 28 B 5 3 Restrictions on inline Storage Class sesseeeeeeeeenneenenennennene 30 Bio Extension Of GOIYITIGnts uite sister tote dece Sa Dr d RR INe e epa Ue Ki RES 32 B 6 1 Overview or 7 COMMONS siio cam creer deck ui posito cae perdet exe isa accrue ear eva deel 32 B62 Comment V ree 32 B 6 3 Priority OF alid V seer ed AE 32 B 7 pragma Extended FUNCOMS a Rae 33 B 7 1 Index f 1 15 33 a Using Memory Mapping Extended Functions 33 b Using Extended Functions for Target Devices criaria 34 Using MRSO Extended FUNCHONS etie co ea ates 35 d The Other Extensions 3 o a SEIL RU RE REDE cedes 36 B 7 2 Using Memory Mapping Extended Functions ccccecseeeseneeseseceeseceeeeeseeeneneceneeeees 37 7 8 Using Extended Functions for Target Devices iim etim ees 44 B 7 4 Using MRS30 Extended F rictiolis oiii t err reti tette ies 53 The Other Extensions aei lei baie
331. rnValue ReturnValue 0 The two character strings are equal 9 ReturnValue gt 0 The first character string s1 is greater than the other 9 Return Value O The second character string 52 is greater than the other Description Compares each byte of two character strings ending with NULL When you specify options O OR or OS the system may selects another functions with good code efficiency by optimization strcoll String Handling Functions Function Compares character strings using locale information Format include lt string h gt int strcoll 51 s2 Method function Argument const char _far s1 Pointer to the first character string to be compared const char _far s2 Pointer to the second character string to be compared ReturnValue ReturnValue 0 The two character strings are equal 9 ReturnValue gt 0 The first character string s1 is greater than the other 9 ReturnValue lt 0 The second character string s2 is greater than the other Description When you specify options O OR or OS the system may selects another functions with good code efficiency by optimization Appendix E 68 Appendix E Standard Library strcpy Function Copies a character string Format include lt string h gt char far strcpy s1 52 Method function Argument char far s1 Pointer to the character string to be copied to const char far s2 Pointer to the character string to be copied from
332. rns x exp power of 2 Idiv Integer Arithmetic Functions Function Format Method Argument Divides a long type integer and calculates the remainder include lt stdlib h gt Idiv_t Idiv number denom function long number Dividend long denom Divisor ReturnValue Returns the quotient derived by dividing number by denom and the remainder of the division Description amp Returns the quotient derived by dividing number by denom and the remainder of the division in the structure ldiv t 0 div t is defined in stdlib h This structure consists of members long quot and long rem Appendix E 43 Appendix E Standard Library localeconv Localization Functions Function Initializes struct Iconv Format include lt locale h gt struct Iconv _far localeconv void Method function Argument argument used ReturnValue Returns a pointer to the initialized struct Iconv log Mathematical Functions Function Calculates natural logarithm Format include lt math h gt double log x Method function Argument double X arbitrary real number ReturnValue Returns the natural logarithm of given real number x Description This is the reverse function of exp Appendix E 44 log10 Appendix E Standard Library Mathematical Functions Function Format Method Argument ReturnValue Calculates com
333. rocessor s entire memory space by intb register relative addressing For more information refer to the Micro Processor User s Manual fvector This section stores the contents of the Micro Processor s fixed vector program Stores programs program_S Stores programs for which pragma SPECIAL has been specified switch_table The section to which the branch table for switch statements is allocated This section is generated only with the fSOS option NC vector This section is generated when an interrupt vector table number is speci fied by pragma INTERRUPT NC svector Stores vector for which pragma SPECIAL has been specified These sections are mapped to memory according to the settings in the startup pro gram include file sect30 inc You can modify the include file to change the mapping NC30 MANUAL 45 Chapter 2 Basic Method for Using the Compiler Figure 2 29 shows the how the sections are mapped according to the sample startup program s include file sect30 inc 000000H E OF0000H J 7 1 000400H data SE section d bss SE section a data SEI section data SO section l 2 data SOI section bss SO section data_NE section data NEI section bss NE section data NO 5 data NOI section bss NO section 3 5 T data FEI section p stack section lt D o 0 data FOI section lt 0 fat 0 010000H B data FE section 3 3 program_S section bss FE section r 9
334. rs input from the stream as specified in format and stores them in the variables shown in the arguments Argument must be a pointer to the respective variable Interprets code 0x1A as the end code and ignores any subsequent data Format is specified in the same way as in scanf fwrite Input Output Functions Function Outputs the specified items of data to the stream Format include lt stdio h gt size_t fwrite buffer size count stream Method function Argument const void far buffer Pointer of the output data Size t size Number of bytes in one data item Size t count Maximum number of data items FILE far stream Pointer of the stream ReturnValue Returns the number of data items output Description Outputs data with the size specified in size to the stream Data is output by the number of times specified in count Interprets code 0x1A as the end code and ignores any subsequent data f an error occurs before the amount of data specified in count has been input this function returns the number of data items output to that point Appendix E 34 Appendix E Standard Library getc Input Output Functions Function Reads one character from the stream Format include lt stdio h gt int getc stream Method macro Argument FILE far stream Pointer of stream ReturnValue Returns the one input character Returns EOF if an error or the end of the stream is encountered
335. s 16 K Localization FUNCIONS cxcossssaics iode maanisia tusateelondecasascasdaaatted an ie eeso las bte epi pies 16 E23 Standard Function 17 E 2 4 Using the Standard 84 a Not s on Regarding Standard Header File erret trt hene entes 84 b Notes on Regarding Optimization of Standard Library ccccccscceeseeeeeesteeeeneeees 84 nline padding of MONCTON Six acus riori Haz cep 84 2 Selection of high speed library NCSO only 2 orit ai citt rar itat 84 Madifyind Standard EIBFE aa 85 E 3 1 Sru ture oi VO UN CtONS 85 E 3 2 Sequence of Modifying I O Functions 86 a Modifying Level 3 VO Funch rerien a rr E NENS 86 b pe E E N 88 c Incorporating the Modified Source Program eese 94 F i F 2 F 3 F 4 F 5 F 6 Message Foll alii 1 NESO Emor MESSAGES 2 CHps0 Error MESSAGSS ore ce Roos densae n e E pne 4 cppaD Warning Messages deii esie d ce rt ru inu ede to Ones e Fas 8 cecom30 Error Messages EUR 9 coomao Warning 8658
336. s Function Allocates a memory area and initializes it to zero 0 Format include lt stdlib h gt void far calloc n size Method function Argument Size tn Number of elements size_t size Value indicating the element size in bytes ReturnValue Returns NULL if a memory area of the specified size could not be allocated Description After allocating the specified memory it is cleared to zero The size of the memory area is the product of the two parameters Rule The rules for securing memory are the same as for malloc ceil Mathematical Functions Function Calculates an integer carry value Format include lt math h gt double ceil x Method function Argument double x arbitrary real number ReturnValue Returns the minimum integer value from among integers larger than given real number x Appendix E 23 Appendix E Standard Library clearerr Input Output Functions Function Initializes clears error status specifiers Format include lt stdio h gt void clearerr stream Method function Argument FILE far stream Pointer of stream ReturnValue amp No value is returned Description Resets the error designator and end of file designator to their normal values COS Mathematical Functions Function Calculates cosine Format include lt math h gt double cos x Method function Argument double X
337. s unsigned int sha w signed char count unsigned int val When calculated in 16 bits unsigned long sha l signed char count unsigned long val When calculated in 24 bits o F Function The value of val is returned after logically shifting it as many times as indicated by count Syntax include lt asmmacro h gt unsigned char shl b signed char count unsigned char val When calculated in 8 bits unsigned int shl w signed char count unsigned int val When calculated in 16 bits unsigned long shl l signed char count unsigned long val When calculated in 24 bits UJ o Function absolute Syntax include lt asmmacro h gt signed char abs b signed char val When calculated in 8 bits signed int abs w signed int val When calculated in 16 bits Appendix B 67 NEG Appendix B Extended Functions Reference Function Syntax NOT negate include lt asmmacro h gt signed char neg_b signed char val When calculated in 8 bits signed int neg_w signed int val When calculated in 16 bits Function Syntax not include lt asmmacro h gt signed char not_b signed char val When calculated in 8 bits signed int not w signed int val When calculated in 16 bits Appendix B 68 Appendix C Overview of C Language Specifications Appendix C Overview of C Language Specifications In addition to the standard versions of C ava
338. s auto are placed in the stack of the micro processor Fora C language source file like the one shown in Figure D 20 if the areas where variables of storage class auto are valid do not overlap each other the system allocates only one area which is then shared between multiple variables for i20 i 20 i process scope of i abbreviated for j OxFF j lt 0 j process scope of abbreviated for k 0 k lt 0 k process scope of k Figure D 20 Example of C Program In this example the effective ranges of three auto variables i j and k do not overlap so that a two byte area offset 1 from FB is shared Figure D 21 shows an assembly language source file generated by compiling the program in Figure D 20 FUNCTION func HHH FRAME AUTO k size 2 offset 2 HHH FRAME AUTO j size 2 offset 2 HHH FRAME AUTO i size 2 offset 2 section program file test1 c line 3 glb func enter 02H remainder omitted As shown by 1 2 and 8 the three auto variables share the FB offset 2 area Figure D 21 Example of Assembly Language Source Program Appendix D 14 Standard Librar E ET E 1 2 Appendix E Standard Library Standard Header Files When using the NC30 standard library you must include the header file that defines that function This appendix details the functions and specifications
339. s of the compiler programs then fin ishes processing without compiling d Options for Debugging Table 2 4 shows the command line options for outputting the symbol file for the C source file Table 2 4 Options for Debugging Option Function g Outputs debugging information to an assembler source file extension a30 Therefore you can perform C language level debugging genter Always outputs an enter instruction when calling a function Be sure to specify this option when using the debugger s stack trace function In the entry version this option is always enabled i e assumed to be specified Therefore it cannot be enabled or disabled by specification gno reg Suppresses the output of debugging information for register variables In the entry version this option cannot be specified gold outputs debugging information for old version debuggers and third party debuggers In the entry version this option cannot be specified NC30 MANUAL 16 Chapter 2 Basic Method for Using the Compiler e Optimization Options Table 2 5 shows the command line options for optimizing program execution speed and ROM capacity Table 2 5 Optimization Options Option Short form Function O 1 5 None Maximum optimization of speed and ROM size OR None Maximum optimization of ROM size followed by speed OS None Maximum optimization of speed followed by ROM size O
340. s on Transporting between NC Series Compilers 15 a Bitterencedndetault neatfar 5 p dern Sirac edo XE ger aeter ed rn eee Rr aep Sao e Fer Rhe Z5 A 1 A 2 A 3 ngo Command Format RR 1 n30 Command Ming OpuonS aaa ae e N a rd cree aa 2 A 2 1 Options for Controlling Compile Driver snrss siisii asine 2 A 2 2 Options Specifying Output Files sseseseeeeeeeeeneneenneeneeen ennemi 8 A 2 3 Version Information Display Option ssessseseeeeeeneneeneenneen nennen 10 A2 4 Options for Debuggilig i cr erect thc nest cubes ie si ipai Eas 12 A 2 5 Optimization OPI OMS is ci tees i 15 A 2 6 Generated Code Modification Options 26 A27 library Specifying OLOR ce eter de their t te Hb 43 A 2 9 Warning cerit Et Ee o 45 A29 ASsermble and ldink ODON Sic 55 Notes on Command Line Optom ieccsietce carccesssevarters 58 A 3 1 Coding Command Line ODtIOfIS icit erint cenicesaseceuatansedsuaeseuaensdssehdensacasaueasaaie 58 A 3 2 Priority OF Options for Controlling sissisodan 58 B 1 B 2 Near and far Meodiflers 2 5 esci y Eni e e Y e Pekp e EL ee Ed ER ed AREE EIE 2 B 1 1 Overview of near and far Modifiers
341. s returned Description lnitializes the stream Also calls speed and init prn in the function to make the initial settings of the UART and Centronics output device init is normally used by calling it from the startup program Appendix E 36 Appendix E Standard Library isalnum Character Handling Functions Function Checks whether the character is an alphabet or numeral A Z a z 0 9 Format include lt ctype h gt int isalnum c Method macro Argument Character to be checked ReturnValue amp Returns any value other than 0 if an alphabet or numeral 9 Returns 0 if not an alphabet nor numeral Description Determines the type of character in the parameter isalpha Character Handling Functions Function Checks whether the character is an alphabet A Z a z Format include ctype h int isalpha c Method macro Argument int c Character to be checked ReturnValue amp Returns any value other than 0 if an alphabet Returns 0 if not an alphabet Description Determines the type of character in the parameter Appendix E 37 Appendix E Standard Library iscntrl Character Handling Functions Function Checks whether the character is a control character Ox00 Ox1f 0x7f Format include lt ctype h gt int iscntrl c Method macro Argument int c Character to be checked ReturnValue Retur
342. s the assembler codes output by ccom30 In the entry version this option cannot be specified StkViewer amp stk StkViewer is the execution file for the utility that graphically shows the stack size and the relationship of function calls needed for program operation Also stk is the execution file for the utility that analyzes the information required for StkViewer StkViewer calls stk to process the Inspector information added to the absolute module file x30 find the stack size and the relationship of function calls needed for program operation and displays the result Also by specifying information if any that could not be fully analyzed with only the Inspector information StkViewer recalculates the stack size and the relationship of function calls and displays the result To use StkViewer amp stk specify the compile driver startup option finfo when compiling so that the Inspector information will be added to the absolute module file x30 In the entry version this option cannot be specified utl30 utl30 is the execution file for the SBDATA declaration utility and SPECIAL page Func tion declaration Utility By processing the absolute module file x30 utl30 generates a file that contains SBDATA declarations located in the SB area beginning with the most frequently used one and a file that contains SPECIAL page function declarations lo cated in the SPECIAL page area beginning with the most frequently used one
343. s upper case letters Search strchr Searches the specified character beginning with the O top of the character string strcspn Calculates the length number of unspecified charac O ters that are not found in the other character string strpbrk Searches the specified character in a character string O from the other character string strrchr Searches the specified character from the end of a O character string strspn Calculates the length number of specified characters O that are found in the other character string strstr Searches the specified character from a character O string strtok Divides some character string from a character string x into tokens Length strlen Calculates the number of characters in a character O string Convert strerror Converts an error number into a character string x strxfrm Converts a character string using locale information O Several standard functions use global variables that are specific to that function If while that function is called and is being executed an interrupt occurs and that same function is called by the interrupt processing program the global variables used by the function when first called may be overwritten This does not occur to global variables of functions with reentrancy indicated by a O in the table However if the function does not have reentrancy indicated by a X in the table care must be taken if the function is also used by an interrupt processing progr
344. sed by NC30 the extended rules for signs in operations etc and the rules for calling functions and the values returned by functions D 1 Internal Representation of Data Table D 1 shows the number of bytes used by integral type data D 1 1 Integral Type Table D 1 Data Size of Integral Type Type Existence of sign Bit size Range of values Bool No 8 0 1 char No 8 060255 unsigned char signed char Yes 8 1280127 int Yes 16 32768 332767 short signed int signed short unsigned int No 16 0265535 unsigned short long Yes 32 2147483648 lt 52147483647 signed long unsigned long 32 04294967295 long long Yes 64 9223372036854775808 lt signed long long 9223372036854775807 unsigned long long No 64 18446744073709551615 float Yes 32 1 17549435e 38F lt 93 40282347e 38F double Yes 64 2 2250738585072014e 308 long double 1 7976931348623157e 308 near pointer No 16 0 0xFFFF far pointer No 32 0 0xFFFFFFFF Ge The _Bool type can not specify to sign f a char type is specified with no sign it is processed as an unsigned char type 6 if an int or short type is specified with no sign it is processed as a signed int or signed short type If a long type is specified with no sign it is processed as a sign long type If a long long type is specified with no sign it is processed as a sign long long type 6 If the bit field members of a structure are spe
345. specify pragma ROM more than once 3 The data is mapped to a rom section with initial value 0 if you do not include an initialization expression Example C language source program pragma ROM i unsigned int i Variable i which satisfies condition 1 void func static int i 20 Variable i which satisfies condition 2 remainder omitted Assembly language source program section rom_NE ROMDATA C s name is Variable i which satisfies 50 condition 2 word 0014H glb d E Variable i which satisfies condition 1 byte 00H byte 00 M Figure B 63 Example Use of pragma ROM Declaration Note This facility is provided to maintain compatibility with NC77 and NC79 The variable normally must be located in the rom section using the const modifier Appendix B 38 Appendix B Extended Functions Reference pragma SBDATA Function Declares that the data uses SB relative addressing Syntax pragma SBDATAAvaluable name Description The M16C 60 series allows you to choose instructions that can be executed efficiently by using SB relative addressing pragma SBDATA declares that SB relative address ing can be used for the variable when referencing data This facility helps to generate ROM efficient code Rules The variable declared to be pragma SBDATA is declared by the assembler s pseudo instruction SBSYM 2 f pragma SBDATA is specified for anything other than a variable it
346. specify the startup program first when linking Figure 2 2 Example nc30 Command Line 2 1 2 Command File The compile driver can compile a file which has multiple command options written in it i e a command file after loading it into the machine Use of a command file helps to overcome the limitations on the number of command line characters imposed by Windows TM etc a Command file input format nc3s0A command line option A lt file name gt command line option A Prompt lt gt Mandatory item Optional item A Space Figure 2 3 Command File Command Line Format P nc30 c test cmd g lt RET gt lt RET gt Return key Always specify the startup program first when linking M Figure 2 4 Example Command File Command Line Command files are written in the manner described below ncrt0 a30 lt CR gt sample1 c sample2 r30 lt CR gt Command File description _ gt g as30 IcCR 0 lt CR gt sample lt CR gt lt CR gt Denotes carriage return Figure 2 5 Example Command File description NC30 MANUAL 13 Chapter 2 Basic Method for Using the Compiler b Rules on command file description The following rules apply for command file description Only one command file can be specified at a time You cannot specify multiple command files simultaneously No command file can be specified in another command file
347. ssed by specifying the ferase_static_function option no const in previous declaration The function or variable declaration without const qualification is const qualified on the entity defini tion side Make sure the function or variable declaration and the const qualification on the entity definition side are matched Appendix F 32 Appendix G G 1 G 1 1 The SBDATA declaration SPECIAL page Function declaration Utility utl30 The SBDATA declaration amp SPECIAL Page Function declaration Utility utl30 Appendix G How to startup the SBDATA declaration amp SPECIAL page function declaration utility utl30 and how the startup options works are described here This utility is not included in the entry version Introduction of utl30 Introduction of utl30 processes The SBDATA declaration amp SPECIAL page Function declaration Utility utl30 precesses the absolute module file hanving the extension x30 The utl30 generates a file that contains SBDATA declarations located in the SB area beginning with the most frequently used one i pragma SBDATAT and a file that contains SPECIAL page function declarations located in the SPECIAL page area beginning with the most frequently used one i pragma SPECIALT To use utl30 specify the compile driver startup option finfo when compiling so that the absolute module file x30 will be generated Figure G 1 illustrates the NC30 processing flo
348. sssssss 2 6 USO Erfor MessdgBS G61 Eror Messages TE G 6 2 Warrnirig Messad6eSs NC30 MANUAL X E a m rerace Glave NC30 is the C compiler for the Renesas M16C 60 M16C 30 M16C Tiny M16C 20 M16C 10 R8C Tiny Series NC30 converts programs written in C into assembly language source files for the M16C 60 M16C 30 M16C Tiny M16C 20 M16C 10 R8C Tiny Series You can also specify compiler options for assembling and linking to generate hexadecimal files that can be written to the microcomputer Please be sure to read the precautions written in this manual before using NC30 Terminology The following terms are used in the NC30 User Manuals Term Meaning NC30 Compiler package included in M3T NC30WA nc30 Compile driver and its executable file AS30 Assembler package included in M3T NC30WA as30 Relocatable macro assembler and its executable file TM Integrated development environment be attached to M3T NC30WA Professional version Professional use compiler for full scale programming Entry version Simplified compiler included in the starter kit etc Description of Symbols The following symbols are used in the NC30 manuals Symbol Description Root user prompt 96 UNIX prompt MS Windows TM prompt lt RET gt Return key lt gt Mandatory item Optional item Space or tab code mandatory
349. stdin amp iob 0 Fundamental input define stdout amp iob 1 Fundamental output define stdaux amp iob 2 Fundamental auxialiary input output define stdprn amp iob 3 Fundamental printer output define derr stdout FEX o EG EKEK KK I EO I EO KK KK EG Ee Ee Ee EKEK KRKK EKE K GGG KKK E K K ES EES EE ES EE EE define OREAD 1 Read only flag define OWRT 2 Write only ag define OE OF End of file flag define OERR Error flag define ORW Read and write flag define FILE Stream number define TEXT Text mode flag define Bl Binary mode flag remainder omitted Figure E 4 Stream Definition in stdio h Let s look at the elements of the file structures shown in Figure E 4 Items 1 to 6 correspond to 1 to 6 in Figure E 4 Appendix E 90 Appendix E Standard Library 1 char _ buff Functions scanf and fscanf read one character ahead during input If the character is no use function ungetc is called and the character is stored in this variable If data exists in this variable the input function uses this data as the input data 2 int Stores the _buff data count 0 or 1 S int _ flag Stores the read only flag IOREAD the write only flag the read write flag _IORW the end of file flag _IOEOF and the error flag IOERR _IOREAD _IOWRT IORW These flags specify the stream opera
350. ster is initialized after a reset and that it thereafter is used as a fixed register NC30 MANUAL 63 Chapter 3 Programming Technique pragma SBDATA val int val Figure 3 8 Example of variable declaration using SB based addressing mode f Compressing ROM Size Using Option fJSRW When calling a function defined outside the file in NC30 the function is called with the JSR A instruction However if the program is not too large most functions can be called with the JSR W instruction In this case ROM size will be reduced by doing as follows First Compile with the fUSRW option and check functions which are indicated as errors at link time Then change declarations for the error functions only into decla rations using pragma JSRA function name When you use the OGJ option the JMP instruction at the time of a link is chosen g Other methods In addition to the above the ROM capacity can be compressed by changing program description s as shown below 1 Chabge a relatively small function that is called only once to an inline function 2 Replace an if else statement with a switch statement This is effective unless the variable concerned is a simple variable such as an array pointer or structure 3 For bit comparison use amp or in place of amp amp or 4 For a function which returns a value in only the range of char type declare its return value type with char 5 For variables used ov
351. strcpy Copies a character string strncpy Copies a character string n characters Concatenate strcat Concatenates character strings strncat Concatenates character strings n characters Compare strcmp Compares character strings strcoll Compares character strings using locale information stricmp Compares character strings alphabets are handled as upper case letters strncmp Compares character strings n characters strnicmp Compares character strings n characters All alphabets are handled as upper case letters Search strchr Searches the specified character beginning with the top of the character string strcspn Calculates the length number of unspecified characters that are not found in the other character string strpbrk Searches the specified character in a character string from the other character string strrchr Searches the specified character from the end of a character string strspn Calculates the length number of specified characters that are found in the other character string strstr Searches the specified character from a character string strtok Divides some character string from a character string into tokens Length strlen Calculates the number of characters in a character string Convert strerror Converts an error number into a character string strxfrm Converts a character string using locale information Initialize bzero Initializes a memory area by clearing it to zero Copy bcopy Copies
352. ta types near or far assignment from const pointer to non const pointer 6 The const property is lost by assignment from const pointer to non const pointer Check the statement description If the descrip tion is correct ignore this warning assignment from volatile pointer to non volatile pointer 6 The volatile property is lost by assignment from volatile pointer to non volatile pointer Check the statement description If the descrip tion is correct ignore this warning Appendix F 24 Appendix F Error Messages Table F 23 ccom30 Warning Messages 3 10 Warning message Description and countermeasure assignment in comparison state ment You put an assignment expression in a compari son statement You may confuse with Check on it block level extern variable initialize forbid ignored An initializer is written in extern variable declara tion in a function gt Delete the initializer or change the storage class can t get address from register storage class variable The amp operator is written for a variable of the storage class register gt Do not use the operator to describe a variable of the storage class register can t get size of bitfield The bit field is used for the operand of the sizeof operator gt Write the operand correctly can t get size of function A function name is used for the operand of the sizeof op
353. tack size used by the main function etc is insufficient NC30 MANUAL 42 Chapter 2 Basic Method for Using the Compiler g Setting the Processor Mode Register Set the processor operating mode to match the target system at address 04H Processor mode register in the part of ncrt0 a30 shown in Figure 2 28 after reset this program will start omitted mov b 00h 04h set processer mode omitted Figure 2 28 Example Setting of Processor Mode Register ncrt0 a30 See the User s Manual of microcomputer you are using for details of the Processor Mode Register NC30 MANUAL 43 Chapter 2 Basic Method for Using the Compiler 2 2 3 Customizing for NC30 Memory Mapping a Structure of Sections In the case of a native environment compiler the executable files generated by the com piler are mapped to memory by the operating system such as UNIX However with cross environment compilers such as NC30 the user must determine the memory mapping With NC30 storage class variables variables with initial values variables without initial values character string data interrupt processing programs and interrupt vector address tables etc are mapped to Micoro Processor series memory as independent sections ac cording to their function The names of sections consist of a base name and attribute as shown below Table 2 12 Section Names Section Base Name Attribute Table 2 13 shows Section Base Name and T
354. tal size of the array array is 64 Kbytes or less and calculates the subscript j in 16 bits As a result the processing speed can be increased and code size can be reduced Renesas recommends using this option whenever the size of one array does not exceed 64 Kbytes Appendix A 33 Appendix A Command Option Reference fenable register fER Function Allocates variables with a specified register storage class to registers supplement When optimizing register assignments of auto variables it may not always be possible to obtain the optimum solution This option is provided as a means of increasing the efficiency of optimization by instructing register assignments in the program under the above situation When this option is specified the following register specified variables are forc ibly assigned to registers 1 Integral type variable 2 Pointer variable Note Because register specification in some cases has an adverse effect that the efficiency decreases be sure to verify the generated assembly language be fore using this specification fno_align fNA Function Does not align the start address of the function In the entry version this option cannot be specified Appendix A 34 Appendix A Command Option Reference JSRW Function Changes the default instruction for calling functions to JSR W supplement When calling a function that has been defined external to the source file the JSR A command is used
355. tandard output Execution nc30 E sample c example M16C 60 NC30 COMPILER V X XX Release X COPYRIGHT C XXXX XXXX RENESAS TECHNOLOGY CORPORATION ALL RIGHTS RESERVED AND RENESAS SOLUTIONS CORPORATION ALL RIGHTS RESERVED line 1 sample c omitted line 1 usr3 tool toolusr work30 inc30 stdio h omitted Notes When this option is specified no assembly source file extensions a30 re locatable object files extension r30 absolute module files extension x30 or other files output by ccom30 as30 or In30 are generated Appendix A 4 Appendix A Command Option Reference Compile driver control Function Invokes only preprocess commands creates a file extension i and stops processing Execution nc30 P sample c example M16C 60 NC30 COMPILER V X XX Release X COPYRIGHT C XXXX XXXX RENESAS TECHNOLOGY CORPORATION ALL RIGHTS RESERVED AND RENESAS SOLUTIONS CORPORATION ALL RIGHTS RESERVED sample c s sample rwer r 1 toolusr 2835 Aug 17 11 28 sample c 1 toolusr 2322 Aug 17 11 30 sample M Notes 1 When this option is specified no assembly source file extensions a30 relocatable object files extension r30 absolute module files extension X30 or other files output by ccom30 as30 or In30 are generated 2 The file extension i generated by this option does not include the line com mand generated by the preprocessor To get a result that inc
356. tatement is revolved 1 In order that there may be no guarantee the number of whose values of the stack pointer in the timing which interruption generated is even alignment is not performed to an interruption function For this reason processing speed may become slow when Ostack frame align op tion is specified to the function called from an interruption function Appendix A 22 Appendix A Command Option Reference Ono logical or combine ONLOC Function Suppresses the optinization that puts consective ORs together In the entry version this option cannot be specified Supplement If one of three options O3 or greater OR or OS is specified when compiling as in the example shown below the compiler optimizes code generation by combining logical ORs Example if a amp 0x01 a amp 0x0 a amp 0x04 l Optimized l if a amp 0x07 M In this case the variable a is referenced up to three times but after optimiza tion it is referenced only once However if the variable a has any effect on I O references etc the program may become unable to operate correctly due to optimization In such a case specify this option to suppress the optimization to combine logical ORs Note however that if the variable is declared with volatile logical ORs are not com bined for optimiza Ono asmopt ONA Inhibits starting the assembler optimizer Function Inhibits starting the assembler optim
357. te 6 far is described more than twice Write far correctly near is duplicate near is described more than twice Write near correctly static is illegal storage class for argument An appropriate storage class is used in argument declaration gt Use the correct storage class Appendix F 9 Appendix F Error Messages Table F 9 ccom mocc Error Messages 2 14 Error message Description and countermeasure volatile is duplicate 6 volatile is described more than twice Write the type qualifier correctly can t read C source from filename line number for error message The source line is in error and cannot be dis played The file indicated by filename cannot be found or the line number does not exist in the file Check whether the file actually exists can t open C source filename for error message 6 The source file in error cannot be opened Check whether the file exists argument type given both places 6 Argument declaration in function definition over laps an argument list separately given Choose the argument list or argument declara tion for this argument declaration array of functions declared The array type in array declaration is defined as function Specify scalar type struct union for the array type array size is not constant integer 6 The number of elements in array declaration is not a constant
358. te struct union tag name s member access An attempt is made to reference members of an incomplete struct or union that do not have de fined members gt Define a complete struct or union first inline function s address used An attempt is made to reference the address of an inline function Do not use the address of an inline function inline function s body is not de clared previously The body of an inline function is not defined Using an inline function define the function body prior to the function call inline function function name is recursion The recursive call of an in line function cannot be carried out Using an inline function No recursive interrupt function called The function specified by pragma INTERRUPT is called Be careful not to call an interrupt handling func tion invalid function default argument The default argument to the function is incorrect This error occurs when the prototype declaration of the function with default arguments and those in the function definition section do not match Make sure they match invalid push An attempt is made to push void type in function argument etc The type void cannot be pushed invalid operand The operation contains an error gt Check each expression Also note that the ex pressions on the left and right sides of must be of the same type invalid o
359. ted Figure B 44 Format of Kanji Character Constant Description Figure B 45 is a memory map of the array to which the character constant in Figure B 44 has been assigned 10bytes Figure B 45 Memory Location of wchar_t Type Character Constant Assigned Array higher Appendix B 24 Appendix B Extended Functions Reference B 4 Default Argument Declaration of Function NC30 allows you to define default values for the arguments of functions in the same way as with the C facility This chapter describes NC30 s facility to declare the default arguments of functions B 4 1 Overview of Default Argument Declaration of Function NC30 allows you to use implicit arguments by assigning parameter default values when declaring a function s prototype By using this facility you can save the time and labor that would otherwise be required for writing frequently used values when calling a function B 4 2 Format of Default Argument Declaration of Function Figure B 46 shows the format used to declare the default arguments of a function Storage class specifierAType declaratorADeclarator Dummy argument Default value or variable Figure B 46 Format for declaring the default arguments of a function Figure B 47 shows an example of declaration of a function and Figure B 48 shows a result of compiling of sample program which shows at Figure B 47 extern int func int i21 int j 2 abbreviated Figure B 47 Example f
360. that CLR specified in define is expanded as 0 4 Shows that because PRN specified in define is 1 the compile condition is satis fied and the printf function is output NC30 MANUAL 9 Chapter 1 Introduction to NC30 1 5 8 Assembly Language Source Files The assembly language source file is a file that can be processed by AS30 as a result of the compiler ccom30 converting the preprocess result C source file The output files are assembly language source files with the extension a30 Figures 1 9 and 1 10 are examples of the output files When the nc30 command line option dsource dS is specified the assembly language source files contain the contents of the C source file as comments C N LANG C X XX XX M16C 60 C Compiler OUTPUT ccom30 Version X XX XX i34 COPYRIGHT C XXXX XXXX XXXX RENESAS TECHNOLOGY CORPORATION ALL RIGHTS RESERVED AND RENESAS SOLUTIONS CORPORATION ALL RIGHTS RESERVED 44 Compile Start Time Thu April 10 18 40 11 1995 1996 1997 1998 1999 2000 2001 2002 2003 COMMAND LINE ccom30 smp i o smp a30 dS 44 Normal Optimize OFF 1 ROM size Optimize OFF Speed Optimize OF F 1 Default ROM is far 1 Default RAM is near GLB SB SB SB FB S34 FUNCTION main DER FRAME AUTO flag size 25 offset 2 Section program file smp c line 6 1 C SRC glb main main enter 02H line 8 1 C SRC flag CLR as A Figure
361. the 2nd expression of the for statement function initialized 6 An initialize expression is described for function declaration Delete the initialize expression function member declared A member of struct or union is function type Write the members correctly function returning a function de clared The type of the return value in function declara tion is function type Change the type to pointer to function etc function returning an array The type of the return value in function declara tion is an array type Change the type to pointer to function etc handler function called 6 The function specified by pragma HANDLER is called Be careful not to call a handler identifier variable name is dupli cated The variable is defined more than one time Specify variable definition correctly if struct union statement The struct or union type is used in the expression of the if statement The expression must have scalar type if void statement The void type is used in the expression of the if statement The expression must have scalar type illegal storage class for argument inline ignored An inline function is declared in declaration state ment within a function Declare it outside a function illegal storage class for argument interrupt ignored An interrupt function is declared in declaration stat
362. the boundary address OFFFFH NC30 allows you to control addressing mode switching by near and far qualifiers B 1 1 Overview of near and far Modifiers The near and far qualifiers select an addressing mode used for variables or functions near modifier Area of 000000H to OOFFFFH 6 far modifier Area of 000000H to OFFFFFH The near and far modifiers are added to a type specifier when declaring a variable or function If you do not specify the near or far modifiers when declaring variables and func tions NC30 interprets their attributes as follows MariableS near attribute const qualified constants far attribute Functions eeeeeR mme far attribute Furthermore NC30 allows you to modify these default attributes by using the startup options of compile driver nc30 Appendix B 2 Appendix B Extended Functions Reference B 1 2 Format of Variable Declaration The near and far modifiers are included in declarations using the same syntactical format as the const and volatile type modifiers Figure B 1 is a format of variable declaration type specifierAnear or farAvariable Figure B 1 Format of Variable added near far modifier Figure B 2 is an example of variable declaration Figure B 3 is a memory map for that variable int near in data int far if data func remainder omitted Figure B 2 Example of Variable Declaration near area far area 2bytes
363. the following directory and email to your local distributor SUPPORT Product name SUPPORT TXT Renesas Tools Homepage http www renesas com en tools NC30 User s Manual P Contents NC30 MANUAL III Contents Ta COMPONENTS uccide iia eter ia tpeaaiadee Mes 1 T2 Processing FOW usse edi iei SERERE ILE HER 1 1 551 S Sete rere 2 E 2 EE 2 pin Eoo 2 W225 Sik Viewer amp SIK ii te Eo eL ESSO REEL RU 2 1122 6 ERREUR es tH I Ie 2 12 7 2 Doc 3 1 3 1 Notes about Versionsup of compller 2 c ttbi ei iit irent Ine etr tib ecu eot nn 3 1 3 2 Notes about the M16C s Type Dependent Part sess 3 1 4 Example Program Development 2e eee hated e able sam borea x nid 5 15 NG30 Output Files me 7 1 5 1 Introduction to Output Fie Seisson a aici 7 1 5 2 Prep rocessed C Source Files iiie torio n ERE 8 1 5 3 Assembly Language Soutce 65 atit ie ne I edes 10 Chapter 2 Basic Method for Using the Compiler 12 2 1 Staring Wp the Compllel siryf eene era ese perte peered T EE 12 21A nest Command Format sue ici etate rp etre a ETa sad eoa aaea 12 2 1 2 Command
364. the input characters while the one or more characters between and are input Storing stops when a character other than those between and is input If you specify the circumflex after only character other than those between the circumflex and are legal input characters Storing stops when one of the specified characters is input The target parameter must be a pointer to a character array of sufficient size to store the character string including the null character which is automatically added en Stores the number of characters already read in format conversion The target param eter must be a pointer to an integer ee E f g and G Convert to floating point format If you specify modifier the target parameter must be a pointer to a double type The default is a pointer to a float type Appendix E 61 Appendix E Standard Library Specifying format in scanf form 2 prevents data storage Specifying the asterisk prevents the storage of converted data in the parameter 3 Maximum field width 9 Specify the maximum number of input characters as a positive decimal integer In any one format conversion the number of characters read will not exceed this number If before the specified number of characters has been read a space character a character that is true in function isspace or a character other than in the specified format is input reading stops at that character 4 1 Lorh T
365. ther than the integer and enumer ated types are used for the expression of a switch statement gt Use the integer type or enumerated type syntax error This is a syntax error Write the description correctly System Error 6 t does not normally occur This is an internal error This error may occur pursuant to one of errors that occurred before it If this error occurs even after eliminating all errors that occurred before it please send the content of the error message to Renesas Solutions Corp as you contact Appendix F 20 Appendix F Error Messages Table F 20 ccom30 Error Messages 14 14 Error message Description and countermeasure too many storage class of typedef 6 Storage class specifiers such as extern typedef static auto register are described more than twice in declaration Do not describe a storage class specifier more than twice type redeclaration of variable name 9 The variable is defined with different types each time Always use the same type when declaring a vari able twice typedef initialized An initialize expression is described in the vari able declared with typedef Delete the initialize expression uncomplete array pointer operation An incomplete multidimensional array has been accessed to pointer Specify the size of the multidimensional array undefined label label used 6 The jump address label for g
366. this option only when you are using the compiler in 8 bit bus width and when you want to reduce the number of sections Notes When pragma SECTION is used to change the name of a section data is mapped to the newly named section ffar RAM FRAM Function Change the default attribute of RAM data to far Supplement The RAM data variables are located in the near area by default Use this op tion when you want the RAM data to be located in other areas than the near area 64 Kbyte area Notes This option cannot used simultaneously with the R8C option Appendix A 31 Appendix A Command Option Reference ROM NROM Function Change the default attribute of RAM data to far In the entry version this option cannot be specified Supplement The ROM data const specified variables etc are located in the far area by default By specifying this option you can locate the ROM data in the near area You do not normally need to use this option however fconst_not_ROM fCNR Function Does not handle the types specified by const as ROM data Supplement The const specified data by default is located in the ROM area Take a look at the example below int const array 10 1 2 3 4 5 6 7 8 9 10 In this case the array array is located as ROM area By specifying this op tion you can locate the array in the RAM area You do not normally need to use this option however Appendix A 32
367. time for example c Finish processing after creating a relocatable file extension r30 S Finish processing after creating an assembly language source file extension a30 the S option has priority That is to say the compile driver does not perform any further processing after assembling In this case it only generates an assembly language source file If you want to create a relocatable file simultaneously with an assembly language source file use the option dsource shortcut dS NC30 MANUAL 14 2 1 4 Chapter 2 Basic Method for Using the Compiler nc30 Command Line Options a Options for Controlling Compile Driver Table 2 1 shows the command line options for controlling the compile driver Table 2 1 Options for Controlling Compile Driver Option Function C Creates a relocatable file extension r30 and ends processing Didentifier Defines an identifier Same function as define Idirectory Specifies the directory containing the file s specified in include You can specify up to 8 directories E Invokes only preprocess commands and outputs result to standard output P Invokes only preprocess commands and creates a file extension i S Creates an assembly language source file extension a30 and ends processing U predefined macro Undefines the specified predefined macro silent Suppresses the copyright message display at startup dsource Short form d
368. ting mode They are set during stream initial ization _IOERR These flags are set according to whether an EOF is encountered or error occurs in the I O function 4 int mod Stores the flags indicating the text mode TEXT and binary mode BIN 9 Text mode Echo back of I O data and conversion of characters See the source programs fgetc c and fputc c of the fgetc and fputc functions for details of echo back and character conversion 9 Binary mode No conversion of I O data These flags are set in the initialization block of the stream 5 int func in When the stream is in read only mode IOREAD or read write mode IORW stores the level 3 input function pointer Stores a NULL pointer in other cases This information is used for indirect calling of level 3 input functions by level 2 input functions 6 int func out When the stream is in write mode _IOWRT stores the level 3 output function pointer If the stream can be input IOREAD or IORW and is in text mode it stores the level 3 output function pointer for echo back Stores a NULL pointer in other cases This information is used for indirect calling of level 3 output functions by level 2 output functions Appendix E 91 Appendix E Standard Library Set values for all elements other than char_buff in the stream initialization block The standard library file supplied in the NC30 package initializes the stream in function init which
369. tion simultaneously within a single function and they point to an identical address Exsampl e int a 3 int p amp a test1 int b p 9 a 10 b By applying optimization p will be transposed to 9 printf b d expect b 10 n b result b 9 expect 10 The next page is followed Appendix A 16 Appendix A Command Option Reference 8 Notes When the O5 optimizing options is used the compiler generates in some cases BTSTC or BTSTS bit manipulation instructions In M16C the BTSTC and BTSTS bit manipulation instructions are prohibited from rewriting the con tents of the interrupt control registers However the compiler does not recog nize the type of any register so should BTSTC or BTSTS instructions be generated for interrupt control registers the assembled program will be differ ent from the one you intend to develop When the O5 optimizing options is used in the program shown below a BTSTC instruction is generated at compilation which prevents an interrupt request bit from being processed correctly resulting in the assembled pro gram performing improper operations For examplr C sauce which must not use an optimization option at the time of compile pragma ADDRESS TAOIC 0055h M16C 60 MCU s Ti mer AO interrupt control register struct char ILVL 3 char IR Mole An interrupt request bit char dmy 4 TAOIC void wait u
370. tion expression contains an error Check to see if the number of initialization ex pressions in the parentheses matches the num ber of array elements and the number of structure members invalid initializer too many brace Too many braces are used in a scalar type initialization expression of the auto storage class gt Reduce the number of braces used invalid Ivalue The left side of the assignment statement is not Ivalue gt Write a substitutable expression on the left side of the statement invalid Ivalue at operator The left side of the assignment statement is not Ivalue Write a substitutable expression on the left side of the statement invalid member The member reference contains an error Write correctly invalid member used The member reference contains an error Write correctly invalid redefined type name of identifier The same identifier is defined more than once in typedef Write the identifier correctly invalid return type The type of return value of the function is incor rect Write it correctly invalid sign specifier Specifiers signed unsigned are described twice or more Write the type specifier correctly invalid storage class for data The storage class is erroneously specified Write it correctly invalid struct or union type Structure or union members are referenced for the
371. tion options cannot be specified Table A 5 Optimization Options Option Short form Function O 1 5 None Effects the best possible optimization both in execu tion speed and in ROM capacity level by level OR None Maximum optimization of ROM size followed by speed OS None Maximum optimization of speed followed by ROM size Oconst OC Optimizes code generation by replacing reference to vari ables to declared by the const qualifier wih constatnts Ono_bit ONB Suppresses optimization based on grouping of bit manipulations Ono_break_source_debug ONBSD Suppresses optimization that affects source line data Ono float const fold ONFCF Suppresses the constant folding processing of float ing point numbers Ono stdlib ONS Inhibits inline padding of standard library functions and modification of library functions Osp adjust OSA Optimizes code generation by combining stack cor rection codes after function calls This helps to re duce the ROM capacity as well as speed up pro cessing However the amount of stack used may increase Ostack_frame_align OSFA Aligns the stack frame on an even boundary Oloop unroll 2 oop count OLU Unrolls code as many times as the loop count with out revolving the loop statement The loop count can be omitted When omitted this option is applied to a loop count of up to 5 Ono logical or combine ONLOC Suppresses the optimization that puts c
372. tion or SPECIAL page Function declaration Appendix G 2 Appendix G The SBDATA declaration amp SPECIAL Page Function declaration Utility utl30 Output the absolute module file nc30 ncrt0 a30 finfo sample c lt RET gt M16C 60 NC30 COMPILER V X XX Release X COPYRI GHT C XXXX XXXX RENESAS TECHNOLOGY CORPORATION ALL RIGHTS RESERVED AND RENESAS SOLUTIONS CORPORATION ALL RIGHTS RESERVED ncrt0 x30 Sample c Output SBDATA declaration Mut 30 sb30 ncrt0 x30 o sampl e lt RET gt M16C 60 UTILITY UTL30 for M16C 80 V X XX XX COPYRIGHT C XXXX XXXX RENESAS TECHNOLOGY CORPORATION ALL RIGHTS RESERVED AND RENESAS SOLUTIONS CORPORATION ALL RIGHTS RESERVED Output SPECIAL page Function declaration Mut 30 sp30 ncrt0 x30 o sampl e lt RET gt M16C 60 UTILITY UTL30 for M16C 80 V X XX XX COPYRIGHT C XXXX XXXX RENESAS TECHNOLOGY CORPORATION ALL RIGHTS RESERVED AND RENESAS SOLUTIONS CORPORATION ALL RIGHTS RESERVED RET Means entering the return key Figure G 3 Example utl30 Command Line 4 2 2 Selecting Output Informations To select outputs between SBDATA declaration and SPECIAL page function declara tion in utl30 specify the options described below If neither option is specified an error is assumed for utl30 1 Output SBDATA declaration Option sb30 2 Output SPECIAL page Function declaration Option sp30 Table G 3 shows the sbutl command line options Appendix G 3
373. tn Number of wide characters stored Returns the number of wide characters converted if s configure a correct multibyte character string Returns 1 if s does not configure a correct multibyte character string Returns 0 if s indicates a NULL character Appendix E 48 Appendix E Standard Library memchr Memory Handling Functions Function Format Method Argument ReturnValue Description Searches a character from a memory area include lt string h gt void far memchr s c n function const void far s Pointer to the memory area to be searched from WIL C Character to be searched size tn Size of the memory area to be searched Returns the position pointer of the specified character c where it is found Returns NULL if the character c could not be found in the memory area Searches for the characters shown in c in the amount of memory specified in n starting at the address specified in s When you specify options O OR or OS the system may selects another functions with good code efficiency by optimization memcmp Memory Handling Functions Function Format Method Argument ReturnValue Description Compares memory areas n bytes include lt string h gt int memcmp 51 52 n function const void far s1 Pointer to the first memory area to be compared const void s1 Poi
374. tor table in sect30 inc 1 When using the compiler option fmake_special_table fMST to set up Refer to fmake_special_table fMST in Appendix A Command Option Refer ence and pragma SPECIAL in Appendix B Extended Function Reference 2 When setting up the special page vector table in sect30 inc Figure 2 38 shows an example special page vector table macro is defined in ncrt0 a30 Format SPECIAL number SPECIAL 42 SPECIAL 41 SPECIAL 40 SPEC SPEC P L 31 P r w So SPEC SPEC SPEC SPEC SPEC 22 21 20 19 18 mom ie are Figure 2 38 Example Setting of Special Page Vector Table By default the special page vector table is a comment SPECIAL is a macro whose behavior is associated with the function name defined by pragma SPECIAL To define a special page number you want to use remove the comment for the desired page number Special page numbers do not need to be consecutive but must always be set in de scending order NC30 MANUAL 56 Programming Technique 3 1 Chapter 3 Programming Technique Chapter 3 This chapter describes precautions to be observed when programming with the C compiler NC30 Notes Renesas Technology Corp are not designed or manufactured for use in a device or system that is used under circumstances in which human life is potentially at stake Please contact Renesas Technology Corp Renesas Solutions Corp
375. torAdeclaration specifierAinitialization expression Figure C 1 Declaration Format of Variable 1 Storage class Specifiers NC30 supports the following storage class specifiers extern auto ypedef tatic egister 2 Type Declarator NC30 supports the type declarators 6 Bool echar eint es hort ong ong long loat double unsigned igned struct union enum 3 Declaration Specifier Use the format of declaration specifier shown in Figure C 2 in NC30 Declarator Pointer declarator2 Declarator2 identifier declarator declarator2 constant expression declarator2 list of dummy arguments opt Only the first array can be omitted from constant expressions showing the number of arrays opt indicates optional items Figure C 2 Format of Declaration Specifier Appendix C 11 Appendix C Overview of C Language Specifications 4 lnitialization expressions NC30 allows the initial values shown in Figure C 3 in initialization expressions integral types constant integral types array constant constant character types i constant character types array character literal constant pointer types character literal pointer array character literal character literal Figure C 3 Initial Values Specifiable in Initialization Expressions b Function Declaration Use the format shown in Figure C 4 to declare functions function declaration definition storage class speci
376. tput of debugging information for register variables In the entry version this option cannot be specified Supplement Use this option to suppress the output of debugging information about register variables when you do not require that information Suppressing the output of debugging information about the register variables will soeed up downloading to the debugger Appendix A 13 Appendix A Command Option Reference gold Outputs debugging information in previous format Function This option outputs debugging information in Rev E format When this option specifies the gno reg option and the fauto 128 option are automatically specified In the entry version this option cannot be specified Supplement With the increase in the maximum number of auto variables starting with NC30 V 2 00 the format of debugging information has changed from xxx r30 and Xxx x30 format The new format is known as the Rev F format the executable objects in the new format xxx x30 are compatible with the following debuggers PDB30 V 2 00 and later XDB30 V 2 00 and later PDB30SIM V 2 00 and later Use the gold option when compiling if you are using a debugger that cannot load executable objects in the new format xxx x30 Appendix A 14 Appendix A Command Option Reference A 2 5 Optimization Options Table A 5 shows the command line options for optimizing program execution speed and ROM capacity In the entry version all optimiza
377. ts the compiler stopping when an error occurs supplement The compiler compiles the program one function at a time If an error occurs when compiling the compiler by default does not compile the next function Also another error may be induced by an error giving rise to multiple errors In such a case the compiler stops compiling When this option is specified the compiler continues compiling as far as pos sible Note A system error may occur due to erroneous description in the program In such a case the compiler stops compiling even when this option is specified Wstdout Function Outputs error messages to the host machine s standard output stdout Execution A nc30 c Wstdout sample c err doc example A type err doc M16C 60 NC30 COMPILER V X XX Release X COPYRIGHT C XXXX XXXX RENESAS TECHNOLOGY CORPORATION ALL RIGHTS RESERVED AND RENESAS SOLUTIONS CORPORATION ALL RIGHTS RESERVED sample c Error ccom sample c line 39 unknown valuable port00 gt port00 0x00 Sorry compilation terminated because of these errors in main A gt 2 Supplement Use this option to save error output etc to a file by using Redirect in the MS Windows95 version personal computer version Note In this Compiler for MS Windows version personal computer version errors from as30 and In30 invoked by the compile driver are output to the standard output regardless of this option Appendix A 47
378. ts the macros that define these limits Macro name Contents Defined value MB LEN MAX Maximum value of the number multibyte charac 1 ter type bytes CHAR BIT Number of char type bits 8 CHAR MAX Maximum value that a char type variable can take 255 on as value CHAR MIN Minimum value that a char type variable can take 0 on as value SCHAR MAX Maximum value that a signed char type variable 127 can take on as value SCHAR MIN Minimum value that a signed char type variable 128 can take on as value INT MAX Maximum value that a int type variable can take on 32767 as valueMaximum value that a int type variable can take on as value INT MIN Minimum value that a int type variable can take on 32768 as value SHRT MAX Maximum value that a short int type variable can 32767 take on as value SHRT MIN Minimum value that a short int type variable can 32768 take on as value LONG MAX Maximum value that a long type variable can take 2147483647 on as value LONG MIN Minimum value that a long type variable 2147483648 can take on as value LLONG MAX Maximum value that a signed long long type vari 9223372036854775807 able can take on as value LLONG MIN Minimum value that a signed long long 9223372036854775808 type variable can take on as value UCHAR MAX Maximum value that an unsigned char type vari 255 able can take on as value UINT MAX Maximum value that an unsigned int type variable
379. turning to the function from which it was called Notes on Handling General purpose and Address Registers The general purpose registers RO R1 R2 R3 and address registers AO A1 can have their contents modified in assembler functions without a problem d Passing Parameters to an Assembler Function Use the pragma PARAMETER function if you need to pass parameters to a function written in assembly language The parameters are passed via registers Figure 14 5 shows the format asm func in the figure is the name of an assembler function unsigned int asm func unsigned int unsigned int TPrototype declaration of assembler function pragma PARAMETER asm func RO R1 Figure 3 16 Example Coding of Assembler Function pragma PARAMETER passes arguments to assembler functions via 16 bit general pur pose registers RO R1 R2 R3 8 bit general purpose registers ROL ROH R1L R1H and address registers A0 A1 In addition the 16 bit general purpose registers are com bined to form 32 bit registers R3R1 and R2RO0 for the parameters to be passed to the Note that an assembler function s prototype must always be declared before the pragma PARAMETER declaration However you cannot declare the following parameter types in a pragma PARAMETER declaration 9 struct or union types 9 64bit integer type flong longparameters 9 floating point type double argument You also cannot declare the functions returning structure or union t
380. ues of functions 6 Functions that return structures or unions 4 You can only use decimals for the INT Numbers Appendix B 47 Appendix B Extended Functions Reference oragma INTCALL Declare a function called by the INT instruction Examples int asm func unsigned long unsigned int Prototype declaration for pragma INTCALL 25 asm func R2R0 R1 the assembler function void main int i long 1 i Ox7FFD 1 0x007F asm func 1 i Calling the assembler function Figure B 73 Example of pragma INTCALL Declaration asm function 1 EY int c func unsigned int unsigned int Prototype declaration for the C function pragma INTCALL 25 c func You may NOT specify registers void main int i j i 0x7FFD j 0x007F c func i j Calling the C function Figure B 74 Example of pragma INTCALL Declaration C language functuion 2 Appendix B 48 Appendix B Extended Functions Reference pragma INTERRUPT pragma INTF Function Declares an interrupt handler Syntax pragma INTERRUPTA B E Ainterrupt handler name pragma INTERRUPTA B E Ainterrupt vector numberAinterrupt handler name pragma INTERRUPTA B E Ainterrupt handler name vectzinterrupt vector number Description 1 By using the above format to declare interrupt processing functions written in C NC30 generates the code for performing the following interrupt processing at the entry
381. urn value is set to R2RO register endm pragma ENDASM long void test func voi d mul 2 3 Figure B 86 Example of pragma Appendix B 61 B 8 B 8 1 B 9 2 Appendix B Extended Functions Reference assembler Macro Function Outline of Assembler Macro Function NC30 allows part of assembler commands to be written as C language functions Be cause specific assembler commands can be written directly in a C language program you can easily tune up the program Description Example of Assembler Macro Function Assembler macro functions can be written in a C language program in the same format as C language functions as shown below include lt asmmacro h gt Includes the assembler macro function definition file long char a 20 char b 20 func rmpa b 1 19 a b asm Macro Function rmpa command Figure B 87 Description Example of Assembler Macro Function Appendix B 62 Appendix B Extended Functions Reference B 8 3 Commands that Can be Written by Assembler Macro Function The following shows the assembler commands that can be written using assembler macro functions and their functionality and format as assembler macro functions DADD Function Syntax DADC Returns the result of decimal addition on val1 plus val2 include lt asmmacro h gt unsigned char dadd_b unsigned char val1 unsigned char val2 When calculated in 8
382. variable loca tion as near and the variable type as near Therefore Examples 1 and 2 respectively are interpreted as shown in Figure B 8 Example 1 int far near ptr1 Example 2 int near far ptr2 Figure B 8 Example of Declaring a Pointer Type Variable 2 2 In Example 1 the variable ptr1 is a 4 byte variable that indicates the int type variable located in the far area The variable itself is located in the near area In Example 2 the variable ptr2 is a 2 byte variable that indicates the int type variable located in the near area The variable itself is located in the far area Memory mappings for Examples 1 and 2 are shown in Figure B 9 int far ptr1 int far ptr2 iia oi near area near area far area tarea pe 77 1 2bytes 65 Figure 9 Memory Location of Pointer type Variable Appendix B 5 Appendix B Extended Functions Reference B 1 4 Format of Function Declaration A function s near and far allocation attributes are always far If you specify the near attribute in function declaration the system outputs a warning message function must be far with your near declaration ignored B 1 5 near far Control by nc30 Command Line Options NC30 handles functions as belonging to the far attribute and variables data as belong ing to the near attribute if you do not specify the near and far attributes NC30 s command line options allow you to modify the d
383. ver insert a comment 9 endif indicates the end of the range controlled by if Always be sure to enter endif when using command if 9 Combinations of if elif else endif can be nested There is no set limit to the number of levels of nesting but it depends on the amount of available memory You cannot use the sizeof operator cast operator or variables in a constant expression Appendix C 23 Appendix C Overview of C Language Specifications ifdef elif else endif ee ee ee Function Performs conditional compilation Examines the macro defined or not Format ifdefAidentifier islifAconstant expression d endif Description f an identifier is defined ifdef processes the program that follows You can also describe the following ifAdefinedAidentifier ifAdefinedA identifier else is used in a pair with ifdef Do not specify any tokens between else and the line feed You can however insert a comment elif is used in a pair with if ifdef or ifndef 6 endif indicates the end of the range controlled by ifdef Always be sure to enter endif when using command ifdef Combinations of ifdef else endif can be nested There is no set limit to the number of levels of nesting but it depends on the amount of available memory Appendix C 24 Appendix C Overview of C Language Specifications ifndef elif else endif p a ee ee Function Format
384. voi d func 1 M Figure B 83 Example of pragma JSRA Appendix B 58 Appendix B Extended Functions Reference pragma JSRW Function Calls a function using the JSR W instruction Syntax pragma JSRWAfunction name Description By default the JSR A instruction is used when calling a function that in the same file has no body definition However the pragma SRW declared function are always called using JSR W This directive helps reduce ROM size Rules 1 You may NOT specify pragma SRW for static functions 2 When function call with the JSR W instruction does not reach pragma SRW de clared function an error occurs at link time In this case you may not use pr ag ma SRW Example extern void func int i pragma SRW func void mai n voi d func 1 Figure B 84 Example of Zpragma JSRW Note The pragma SRW is valid only when directly calling a function It has no effect when calling indirectly Appendix B 59 Appendix B Extended Functions Reference pragma PAGE Function Declares new page position in the assembler generated list file Syntax pragma PAGE Description Putting the line pragma PAGE in C source code the PAGE pseudo instruction is output at the corresponding line in the compiler generated assembly source This instruction causes page ejection asesmbler output assembly list file Rules 1 You cannot specify the character string specifi
385. w C language source file C nc30 I Preprosesser nc30 command option ompile driver cpp30 C source file from Y preprocesser Compiler ccom3O Assembly language source file This file is generated Assembler nc30 command Relocatable object file Absolute module file option finfo SBDATA definition amp SPECIAL Page Function definition linker utility SBDATA SPECIAL Page SPECIAL Page definition file Function Vector 1 definition file definition file C 2 output file of nc30 FigureG 1 30 Processing Flow Appendix G 1 Appendix G The SBDATA declaration amp SPECIAL Page Function declaration Utility utl30 G 2 Starting utl30 G 2 1 utl30 Command Line Format For starting utl30 you have to specify the information and parameter that required utlS0A command line option A map file name 96 Prompt Mandatory item Optional item Space Delimit multiple command line options with spaces Figure G 2 utl30 Command Line Format Before utl30 can be used the following startup options of the compiler must both be specified in order to generate an absolute module file extension x30 9 finfo option to output an inspector information 9 g option to output debugging information The following utl30 options are also specified 9 o option to output of information SBDATA declara
386. wercase v for this option Appendix A 10 Appendix A V Command Option Reference Display version data Function Execution example Supplement Notes Displays version data for the command programs executed by the compiler then finishes processing D MTOOL nc30wa gt nc30 V M16C 60 NC30 COMPILER V X XX Release X COPYRI GHT C XXXX XXXX RENESAS TECHNOLOGY CORPORATION ALL RIGHTS RESERVED AND RENESAS SOLUTI ONS CORPORATION ALL RIGHTS RESERVED M16C 60 C Compile Driver Version X XX XX NC Preprocessor Version X XX XX M16C 60 C Compiler Version X XX XX Assembler Optimizer aopt30 for MI6C Family Version X XX XX M16C 60 Series Assembler system Version X XX ReleaseX Assembler Driver as30 for M16C 60 Series Version X XX XX Macro Processor mac30 for M16C 60 Version X XX XX Structured Processor pre30 for M16C Family Version X XX XX Assembler Processor asp30 for MI6C Family Version X XX XX Linkage Editor 1n30 for M16C Family Version X XX XX Librarian 1530 for M16C Family Version X XX XX Load Module Converter Imc30 for M16C 60 Series Version X XX XX Cross Referencer xrf30 for M16C Family Version X XX XX Absolute Lister abs30 for MI6C Family Version X XX XX D MTOOL nc30wa gt Use this option to check that the compiler has been installed correctly The Release Notes list the correct version numbers of the commands executed internally by the c
387. when using the STZ instruction or outputting shift instructions for division multiplications is always performed regardless of whether optimization options are specified or not b About the volatile qualifier Use of the volatile qualifier helps to prevent the referencing of variables the order in which they are referenced the number of times they are referenced etc from being affected by optimization However avoid writing statements like those shown below which will be interpreted ambiguously int a int volatile b c b C whethera cora b b whether a b or a b 1 a a Figure 3 6 Example of Ambiguously Interpreted volatile Qualifier Statements For successive bit manipulations if optimized the compiler generates codes to perform bit manipulations collectively even when the volatile qualifier is specified Bit manipula tions are performed simultaneously by overriding the order of references To inhibit collective bit manipulations use the Ono_bit shortcut ONB option NC30 MANUAL 60 3 1 4 3 1 5 Chapter 3 Programming Technique Precautions on Using register Variables a register qualification and fenable_register option f the option fenable_register fER is specified the variables that are register qualified so as to satisfy specific conditions can be forcibly assigned to registers This facility is provided for improving generated codes without relying on optimization
388. wise specified integers 0 1 2 are applied in the order in which the members appear Note that you can also use the nc30 command line option fchar_enumerator fCE to force enumerator types to have the same internal representation as unsigned char types D 1 4 Pointer Type Table D 3 shows the number of bytes used by pointer type data Table D 3 Data Size of Pointer Types Type Existence of Sign Bit Size Range near pointers None 16 0 OxFFFF far pointers None 32 0 OxFFFFFFFF Note that only the least significant 24 bits of the 32 bits of far pointers are valid D 1 5 Array Types Array types are mapped contiguously to an area equal to the product of the size of the elements in bytes and the number of elements They are mapped to memory in the order in which the elements appear Figure D 3 is an example of mapping Example char c 5 0 1 2 3 4 Figure D 3 Example of Placement of Array D 1 6 Structure types Structure types are mapped contiguously in the order of their member data Figure D 4 is an example of mapping Example struct TAG char c int i s addres s higher Figure D 4 Example of Placement of Structure 1 2 Appendix D 3 Appendix D C Language Specification Rules Normally there is no word alignment with structures The members of structures are mapped contiguously To use word alignment use the Zpragma STRUCT extended func tion pragma STRUCT adds a byte of
389. word dummy in vector 15 word dummy in vector 16 word dummy in uartO trance for user vector 17 word dummy in uartO receive for user vector 18 word dummy in uartl trance for user vector 19 word dummy in uartl receive for user vector 20 word dummy in ER A0 for user vector 21 word dummy in TIMER Al for user vector 22 word dummy in TIMER A2 for user vector 23 word dummy in TIMER A3 for user vector 24 word dummy int TIMER A4 for user vector 25 word dummy in TIMER B0 for user vector 26 word dummy in TIMER B1 for user vector 27 word dummy in TIMER B2 for user vector 28 word dummy in TO for user vector 29 word dummy in i T1 for user vector 30 dummy in T2 for user vector 31 else word dummy in BRK vector 0 word dummy in vector 1 word dummy in vector 2 word dummy in i vector 3 word dummy in int3 for user vector 4 word dummy in timerB5 for user vector 5 word dummy in timerB4 for user vector 6 word dummy in timerB3 for user vector 7 word dummy in Silo4 int5 for user vector 8 word dummy in Silo3 int4 for user vector 9 word dummy in Bus collision detection for user v10 word dummy in DMAO for user vector 11 word dummy in DMAl for user vector 12 word dummy in Key input interrupt for user vect 13 word dummy in A D for user vector 14 word dummy in uart2 transmit for user vector 15 word dummy in
390. ws precautions to be observed when using the asm function Do not destroy register contents in the asm function The compiler does not check the inside of the asm function If registers are going to be destroyed write push and pop instructions using the asm function to save and restore the registers 1 For the purpose of expression in this user s manual the subroutines written in the assembly language are referred to as assembler functions Those written with asm in a C language program are referred to as asm functions or inline assemble description Appendix B 10 Appendix B Extended Functions Reference B 2 2 Specifying FB Offset Value of auto Variable The storage class auto and register variables including arguments written in the C language are referenced and located as being offset from the Frame Base Register FB They may be mapped to registers as a result of optimization The auto variables which are mapped to the stack can be used in the asm function by writing the program as shown in Figure B 18 below asm op code R1 FB variable name Figure B 18 Description Format for Specifying FB Offset Only two variable name can be specified by using this description format The following types are supported for variable names Variable name Array name integer Struct name member name not including bit field members void func int idata int a 3 struct TAG int i int k s asm
391. y times as indicated by count in the address decrementing direction There is no return value void smovb b unsigned char p1 unsigned char p2 unsigned int count calculated in 8 bits void smovb w unsigned int p1 unsigned int p2 unsigned int count When calculated in 16 bits SMOVF EQ a Function Syntax Strings are transferred from the source address indicated by p1 to the destination address indicated by p2 as many times as indicated by count in the address incrementing direction There is no return value void smovf b unsigned char p1 unsigned char p2 unsigned int count calculated in 8 bits void smovf w unsigned int p1 unsigned int p2 unsigned int count calculated in 16 bits Appendix B 65 Appendix B Extended Functions Reference SSTR Function Strings are stored using val as the data to store p as the address to from val address which to transfer and count as the number of times to transfer data There is no return value Syntax void sstr b unsigned char val unsigned char p unsigned int count calculated in 8 bits void sstr w unsigned int val unsigned int p unsigned int count calculated in 16 bits MOVdir Function transfer to val2 from val1 by nibble Syntax include lt asmmacro h gt unsigned char movll unsigned char val1 unsigned char val2 to low of val2 from high of val1 unsigned char movlh unsigned char valt unsi
392. yntax pragma SRA function name Example pragma SRA func pragma JSRW Calls functions using JSR W as the JSR instruction Syntax pragma SRW function name Example pragma SRW func pragma PAGE Indicates a new page point in the assembler listing file Syntax pragma PAGE Example pragma PAGE Appendix B 36 Appendix B Extended Functions Reference B 7 2 Using Memory Mapping Extended Functions NC30 includes the following memory mapping extended functions pragma BIT 1 bit Manipulate Instruction using Variable Declaration Function Function Declares an external variable that exists in an area where a one bit manipulate instruc tion can be used in 16 bit absolute addressing mode Syntax pragma BlTA oariable name Description The M16C 60 series allows you to use a one bit manipulate instruction for external vari ables located in an area of addresses 00000H to 01FFFH in a ROM efficient 16 bit absolute addressing mode The variable declared by pragma BIT is assumed to be present in an area where a one bit manipulate instruction can be operated on it directly Rules 1 If pragma BIT is used for anything other than an external variable it is ignored as invalid 2 When an external variable is declared in pragma BIT and also has a bit width of 1 bit always directly output 1 bit instructions It is therefore the user s responsibility to ensure that when pragma BIT declarations a
393. yntax nc30A In30A option1Aoption2 A lt C source file name Execution n the example below the map file is generated when compiling example 9 nc30 g v osample In30 ms ncrt0 a30 sample c M16C 60 NC30 COMPILER V X XX Release X COPYRIGHT C XXXX XXXX RENESAS TECHNOLOGY CORPORATION ALL RIGHTS RESERVED AND RENESAS SOLUTIONS CORPORATION ALL RIGHTS RESERVED ncrt0 a30 as30 N N ncrt0 a30 sample c Cpp30 sample c o sample i DM16C DNC30 ccom30 sample i o sample a30 g as30 N N sample a30 1n30 ncrt0 r30 sample r30 G MS ms o sample omitted 9 ls sample rw r r 1 toolusr 2850 Aug 17 14 51 sample c YW Y 1 toolusr 44040 Aug 17 15 47 sample x30 YW Yr 1 toolusr 8310 Aug 17 15 47 sample map ok Notes Do not specify the In30 options G O ORDER L T V or file Appendix A 57 Appendix A Command Option Reference A 3 Notes on Command Line Options A 3 1 Coding Command Line Options The NC30 command line options differ according to whether they are written in upper case or lowercase letters Some options will not work if they are specified in the wrong case A 3 2 Priority of Options for Controlling If you specify both the following options in the NC30 command line the S option takes precedence and only the assembly language source files will be generated 6 c Stop after creating relocatable files 6 S Stop after creating assembly langu
394. ypes as the function s return values NC30 MANUAL 72 9 4 3 4 1 3 4 2 3 4 3 3 4 4 Chapter 3 Programming Technique When Using the R8C Tiny Series R8C Option To generate code for the R8C Tiny always be sure to specify this option in the compiler assembler linkage editor and load module converter For details about the R8C option see page 17 of this releasenote About Memory Space When the R8C option is specified memory space is extended to 64 Kbytes About the Default Attributes of ROM and RAM When the R8C option is specified both ROM data and RAM data assume the attribute near by default The default attribute of data with the const qualifier also is near The far and far qualifiers are ignored About the Extended Functions of pragma When the R8C option is specified the extended functions of pragma listed below are ignored Extended function Rules pragma SPECIAL Declares a function to call a special page subroutine pragma EXT4MPTR Declares that this is a pointer to access the 4 Mbyte ex tended ROM However Wunknown_pragma WUP is specified a warning is output for the ex tended functions of pragma mentioned above NC30 MANUAL 73 Chapter 3 Programming Technique 3 4 5 About the Startup Program For the startup program for the R8C Tiny use the ncrt0 a30 startup file and sect30 inc section definition file stored in the src30 startup directory under the install
395. ys returns 0 fgetc Function Reads one character from the stream Format include lt stdio h gt int fgetc stream Method function Argument FILE far stream Pointer of stream ReturnValue Returns the one input character Returns EOF if an error or the end of the stream is encountered Description Reads one character from the stream Interprets code 0x1A as the end code and ignores any subsequent data Appendix E 28 Appendix E Standard Library fgets Function Reads one line from the stream Format include lt stdio h gt char far fgets buffer n stream Method function Argument char far buffer Pointer of the location to be stored in WWE TES eiiis Maximum number of characters FILE far stream Pointer of stream ReturnValue Returns the pointer of the location to be stored the same pointer as given by the argument if normally input Returns the NULL pointer if an error or the end of the stream is encountered Description Reads character string from the specified stream and stores it in the buffer 6 Input ends at the input of any of the following new line character n n 1 characters end of stream A null character is appended to the end of the input character string The new line character n is stored as is Interprets code 0x1A as the end code and ignores any subsequent data Appendix E 29 Appendix E Standard Library
Download Pdf Manuals
Related Search
Related Contents
Eureka! Tents Hammock User's Manual Magnat LZR 765 PORTABLE LCD PROJECTORS klicken Sie hier Omron Healthcare HR-210 heart rate monitor User Manual of VSPlayer Software_V7.0.0 TIP150 - powerbridge.de Mode d'emploi Propex II - Universität zu Köln Copyright © All rights reserved.
Failed to retrieve file