This document contains useful information for embedded software developers who wish to migrate their code from IAR tools to CyberTHOR Studios GNU tools (and vice versa) for M16C Architecture targets. At present, this guide contains the following:
Compiler Options
Compiler Directives
Extended Keywords
Intrinsic Functions
Assembler Options
Assembler Directives
Calling Convention
C/Math Library Functions
Startup Routine
Vector Table
I/O files examples
Revision History:
Version Number | Date | Overview of changes |
1.0 | 21-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 |
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.
IAR |
GNU |
--cpu CPU
M16C/R8C Compiler supported targets are Renesas |
-mcpu=m16c
-mcpu=r8c
|
To compile code for the M16C/80 core and M32C, you need the M32C IAR C/C++ Compiler. |
-mcpu=m32c
-mcpu=m32cm |
In-line assembler
asm("MOV.W R1,R0"); |
asm(<assembly-language instruction string>);
e.g. asm("MOV.W R1,R0"); |
With the IAR compiler function and variable names are the same on C and assembler level. |
The GNU compiler adds a “_” to C function or variables names if they are referred from assembler level. |
--align_func={1|2} By default, the compiler uses byte alignment for function entries. Use --align_func=2 to specify word alignment and force the compiler to align all function entries to an even address |
-falign-functions |
--char_is_signed By default the compiler interprets the char type as unsigned. |
-fsigned-char
-fno-unsigned-char |
--enable_multibytes Enables support for multibyte characters |
Unicode characters are default supported. To add the character set "wchar.h" files need to be included passing "-std=c99" command line option. |
-y
--low_consts |
For M16C GNUC always copies constants from ROM to RAM. For M32C this is not supported. |
--strict_ansi |
-pedantic Let the type char be signed, like signed char. |
-Dsymbol[=value] |
-D symbol=value
|
--dependencies=[i][m] {filename|directory} |
-M |
--diag_error=tag,tag,... |
-Werror=
|
-f filename |
@file
|
--header_context |
-Wsystem-headers
|
-Ipath
|
-I dir |
-la Assembler file |
-S The input C source file is compiled only, assembling and linking is not done. The output is in the form of an assembly file. |
-lA (N is implied) Assembler file with C or C++ source as comments |
-Wa,-ah={filename|directory} |
-laN Assembler file without diagnostics in file. |
-Wa,-ad={filename|directory} |
--no_cse |
-fno-gcse |
--no_inline |
-fno-inline
|
--no_tbaa Use --no_tbaa to disable type-based alias analysis. When this option is not used, the compiler is free to assume that objects are only accessed through the declared type or through unsigned char. |
may_alias
Accesses to objects with types are not subjected to type-based alias
analysis, but are instead assumed to be able to alias any other type of
objects, just like the |
--no_unroll |
-fno-unroll-loops -fno-unroll-all-loops |
--no_warnings |
By
default all the warnings are disabled. -Wall enables the warning for normal code. |
-o {filename|directory} |
-o file
|
--preprocess=c Preserve comments |
-C
|
--preprocess=n Preprocess only |
-E
|
--preprocess=l Generate #line directives |
-P
|
--code_segment=name |
void foobar (void)
__attribute__ ((section ("bar"))); |
-r
--debug |
-g |
--require_prototypes § A function definition of a public function with no previous prototype declaration
|
Warn if a function is declared or defined without specifying the argument types. -Wmissing-prototypes (C only) Warn if a global function is defined without a previous prototype declaration.
-Wdeclaration-after-statement
(C only)
|
-s[2|3|6|9|debug|low|medium|high] 3, low Low* 6, medium Medium
-z[2|3|6|9|debug|low|medium|high] |
-O[1-3] 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.
|
-z9
|
-Os |
--strict_ansi |
-ansi |
--align_data={1|2}
-u(1|2) |
aligned (alignment)
|
--warnings_are_errors |
-Werror
|
-2
--64bit_doubles |
By default 64-bit double. No possibility to use 32-bit double. |
--calling_convention={simple|
normal} |
Not supported |
--constant_data={near|far|huge} |
Not supported But using the "attribute" constant variable can be placed in the named segment, as shown below. char foo __attribute__ ((section (sectionname))); |
--data_model={near|far|huge} |
Not supported |
For more information on the above compiler command line options, please refer to the gcc manual.
IAR |
GNU |
#pragma bitfield |
Not supported |
#pragma constseg |
Not supported |
#pragma data_alignment
|
Not supported |
#pragma dataseg |
Not supported |
#pragma inline
|
inline void foo (const char) __attribute__((always_inline)); |
#pragma location
|
Not supported
#define <var_name> (*(volatile char foo*) <abs add>) |
#pragma optimize
|
Not supported |
#pragma pack
|
struct S { int x[2];} __attribute__ ((packed));
The |
#pragma segment
|
Not supported
|
#pragma type_attribute
|
Default memory segmentation not supported. Pragma also not supported. |
#pragma vector
|
interrupt-handling-function-prototype __attribute__((section (".vects"))) } |
For more information on the above compiler directives, please refer
to the gcc
manual.
IAR |
GNU |
__bitvar |
Not supported. |
__data13 Control the storage of variables. This is a special addressing mode used only for bit variables. Valid for M16C and R8C only. |
Not supported. |
__data16 Control the storage of variables. Valid for M16C and R8C only. |
Not supported But using the "attribute" constant variable can be placed in the named segment, as shown below. char foo __attribute__ ((section (sectionname))); |
__data20 Control the storage of variables. Valid for M16C only. |
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 (20 or 24 bitr addressing), but uses only 16-bit for pointer arithmetics. |
Not supported But using the "attribute" constant variable can be placed in the named segment, as shown below. char foo __attribute__ ((section (sectionname))); |
__huge For M16C alias for __data20 Stores data in the far area (20 or 24 bitr addressing) with full size pointer arithmetics. |
Not supported But using the "attribute" constant variable can be placed in the named segment, as shown below. char foo __attribute__ ((section (sectionname))); |
__near Alias for __data16 |
Not supported But using the "attribute" constant variable can be placed in the named segment, as shown below. char foo __attribute__ ((section (sectionname))); |
__interrupt Defines interrupt function. |
Interrupt Defines interrupt function. |
__intrinsic Reserved for compiler internal use. |
Not supported. |
__monitor Supports atomic execution of a function. |
Not supported. |
__no_init Supports non-volatile memory. |
Not supported. |
__fast_interrupt Supports interrupt functions using special registers for fast interrupt entry. For M32C only |
Not supported. |
__regbank_interrupt Supports interrupt functions using secondary register bank. |
Not supported. |
__root Ensures a function or variable is included in the object code even if it is not used. |
Not supported. |
__simple Ensures that a simple calling convention is used for a function. |
Not supported. |
__task allows functions to exit without restoring registers. |
Not supported. |
__tiny_func Specifies the JSRS instruction for function calls. |
Not supported. |
Intrinsic functions are a
special feature of the IAR compiler and not supported in GNUC.
However, most
intrinsic functions can be easily implemented as shown below:
IAR |
GNU |
__break() |
#define __break() asm(“BRK”); |
__BTSTS(unsigned char b, unsigned char * a) Inserts a BTSTS instruction |
Not supported. Needs special variables to be implemented. |
__disable_interrupt()
|
#define __ disable_interrupt () asm(“FCLR I”); |
__enable_interrupt()
|
#define __enable_interrupt() asm(“FSET I”); |
unsigned short __get_FLG_register()
|
Not supported. Needs special variables to be implemented. |
unsigned char __get_interrupt_level()
|
Not supported. Needs special variables to be implemented. |
__istate_t __read_interrupt_state()
|
Not supported. Needs special variables to be implemented. |
__illegal_opcode() |
#define __illegal_opcode() asm(“UND”); |
__no_operation() |
#define __no_operation() asm(“NOP”); |
unsigned char
__overflow() |
Not supported. Needs special variables to be implemented. |
__require(void *) |
Not supported. |
short __RMPA_B(const signed char *, const signed char *, short, unsigned short) Inserts an RMPA.B instruction |
Not supported. Needs special variables to be implemented. |
__RMPA_B_INTO(const
signed char *, const signed char *, short, unsigned short) |
Not supported. Needs special variables to be implemented. |
__RMPA_B_overflow(const
signed char *, const signed char *, short, unsigned short) |
Not supported. Needs special variables to be implemented. |
__RMPA_W(const signed
char *, const signed char *, long, unsigned short) |
Not supported. Needs special variables to be implemented. |
__RMPA_W_INTO(const
signed char *, const signed char *, long, unsigned short) |
Not supported. Needs special variables to be implemented. |
__RMPA_W_overflow(const
signed char *, const signed char *, long, unsigned short) |
Not supported. Needs special variables to be implemented. |
__segment_begin() |
Not supported. |
__segment_end() |
Not supported. |
__set_FLG_register(unsigned
short) |
Not supported. Needs special variables to be implemented. |
__set_INTB_register(unsigned
long) |
Not supported. Needs special variables to be implemented. |
__set_interrupt_level(unsigned
char) |
Not supported. Needs special variables to be implemented. |
__set_interrupt_state(__istate_t)
|
Not supported. Needs special variables to be implemented. |
__SMOVB_B(char*, const
char*, unsigned short) |
Not supported. Needs special variables to be implemented. |
__SMOVB_W(short*, const
short*, unsigned short) |
Not supported. Needs special variables to be implemented. |
__SMOVF_B(char*, const
char*, unsigned short) |
Not supported. Needs special variables to be implemented. |
__SMOVF_W(short*, const
short*, unsigned short) |
Not supported. Needs special variables to be implemented. |
__software_interrupt(unsigned
char) |
Not supported. Needs special variables to be implemented. |
__SSTR_B(char*, const
char*, unsigned short) |
Not supported. Needs special variables to be implemented. |
__SSTR_W(short*, const
short*, unsigned short) |
Not supported. Needs special variables to be implemented. |
__wait_for_interrupt()
|
#define __wait_for_interrupt() asm(“WAIT”); |
IAR |
GNU |
-B |
-a[cdhlmns]
|
-b |
"m32c-elf-ar.exe" utility makes the library module. |
-Dsymbol[=value]
|
--defsym sym=value Define the symbol sym to be value before assembling the input file. |
-Enumber
|
Not supported |
-f filename
|
@file
|
-Iprefix
|
-I path |
-L[prefix]
|
–a |
-l filename
|
–a=file
|
-Oprefix
|
Not supported |
-o filename
|
-o filename Sets object filename |
-plines |
Not supported.
Can be replaced by
assembler directive ” |
Not supported |
--listing-cont-lines=number |
-r
|
-g Generates debugging information. For generating
|
-S
|
Not supported |
-Usymbol Undefines a symbol |
Not supported. Can be replaced by assembler directive “.purgem name”, which undefines the macro name. |
-w[string][s]
|
-W –no_warn Switch all warnings off. |
-x
|
Not supported
|
For more information on the above assembler command line options, please refer to the as manual.
IAR |
GNU |
$ #include Includes a file. |
.include "file" |
#elif
|
.elseif |
#else
|
.else |
#endif
|
.endif |
#error
|
.err , .error "string" |
#if
|
.if |
#ifdef
|
.ifdef |
#ifndef
|
.ifndef symbol |
#message
|
Not supported |
#undef
|
.purgem name |
/*comment
*/
|
/*comment */ |
//
|
line comment character '#' on the m32c |
label
ALIAS expr
|
To
define a local symbol, write a label of the form `N:' (where N
represents any positive integer). |
ALIGN align [,value2] |
.align |
ASEGN segment [:type], address Begins a named absolute segment |
Not supported. |
label
ASSIGN expr
|
.equ symbol, expression
|
BLKA |
.comm symbol , length
|
BLKB
|
|
BLKD
|
|
BLKF
|
|
BLKL
|
|
BLKW
|
|
BYTE
|
.byte expressions
|
COL
|
.psize lines , columns
|
DS8
|
.comm symbol , length
|
DS16
|
|
DS24
|
|
DS32
|
|
ELSE
|
.else
|
END
|
.end
|
ENDIF
|
.endif
|
ENDM |
.endm |
label
EQU expr |
.equ symbol, expression .set symbol, expression This directive sets the value of symbol to expression. |
EXITM |
.exitm |
EXTERN
|
.extern
|
FLOAT
|
.float flonums
.single flonums |
IF
|
.if absolute expression |
LSTCND
|
Not supported |
LSTCOD
|
|
LSTEXP
|
|
LSTMAC
|
|
LSTOUT
|
|
LSTPAG
|
|
LSTREP
|
|
LSTXRF
|
|
LWORD
|
.long expressions
|
MACRO
|
.macro |
ORG
|
Not supported. The instruction .org in GNUC sets the address relative to the start of the actual section. |
PAGE
|
Not supported |
PAGSIZ
|
.psize lines , columns
|
RSEG
|
.section name
|
REPT
|
.rept count
|
WORD
|
.word expressions
|
For more information on the above assembler directives, please refer to the as manual.
Values |
IAR |
GNU |
_Boll |
R0L Register |
R0L Register |
int |
R0 Register |
R0 Register |
float |
R2R0
LSB (16-bits) R0 |
Anything bigger than 16 bits is |
double |
Pointer to return value in R0 (16-bit address) or R2R0 (32-bit address) |
Anything bigger than 16 bits is |
long long |
Pointer to return value in R0 (16-bit address) or R2R0 (32-bit address) |
Anything bigger than 16 bits is |
Rules of Argument Transfer
Argument |
Argument Type |
IAR |
GNU |
Registers Used |
Registers Used |
||
First argument |
char type, |
R0L register |
R1L |
int type, |
2
byte pointer parameters in A0 register. |
R1 |
|
4-byte argument |
R2R0 |
On Stack |
|
Second argument |
int type |
Assign to registers according to above rules as long as registers are available. Otherwise on stack. |
R2 |
All other arguments |
Any |
Assign to registers according to above rules as long as registers are available. Otherwise on stack. |
On Stack |
Argument |
Argument Type |
IAR |
GNU |
Registers Used |
Registers Used |
||
First argument |
1-byte argument |
R0L register |
R1L |
2-byte argument |
R0 register |
||
3-byte argument |
A0 register |
R1 |
|
4-byte argument |
R2R0 registers |
On Stack |
|
Second arguments |
int type near pointer type |
On Stack |
R2 |
All other arguments |
Any |
On Stack |
On Stack |
GNU C library namely Newlib is under free software license. The 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
routine.
2. There is no support for low-level routines to
connect to the target.
No. |
Function |
General
Utilities (stddef.h) |
|
1 |
Offsetof |
C library Math
Functions only in GNU:
No. |
Function |
Description |
Character type handling
routines (ctype.h) |
||
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) |
||
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) |
||
1 |
atexit |
Request
execution of functions at program exit |
2 |
atof |
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) |
||
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) |
||
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
/*
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 only if ROMSTART is defined */
#if ROMSTART
#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
#endif // ROMSTART
/* 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 */
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
Input Files to IAR 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) |
Relocatable module file (.rxx) C / Assembler list file (.lst) Assembly Source file (.sxx) |
C
source file (.c) |
Assembly Source file (.s) |
Assembler am16c |
|
Assembler GAS |
|
Assembly Source file (.sxx) (.asm) (.msa) |
Relocatable module file (.rxx) Assembler list file (.lst) |
Assembly Source file (.s) |
Relocatable Object file (.o) |
Linker XLINK |
|
Linker LD |
|
Relocatable module file (.r34, .r48) |
Absolute model file (.x, .elf) Motorola S-record file (.mot) Intel Hex format file (.hex) Map file (.map) Supports 30 industry-standard loader formats based on command options passed. |
Relocatable Object file (.o) |
Output File (.out, .x, .abs) |
Load Module Converter |
|
Objcopy |
|
No separate loader module, it is inbuilt in XLINK |
|
Output File (.out, .x, .abs) |
Motorola S-Record format file (.mot) |
Useful Links:
http://sources.redhat.com/newlib/libc.html
http://sources.redhat.com/newlib/libm.html