Preface


This document contains useful information for embedded software developers who wish to migrate their code from TASKING tools to Cyberthor Studios GNU tools (and vice versa) for M16C Architecture targets. At present, this guide contains the following:


   Compiler Options.
   Compiler Directives.
   Compiler Extended Keywords.
   Intrinsic Functions.
   Assembly Options.
   Assembler Directives.
   Calling Conventions.
   C/Math Library Functions.
   Startup Routine.
   Vector Table.
   I/O files at various stages.


Please note that this is an intermediate guide, which will be improved and enhanced periodically.

Please do not hesitate to send any of your suggestions or ideas. You may log in your suggestions on our web site https://gcc-renesas.com/.

You will need to register first, after which you can either add a new support query at the following link: https://gcc-renesas.com/my-support-requests/tickettrackingsystem/addticket, or ask a question here: https://gcc-renesas.com/forum/ask/.

Please note that in order to be able to add a new support query or ask a question you must be logged in.



Revision History:

Version Number Date Overview of changes
1.0 27-December-2007 Created.
2.0 01-October-2008 Reference links provided in tables are removed. Reference link to gcc and as manuals are provided below the tables.
3.0 20-October-2016 Added new responsive template

Compiler Options


TASKING

GNU

In-line assembler

__asm ("MOV.W #0xFF, R0")

 


Note: The asm keyword reduces the compiler’s ability to optimize the code. Use modules written in assembler language instead of inline assembler.

asm(“assembly-language instruction string”);

 

Eg : asm("MOV.W  #0xFF,R0");

 

The GNU compiler adds a “_” to C function or variables names if they are referred from assembler level

--align-func

 

By default, the compiler uses byte alignment for function entries. This option will force the compiler to align all function entries to an even address.

-falign-functions

Align functions.

--align-data

 

By default, the compiler uses word aligns objects to the minimum alignment required by the architecture.

                                                  

aligned (alignment)


This attribute specifies a minimum alignment (in bytes) for variables of the specified type. For example, the declarations:
  struct S { short f[3]; } __attribute__ ((aligned (8)));
typedef int more_aligned_int __attribute__ ((aligned (8)));

force the compiler to insure (as far as it can) that each variable whose type is

 

struct S or more_aligned_int will be allocated and aligned at least on a 8-byte boundary.

--cpu = CPU

OR -C cpu

 

This options define the target processor

 

--r8c option  tells the compiler to compile for R8C/tiny core

 

-mcpu=m16c


Generates the object code for the M16C (up to /60) series.

 

-mcpu=r8c
Generates the code for R8C/Tiny Series.

 

To compile code for the M16C/80 core and M32C, you need the M32C Tasking C/C++ Compiler.

-mcpu=m32c
Generates the object code for the M32C/80 series.

 

-mcpu=m32cm
Generates the object code for the M16C/80 series

-c90  OR --iso = c90
Enables strict ISO/ANSI

-ansi

 

--check

Check the source for syntax errors.

-fsyntax-only

Check the code for syntax errors.

 

--compact-max-size = Value

Limit the maximum number of instructions in functions that the compiler generates during code compaction

 

 

 

Not Supported

-D (--define)

-D name=definition (--define=name=definition)

 

This option is used to define macro and specify it to the processor.

-D name=definition

 

 

 

The contents of definition are tokenized and processed as if they appeared during translation phase three in a `#define' directive

-E  [flags]

--preproces [=flags]

This option tells the compiler to preprocess the C source.

-E

 

Tells the compiler to preprocess the source.

-f filename OR –options-file= filename

 

Reads command line options from the named file, with there may not be any extension.

@file

 

Read command-line options from file. The options read are inserted in place of the original @file option. If file does not exist, or cannot be read, then the option will be treated literally, and not removed.

-F  OR --no-double

 

This option  tell the compiler to treat variables of the type double as float

-fshort-double

 

Use the same size for double as for float.

 

 

-H  OR --include-file

 

This option you include one extra file at the beginning of each C source file, before other includes

-include  file

 

Process file as if #include "file" appeared as the first line of the primary source file

-I path  OR --include-directory = path

Includes Directory path.

-I dir

Add the directory ‘dir’ to the list of directories to be searched For header files.

--inline 

Instructs the compiler to inline all functions.

 

-finline-functions

Integrate all simple functions into their callers.

--no_inline
Use –no_inline to disable function inlining.

 

-fno-inline
 Don't pay attention to the inline keyword.

-integer-enumeration

This option the compiler always treats enum-types as integer. By default it is char type.

Not supported. But following option can be used alternatively

-fshort-enums

Allocate to an enum type only as many bytes as it needs for the declared range of possible values

--noframe.

This option tells the compiler not to generate an interrupt frame (saving/restoring registers) for interrupt handlers

 

 

Not Supported

--no_warnings
By default the compiler issues standard warning messages. Use this option to disable all warning messages.

By default all the warnings are disabled.

 -Wall enables all the warning for normal code.

-o { filename|directory }

 

Use the -o option to specify an output file.

-o file

 

Place output in file file.

 

--preprocess=c

Preserve comments

 

-C
Do not discard comments. All comments are passed to the output file, except for comments in processed directives, which are deleted along with the directive.

--preprocess=n

Preprocess only

-E
Option, nothing is done except preprocessing.

--preprocess=l

Generate #line directives

-P
Inhibit generation of line markers in the output from the preprocessor. This might be useful when running the preprocessor on something that is not C code, and will be sent to a program which might be confused by the line markers.

-g

--debug
Use the --debug or the -g option to make the compiler include information for supported debuggers.

-g


Produce debugging information for supported debuggers.

--help OR -?

Displays the help message

--help

Displays the help message

 

-O (flags)  OR –optimize = flags

 

-O0  No optimization

 

-O1 Debug purpose optimizations

 

-O2 Release purpose optimization

                       

-O3 Full optimization

 

-O[1-3]
Optimise for execution speed.

1 – Optimise  for size and speed.

2 – Better optimisation, nearly all optimisations not involving space-speed trade off are used.

3 – Maximum optimisation for speed

-Os

Code size optimization.

-M {l | m | s}     OR

--model = { large | medium | small}

Specifies the data model large, medium or small.

 

Not supported

-r[flags]

--runtime [=flags] 

This option controls a number of run-time checks to detect errors during program execution.

 

 

Not Supported.

--strict_ansi

Use --strict_ansi to ensure that the program conforms to the ISO/ANSI C standard.

-ansi

-u (--uchar)

 

Treat 'character' type variables as 'unsigned character' variables. By default char is the same as specifying signed char.

-fsigned-char

 Let the type char be signed, like signed char

 

-fno-unsigned-char
Let the type char be unsigned, like unsigned char. 

 

-V

--version         

 

Display version information

 

 

-- version

 

 

Display version information

 

--novector

Option you tell the compiler not to generate code for interrupt vectors

 

Not supported.

--warnings-as-errors
Use this option to make the compiler treat all warnings as errors. 

 

-Werror
Make all warnings into errors.

For more information on the above compiler command line options, please refer to the gcc manual.

Compiler Directives


TASKING

GNU

#pragma align

Pragma align aligns all objects to even addresses

 

#pragma align-data

Pragma align-data aligns all data to even addresses

 

#pragma align-func

Pragma align-func aligns all functions to even addresses.

 

aligned (alignment)
This attribute specifies a minimum alignment (in bytes) for variables of the specified type. For example, the declarations:
  struct S { short f[3]; } __attribute__ ((aligned (8)));
typedef int more_aligned_int __attribute__ ((aligned (8)));

force the compiler to insure (as far as it can) that each variable whose type is struct S or more_aligned_int will be allocated and aligned at least on a 8-byte boundary.

It is not supported for functions

 

#pragma extension isuffix

 

Enables a language extension to specify imaginary floating-point constants.

 

 

Not supported

#pragma extern symbol

 

 

Not Supported

#pragma clear

#pragma noclear

 

By default, uninitialized global or static variables are cleared to zero on startup.

with pragma noclear, this step is skipped.

 

 

Not Supported

 

#pragma inline

#pragma noinline

 

Pragma inline and pragma noinline to inline a function body.

 

Function attributes can be used to inline functions

void foo (const char) __attribute__((always_inline));

 

void foo (const char) __attribute__((noinline));

#pragma smartinline

 

With this pragma small functions that are not too often called, are inlined.

 

Not supported.

#pragma macro

#pragma nomacro

Turns macro expansion on or off.

 

Not supported.

 

#pragma message "string"

 

Print the message string(s) on standard output.

 

 

Not Supported.

 

 

 

#pragma optimize flags

#pragma endoptimize

 

Compiler option -O for the code between the pragmas optimize and endoptimize

 

 

 

Not supported

 

But by passing the -O,-O1,-O2,-O3& -Os option in the command line optimization can be achieved.

#pragma renamesect spec

Rename sections of the specified type.

#pragma endrenamesect

Restore default section naming.

 

 

 

Not Supported

 

#pragma runtime [flag,...]

 

Check for runtime errors

 

Not Supported

#pragma weak symbol

 

Mark a symbol as "weak”.

 

#pragma weak symbol

 

This pragma declares symbol to be weak

 

#pragma alias symbol=defined_symbol

 

Define symbol as an alias for defined_symbol

 

 

Not supported

 

By using attribute alias for function can be written as  alias ("target")

For Example

void f () __attribute__ ((weak, alias ("__f")));

defines `f' to be a weak alias for `__f'

For more information on the above compiler directives, please refer to the gcc manual.

Compiler Extended Keywords


TASKING

GNU

__bita
Storage in bit addressable fields.

Not supported.

__at()

Place the object at an absolute address.

Not supported

But using the "attribute" constant variable can be placed in the named segment, as shown below.

char foo __attribute__ ((section (sectionname)));

__far

Control the storage of variables. Stores data in the far area (Anywhere in 20 bits addressing), but uses only 16-bit for pointer arithmetic. 

 

Not supported

 

__paged

 The data can be stored a 64 kB page, anywhere in memory. 

Not supported

 

__near

Stores the data in the first 64kB of memory.

Not supported

 

__interrupt

Defines interrupt function.

 

__attribute__ ((interrupt ("IRQ")))

Indicate that the specified function is an interrupt handler.

For ex:

void f () __attribute__ ((interrupt ("IRQ")));

__rom

This specifies that a variable must be placed in ROM. 

Not Supported.

__sfr

Define a symbol as a Special Function Register (SFR).

Not Supported.



Intrinsic Functions


TASKING

GNU

 

void __brk (void)    

Breaks the interrupt

 

 

#define __ disable_interrupt ( ) asm(“FCLR I”);

 

void __int (int)        

Initialize the interrupt

 

 

#define __enable_interrupt( ) asm(“FSET I”);

 

__illegal_opcode( )
Inserts an UND instruction

 

 

#define __illegal_opcode( ) asm(“UND”);

void __nop(void)

 

Inserts a NOP instruction

 

#define __no_operation( )  asm(“NOP”);

 

void __wait (void)  

WAIT instruction

 

 

#define __wait_for_interrupt( ) asm(“WAIT”);



Assembler Options


TASKING

                               GNU

-I (--include-directory)

 

-Ipath,...

--include-directory=path,...

 

Specify the path where include files are located. A relative path will be relative to the current directory.

-I path    

Use this option to add a path to the list of directories as searches for files specified in .include directives

-Oa/-OA      (= on/off)

Optimize speed by means of instruction alignment.

 

-Og/-OG

 Allow generic instructions

-Os/-OS

Optimize instruction size

Not Supported

-gAHLS

No debug information

-gs

Automatic HLL or assembly level debug information

-gflag

Custom debug information   

-g

 

Generates debugging information.

 

-gdwarf-2

Generate dwarf-2 debug information 

By default all warnings are reported

 

-w

--no-warnings

Suppress all warnings

 

-w[num]...

--no-warnings[=nr,...]

Suppress specific warnings

 

--warnings-as-errors

Treat warnings as errors     

 

--warn

Don't suppress warning messages or treat them as errors. 

-W

--no-warn

Suppress warning messages.

 

 

 

 

--fatal-warnings

Treat warnings as errors.

-?

--help[=options]

Displays an overview of all command line options.

--help

Displays a summary of the command line options

 --error-file[=file]

Redirect diagnostic messages to a file         

 

Not Supported

 -k

Keep output file after errors

 

Not supported

 

  -m{t|n}

Select TASKING preprocessor or no preprocessor 

 

Not Supported

 

-o file

Specify name of output file 

 

-o filename

Sets object filename

-v

Verbose information  

 

 

Not Supported.

-V

Display version header only 

 

-v

Displays Version information

 

-f filename  OR --option-file= filename
Extends the command line and reads the options from the file.

@file
Read command-line options from file.

         --emit-locals

       Emit local symbols

Not Supported.

-C cpu

Define the target processor

 

Not Supported

--check

Check for syntax errors

Not Supported

--r8c

This option lets the assembler to assemble for R8C/tiny core.

 

Not Supported

-t     flags [c/C          (+/-console Or l/L       (+/-list)       

Option tells the assembler to display section information.

 

Not Supported.

 

-l 

This option generates assembler list file

 

-a  Requests high-level, assembly, and symbols listing

 

-ah Requests a high-level language listing,

 

-al Requests an output-program assembly listing.

 

-as  Requests a symbol table listing


For more information on the above assembler options, please refer to the as manual.

Assembler Directives


                         TASKING

                         GNU

WARN  [{string | expr}[,{string | expr}]...]

Programmer generated warning

 

.warning "string"

Generates Warning message

#IF

#ELSE

#ENDIF

.if

.else

.endif

#DEFINE      Define substitution string

 

.define

#COMMENT  

Start comment lines. You cannot use this directive in MACRO/DUP definitions.

 

/*comment */

DEFSECT     

Define section name, type and attributes

 

.section name

#END  End of source program

 

.end

#fail

Programmer generated error message

 

.fail Expr

Generates an error or a warning

#include

Include a file

 

.include "file"
This directive provides a way to include supporting files at specified points in your source program.

MSG  

Programmer generated message

 

 

.print string

print string on the standard output during assembly

RADIX

Change input radix for constants

 

Not Supported

SECT 

Activate a declared section

 

.section name

UNDEF         

Undefine DEFINE symbol

 

.undef

EXTERN         

External symbol declaration

.extern

EQU

Assigns permanent value to a symbol

 

.equ symbol, expression

GLOBAL

 Global Symbol declaration

.global symbol

LOCAL

Local symbol declaration

 Not Supported

SET

Set temporary value to a symbol

 

.set symbol, expression

Set the value of symbol to expression

 

SIZE   

Set size of symbol in the ELF symbol table

.size

This directive is used to set the size associated with a symbol

TYPE  

Set symbol type in the ELF symbol table

 

.type

WEAK 

Mark symbol as 'weak'

.weak names

This directive sets the weak attribute on the comma separated list of symbol names

ALIGN

Define alignment

 

align abs-expr, abs-expr, abs-expr

 

ASCII / ASCIZ

Define ASCII string without / with ending NULL byte

ascii "string"

BS      

Define block storage (initialized)

 

Not Supported

BSB

Define byte block storage (initialized)

 

Not Supported

BSBIT

Define bit block storage in bit-addressable data

 

Not Supported

BSW / BSL

Define word / long block storage (initialized)

 

Not Supported

DB

Define constant byte

 

Not Supported

DBIT

Define constant bit

Not Supported

DS      

Define storage

 

Not Supported

DW / DL

Define a word / long constant

Not Supported

FLOAT / DOUBLE     

Define a float / double constant

Not Supported

DUP    

Duplicate sequence of source lines

 

 

Not Supported

DUPA 

Duplicate sequence with arguments

 

Not Supported

DUPC 

Duplicate sequence with characters

 

Not Supported

DUPF  

Duplicate sequence in loop

 

Not Supported

ENDM

End of macro or duplicate sequence

 

.endm

EXITM

Exit macro

 

.exitm

IF/ELIF/ELSE/ENDIF         

Conditional assembly

Already Defined

MACRO          

Define macro

 

.macro

PMACRO        

Undefine (purge) macro

 

.purgem name

CALLS

Passes call information to object file. Used by the linker to build a call graph and calculate stack size

 

Not Supported


For more information on the above assembler directives, please refer to the as manual.

Calling Convetions


Rules of Return Value

Values

TASKING

GNU

_Boll
Char (QImode)

R0L Register

R0L Register

int
near pointer (HImode)

R0 Register

A0 Register

R0 Register

float
long
far pointer (SImode)

R2R0

R2R0
A1A0 registers

Anything bigger than 16 bits is
returned in memory, at mem0
(mem0 through mem15 are
provided by libgcc.a)

double

R3R1R2R0 Registers

Anything bigger than 16 bits is
returned in memory, at mem0
(mem0 through mem15 are
provided by libgcc.a)

long long

R3R1R2R0 Registers

Anything bigger than 16 bits is
returned in memory, at mem0
(mem0 through mem15 are
provided by libgcc.a)



Rules of Argument Transfer

Argument

Argument Type

TASKING

GNU

Registers Used
(M16C using normal calling convention)

Registers Used

First argument

char type,

_Bool type(QImode)

R0L register

if R0L not empty R0H.

R1L

int type,

near pointer type (HImode)

R0 Register

 


A0 Register

R1

4-byte argument

 

Long long

R2R0

 

R3R1R2R0

On Stack

 

On Stack

Second argument

int type

 

 

 

near pointer type

Assign to register R1 if available ,otherwise on stack.

 

A1 Register if available otherwise on the stock

R2

Third argument

Int type

R1 Register

On stack

 

Fourth Argument

Int Type

R3 Register

On stack

 

 

All other arguments

 

 

Any

 

Assign to registers according to above rules as long as registers are available. Otherwise on stack.

On Stack



C/Math Library Functions


 

GNU C library namely Newlib is distributed under a free software license. Newlib supports various processors and architectures.

1.    Complete set of standard input/output functions.
2.    Float parameters support for math library.
3.    The library can be built with integer only support. This in turn reduces the load.

4.    Option is available to build the libraries with floating point support.
5.    A customizable math error handler matherr() is available.
6.    All the functions are reentrant.

 

Drawbacks Involved:

 

1.   malloc () is used in every stdio library functions.
2.   There is no support for low-level routines to connect to the target.

 

C library Math Functions only in Renesas:

 

No. Function
General Utilities (stddef.h)
1 offsetof

C library Math Functions only in GNU:

No. Function Description

Character type handling routines (ctype.h)

Please refer the http://sources.redhat.com/newlib/libc.html#SEC35 for more information on these routines.

1 Isascii ASCII character predicate
2 Toascii Control character predicate
3 Iswalnum Alphanumeric wide character test
4 Iswalpha Alphabetic wide character test
5 Iswcntrla Wide character cntrl test
6 Iswdigit Decimal digit wide character test
7 Iswgraph Graphic wide character test
8 Iswlower Lowercase wide character test
9 Iswprint Printable wide character test
10 Iswpunct Punctuation wide character test
11 Iswspace Wide character space test
12 Iswupper Uppercase wide character test
13 Iswxdigit Hexadecimal digit wide character test
14 Iswctype Extensible wide character test
15 Wctype Get wide character classification type
16 *Towlower Translate wide characters to lower case
17 *Towupper Translate wide characters to upper case
18 Towctrans Extensible wide character case mapping
19 Wctrans Get wide character translation type

No. Function Description

Mathematics Functions (math.h)

Please refer the http://sources.redhat.com/newlib/libm.html#SEC1 for more information on these routines.

1 acosh, acoshf Inverse hyperbolic cosine
2 asinh, asinhf Inverse hyperbolic sine
3 atanh, atanhf Inverse hyperbolic tangent
4 jN,jNf,yN,yNf Bessel functions
5 erf, erff, erfc, erfcf Error function
6 gamma, gammaf, lgamma, lgammaf, gamma_r, hypot, hypotf Distance from origin
7 isnan, isnanf, isinf, isinff, finite, finitef Test for exceptional numbers
8 remainder, remainderf Round and remainder
9 cbrt, cbrtf Cube root
10 copysign, copysignf Sign of y, magnitude of x
11 expm, expmf Exponential minus 1
12 ilogb, ilogbf Get exponent of floating point number
13 infinity, infinityf Representation of infinity
14 logp, logpf Log of 1 + x
15 Matherr Modifiable math error handler
16 nan, nanf Representation of infinity
17 nextafter, nextafterf Get next number
18 scalbn, scalbnf Scale by integer

No. Function Description

General Utilities (stdlib.h)

Please refer the http://sources.redhat.com/newlib/libc.html#SEC1 for more information on these routines.

1 Atexit Request execution of functions at program exit
2 Atoff String to double or float
3 Ecvt, ecvtf, fcvt, fcvtf Double or float to string
4 Gvcvt, gcvtf Format double or float as string
5 Ecvtbuf, fcvtbuf Double or float to string
6 __env_lock, __env_unlock Lock environ variable
7 Getenv Look up environment variable
8 Mallinfo, malloc_stats, mallopt Malloc support
9 __malloc_lock, __malloc_unlock Lock malloc pool
10 Mblen Minimal multibyte length function
11 Mbstowcs Minimal multibyte string to wide char converter
12 Mbtowc Minimal multibyte to wide char converter
13 Rand48, drand48, erand48, lrand48, nrand48, mrand48, jrand48, srand48, seed48, lcong48 Pseudo random number generators and initialization routines
14 Strtof String to double or float
15 System Execute command string
16 Wcstombs Minimal wide char string to multibyte string converter
17 Wctomb Minimal wide char to multibyte converter

No. Function Description

String and Memory routines (string.h)

Please refer the http://sources.redhat.com/newlib/libc.html#SEC109 for more information on these routines.

1 Bcmp Compare two memory areas
2 Bcopy Copy memory regions
3 Bzero Initialize memory to zero
4 Index Search for character in string
5 Memccpy Copy memory regions with end token check
6 Mempcpy Copy memory regions and return end pointer
7 Rindex Reverse search for character in string
8 Strcasecmp Case insensitive character string compare
9 Strlwr Force string to lower case
10 Strncasecmp Case insensitive character string compare
11 strtok_r,strsep Get next token from a string
12 Strupr Force string to uppercase
13 Swab Swap adjacent bytes

No. Function Description

Input/output routines (stdio.h)

Please refer the http://sources.redhat.com/newlib/libc.html#SEC67 for more information on these routines.

1 Fgetpos Record position in a stream or file
2 Fiprintf Format output to file (integer only)
3 Fdopen Turn open file into a stream
4 Freopen Open a file using an existing file descriptor
5 fseeko Set file position
6 Fsetpos Restore position of a stream or file
7 ftello Return position in a stream or file
8 Getw Read a word (int)
9 Iprintf Write formatted output (integer only)
10 mktemp, mkstemp Generate unused file name
11 Putw Write a word (int)
12 Remove Delete a file's name
13 Rename Rename a file
14 Setbuf Specify full buffering for a file or stream
15 Siprintf Write formatted output (integer only)
16 asprintf, snprintf Format output
17 Tmpfile Create a temporary file
18 Tmpnam, Name for a temporary file
Large file input / output:
19 Fopen64 Open a large file
20 Freopen64 Open a large file using an existing file descriptor
21 Ftello64 Return position in a stream or file
22 Fseeko64 Set file position for large file
23 Fgetpos64 Record position in a large stream or file
24 Fsetpos64 Restore position of a large stream or file
25 Tmpfile64 Create a large temporary file

 

                Along with all the above, following set of routines are provided in the newlib library:

1.    Wide character strings (wchar.h):
         Please refer http://sources.redhat.com/newlib/libc.html#SEC144

2.    Signal handling (signal.h):
         Please refer http://sources.redhat.com/newlib/libc.html#SEC169

3.    Time functions (time.h):
         Please refer http://sources.redhat.com/newlib/libc.html#SEC172

4.    Locale specific routines (locale.h):
         Please refer http://sources.redhat.com/newlib/libc.html#SEC183

Startup Routine


The startup routine in GNUM16CM32C toolchain for all targets is given below for user reference. 

/* Start-up code */
.text
      .global     _start
      .type _start, @function

_start:
      ldc   #_istack, isp                  /* set interrupt stack pointer */
      mov.b #0x02,0x0a                 /* write enable in protect register */
      mov.b #0x00,0x04                 /* set processer mode  :single chip mode */
                                               /* 0x04 is the address of processor mode register 0 */
      mov.b #0x00,0x0a                 /* write disable in protect register */
      ldc   #0x0080,flg                   /* select USER STACK POINTER (BIT7=1,USP) (BIT7=0,ISP) */
      ldc   #_ustack,sp                  /* set user stack pointer */
      fset  I                                 /* ADD THIS TO ENABLE INTERRUPTS */

/* INTERRUPT VECTOR ADDRESS  definition   */
#ifdef __m16c_cpu__                   /* For M16C target */
      ldc   #0xF, intbh                   /* load upper 4 bits of variable vector address in intbh */
      ldc   #0xA000, intbl               /* load lower 16 bits of variable vector address in intbl */

#elif __r8c_cpu__                        /* For R8C target */
      ldc   #0x0, intbh
      ldc   #0xFD00, intbl                /* load variable vector address in intbl */

#else                                         /* For M32C, M32CM targets */
      ldc   #0x0FFBE00, intb            /* load variable vector address in intb register */

#endif

/* call the hardware initialiser */
      jsr.a _hw_initialise   

/* load data section from ROM to RAM*/
#ifndef __m16c_cpu__
#if defined(__m32c_cpu__) || defined(__m32cm_cpu__)
      mov.l #_mdata,a0                /* For M32C, M32CM targets, store the load address of data section in A0 */

#elif __r8c_cpu__                      /* For R8C target */
      mov.b #0x00,R1H                 /* load 00 in R1H */
      mov.w #_mdata,a0               /* store the load address of data section in A0 */

#endif                             
      mov.w #_data,a1                 /* store the start address of data section in, A1 */
      mov.w #_edata,r3                /* store the end address of data section in R3 */
      sub.w    a1,r3                      /* R3=R3-A1 Store size of data section in R3 */
      smovf.b

#endif

#ifdef __m16c_cpu__                  /* For M16C target */
      mov.b #%hi8(_mdata),r1h      /* move upper 4 bits of the 20 bit address (_mdata) to, r1h */
      mov.w #%lo16(_mdata),a0     /* move lower 16 bits of the 20 bit address (_mdata) to,a0 */
      mov.w #_data,a1                 /* store the start address of data section in,A1*/
      mov.w #_edata,r3                /* store the end address of data section in R3 */
      sub.w a1,r3                         /* R3=R3-A1. Store size of data section in R3 */
      mov.w r3,r2                         /* Store size of data section in R2 */
      smovf.b

/* load rodata section from ROM to RAM only for M16C target */
      mov.b #%hi8(_mdata),r1h      /* move upper 4 bits of the 20 bit address (_mdata) to r1h */
      mov.w #%lo16(_mdata),a0     /* move lower 16 bits of the 20 bit address (_mdata) to,a0 */
      add.w r2,a0                         /* add the size of data section to a0, to get load address of rodata section */
      jnc rodata_init            
      add.b #01, r1h                     /* if the carry flag is set,increment r1h */

rodata_init:                 
      mov.w #_rodata,a1               /* store the start address of rodata section in, A1 */
      mov.w #_erodata,r3              /* store the end address of rodata section in R3 */
      sub.w a1,r3                         /* R3=R3-A1. Store size of rodata section in R3 */
      smovf.b

#endif


/* bss initialisation : zero out bss */
      mov.b #0x00,R0L                /* load R0L reg with 0x0 (value at which bss  section will be initialised) */
      mov.w #_bss, a1                /* store the start address of bss in A1 */
      mov.w #_ebss, a0               /* store the end address of bss in A0 */
      sub.w   a1,a0                     /* (A0 = A0-A1) */
      mov.w   a0,r3                     /* Store size of bss section in reg R3 */
      sstr.b

/* start user program */
      jsr.a _main      
.end

/* End of Start-up code */


Vector Table


The Vector Table in GNUM16CM32C toolchain for all targets is given below for user reference.
User need to call the Interrupt Service Routines (ISR) from the respective vector locations in the vector table. 

/*  Fixed Vector Table  */

             .section          .vects,"a",@progbits
             .type   _HardwareVectors, @object
             .size   _HardwareVectors, 36

_HardwareVectors:
    .long    0                  ;Hardware Vector 8
    .long    0                  ;Hardware Vector 7
    .long    0                  ;Hardware Vector 6
    .long    0                  ;Hardware Vector 5
    .long    0                  ;Hardware Vector 4
    .long    0                  ;Hardware Vector 3
    .long    0                  ;Hardware Vector 2
    .long    0                  ;Hardware Vector 1
    .long    _start           ;Reset ISR

/* Variable Vector Table */
             .section          .var_vects,"a",@progbits
             .type   _VariableVectors, @object
             .size   _VariableVectors, 256

 _VariableVectors:
    .long    _BRK_ISR    ;BRK instruction
    .long    0                  ;Variable Vector 1
    .long    0                  ;Variable Vector 2
    .long    0                  ;Variable Vector 3
        -          -
        -          -
        -          -
        -          -
    .long    0          ;Variable Vector 62
    .long    0          ;Variable Vector 63

 .end


I/O files at various stages


Input Files to TASKING Program

Output Files

Input Files to GNU Program

Output Files

Preprocess

 

Preprocess

 

C source file (.c)

C Header file (.h)

Preprocessed source (.i)

C source file (.c)

C Header file (.h)

Preprocessed source (.i)

Compiler M16C/R8C

 

Compiler GCC

 

C source file (.c)
C Header file (.h)

Intermediate C source file (.ic)

C / Assembler list file (.lst)

Assembly Source file (.src)

Compiler error message eile (.err)

C source file (.c)
C Header file (.h)

Assembly Source file (.s)

Assembler am16c

 

Assembler GAS

 

Assembly Source file (.src) (.asm)
Assembly header file (.inc)

Relocatable object file (.obj)

Assembler list file (.lst)

Assembler error Message file (.err)

Assembly Source file (.s)
Assembly header file (.inc)

Relocatable Object file (.o)
Assembler List file (.lst)

Linker

 

Linker LD

 

Object file (.obj)
Object library file (.a)

 

 

Object library file (.a)

Relocatable linker output file(.eln)

Motorola S-record file (.s)

Intel Hex format file (.hex)

Absolute IEEE-695 output file (.abs)

Absolute ELF/DWARF output file (.elf)

 

Relocatable Object file (.o)
Library File (.a)

Output File (.out, .x, .abs)
Map File (.map)


Useful Links:

http://sources.redhat.com/newlib/libc.html
http://sources.redhat.com/newlib/libm.html