This document contains useful information for embedded software developers who wish to migrate their code from Renesas tools to Cyberthor Studios tools (and vice versa) for H8 targets. At present, this guide contains the following:
Compiler Options.
Compiler Directives.
Intrinsic Functions.
C/Math Library Functions.
Assembly Programming.
Inline Assembly Language.
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 | 23-August-2004 | Created. |
2.0 | 31-August-2004 | Added assembler directives. |
3.0 | 31-August-2004 | GNU intrinsic functions dadd(), dsub(), mac(),
rotlw() are modified. Added .align assembler directive. |
4.0 | 31-August-2004 | GNU intrinsic functions set_imask_ccr(), set_imask_exr() are modified. |
5.0 | 07-March-2008 | 'Using inline assembly in GNU' is added. |
6.0 | 30-September-2008 | Modified 'Using inline assembly in GNU' section to add ‘-h-tick-hex’ option. |
7.0 | 29-January-2009 | Added 'extern' keyword for GNU intrinsic functions. Modified logic of 'set_imask_ccr' function. |
8.0 | 20-October-2016 | Added new responsive template |
Renesas Compiler Options |
Equivalent GCC compiler options |
-include = <path name>[,…] |
-I<path> |
-preinclude = <file name>[,...] |
-include <file> |
-define = <sub> [,…] |
-D<macro> |
-nomessage [ = <error code> [- <error code>] [,…] ]
|
-w |
-preprocessor [= <file name>] |
-E -o filename |
-object [= <object file name>] |
-o filename |
-Code=Asmcode -object=<file name>] |
-S filename |
-debug |
-g[level] |
-string = { Const | Data } |
-fwritable-strings |
-template = { None | Static | Used | All | AUto } |
-fno-implicit-templates |
-List [= <file name>] |
-Wa, -al=file |
-show=<sub>[,...] Specifies the contents and format of the list output by the compiler, and the cancellation of list output. |
-a[sub-option...] |
-speed = <sub> [,…] |
-O[1-3] |
-optimize = { 0 | 1 } |
-Os |
-comment |
-Wcomment |
-pack |
-fpack-struct |
-volatile |
-fvolatile |
-byteenum |
-fshort-enums |
-cmncode |
-fgcse |
-align |
-falign |
-structreg |
Available by default. |
-longreg |
Available by default. |
-double=float |
-fshort-double |
-rtti = { ON |OFf } |
-fno-rtti |
-exception |
-fexceptions |
-lang = { C | CPp } |
-x <language> |
Options only in GCC:
-fomit-frame-pointer |
Register (e) r6 in case of GCC is used as frame pointer. To avoid it from being pushed and popped during a function call, -fomit-frame-pointer option is specified. The Renesas H8 toolchain uses (e) r6 as a frame pointer if the optimization is disabled (-optimize=0) |
For more information on the above compiler command line options, please refer to the gcc manual.
Renesas Directives | Equivalent GNU directive or method |
#pragma interrupt (ext_0(vect=8)) void ext_0(void) { p0=6; } |
#define VECT_SECT __attribute__((section (".vects"))) typedef void (*fp) (void); extern void start (void); /*start function*/ void ext_0() __attribute__ ((interrupt_handler)); /* Interrupt handler function */ VECT_TYPE fp HardwareVectors[] VECT_SECT = { start,0,0,0,0,0,0,0,ext_0,0,0,0,0,0,0,0 } void ext_0() { P0 = 6; } |
extern char STK[100]; #pragma interrupt ( f(sp=STK+100) ) or _ _interrupt(sp=STK+100) void f(void); |
extern char STK[100]; void f () __attribute__ ((interrupt_handler, sp_switch ("STK+100"))); |
extern char STK[100]; #pragma interrupt ( g(tn=2) ) or _ _interrupt(tn=2) void g(void); |
trap_exit void g() __attribute__ ((interrupt_handler, trap_exit(2))); |
#pragma abs8(c1) #pragma abs16(i1) char c1; /* c1 is assigned to $ABS8B */ int i1; /* i1 is assigned to $ABS16B */ |
const char c1[] __attribute__ ((eightbit_data)); const int i1 __attribute__ ((tiny_data)); |
#pragma entry <function name>[<entry specification>] e.g. #pragma entry INIT(sp=0x8000) void INIT() { : } |
Achieved through linker script. |
#pragma inline (<function name>[,…]) _ _inline <type specifier> <function name> |
inline void foo (const char) __attribute__((always_inline)); |
#pragma pack 1 |
struct S { int x[2];} __attribute__ ((packed)); |
#pragma pack 2 #pragma unpack e.g. #pragma pack 2 struct S1 { char a; /* offset: 0 */ /* gap: 1 byte */ int b; /* offset: 2 */ char c; /* offset: 4 */ /* gap: 1 byte */ }; |
struct S1 {char a; int b; char c;} __attribute__ ((aligned (2))); |
#pragma global_register(x=R4) or _ _ global_register(R4L) char x; /* External variable x is allocated to R4 */ |
You can define a global register variable in GNU C like this: register int *x asm ("r4"); |
#pragma stacksize <constant> e.g. #pragma stacksize 100 <Code expansion example> .SECTION S,STACK .RES.W 50 Creates a stack section |
char stack[100] __attribute__ ((section ("STACK"))) = { 0 }; main() { /* Initialize stack pointer */ init_sp (stack + sizeof (stack)); } |
#pragma section [{<name> | <numeric value>}] #pragma abs8 section [{<name> | <numeric value>}] #pragma abs16 section [{<name> | <numeric value>}] #pragma indirect section [{<name> | <numeric value>}] |
Pragma is not available but the functionality can be achieved using __attribute__ ((section(“<section name>”))) For e.g: extern void foobar (void) __attribute__ ((section ("bar"))); Alternatively, this can be achieved using the linker
script. In section definition, the contents of an output section can be
specified by listing particular input files, listing particular input-file
sections, or combination of the two. |
#pragma asm <assembly-language instruction string> #pragma endasm |
Asm(<assembly-language instruction string>); |
#pragma regsave #pragma noregsave |
__attribute__ ((saveall)) |
For more information on the above compiler directives, please refer to the gcc manual.
Renesas Intrinsic functions | Equivalent GCC inline code |
void and_ccr(unsigned char mask) |
asm ("andc.b %0,ccr"::"g"(mask)) |
void and_exr(unsigned char mask) |
asm ("andc.b %0l,exr"::"r"(mask)) |
void dadd(unsigned char size, char *ptr1, char *ptr2, char *rst) |
extern __inline__ void dadd(unsigned char size, char *ptr1, char *ptr2, char *rst) { asm ("mov.b %0l,r4l"::"r"(size):"r4"); #if defined __H8300__ || defined __NORMAL_MODE__ asm ("mov.w %0,r3"::"r"(ptr1):"r3"); asm ("mov.w %0,r5"::"r"(ptr2):"r5"); asm ("mov.w %0,r1"::"r"(rst):"r1"); asm ("andc #0xde:8, ccr\n" "0:\n\t" "mov.b @r3+, r0l\n\t " "mov.b @r5+, r2l\n\t " "addx.b r2l, r0l\n\t" "daa r0l\n\t" "mov.b r0l,@r1\n\t" "adds #1,r1\n\t" "dec.b r4l\n\t" "bne 0b\n\t" ); #else asm ("mov.l %0,er3"::"r"(ptr1):"er3"); asm ("mov.l %0,er5"::"r"(ptr2):"er5"); asm ("mov.l %0,er1"::"r"(rst):"er1"); asm ("andc #0xde:8, ccr\n" "0:\n\t" "mov.b @er3+, r0l\n\t " "mov.b @er5+, r2l\n\t " "addx.b r2l, r0l\n\t" "daa r0l\n\t" "mov.b r0l,@er1\n\t" "inc.l #1,er1\n\t" "dec.b r4l\n\t" "bne 0b\n\t" ); #endif } |
void eepmov(char *source, char *dest, unsigned char count) void eepmov(char *source, char *dest, unsigned int count) |
extern __inline__ void eepmov(char *src, char *dest, unsigned char count) { asm("mov.b %0l,r4l"::"r"(count):"r4"); asm("extu.w r4"); #if defined __H8300__ || defined __NORMAL_MODE__ asm("mov.w %0,r5"::"r"(src):"r5"); asm("push r6"); asm("mov.w %0,r6"::"r"(dest):"r6"); asm("eepmov"); asm("pop r6"); #else asm("mov.l %0,er5"::"r"(src):"er5"); asm("push er6"); asm("mov.l %0,er6"::"r"(dest):"er6"); asm("eepmov"); asm("pop er6"); #endif } |
void dsub (unsigned char size, char *ptr1, char *ptr2, char *rst) |
extern __inline__ void dsub(unsigned char size, char *ptr1, char *ptr2, char *rst) { asm ("mov.b %0l,r4l"::"r"(size):"r4"); #if defined __H8300__ || defined __NORMAL_MODE__ asm ("mov.w %0,r3"::"r"(ptr1):"r3"); asm ("mov.w %0,r5"::"r"(ptr2):"r5"); asm ("mov.w %0,r1"::"r"(rst):"r1"); asm ("andc #0xde:8, ccr\n" "0: \n\t" "mov.b @r3+, r0l\n\t " "mov.b @r5+, r2l\n\t " "subx.b r2l, r0l\n\t" "das r0l\n\t" "mov.b r0l,@r1\n\t" "adds #1,r1\n\t" "dec.b r4l\n\t" "bne 0b \n\t" ); #else asm ("mov.l %0,er3"::"r"(ptr1):"er3"); asm ("mov.l %0,er5"::"r"(ptr2):"er5"); asm ("mov.l %0,er1"::"r"(rst):"er1"); asm ("andc #0de, ccr\n" "0: \n\t" "mov.b @er3+, r0l\n\t " "mov.b @er5+, r2l\n\t " "subx.b r2l, r0l\n\t" "das r0l\n\t" "mov.b r0l,@er1\n\t" "inc.l #1,er1\n\t" "dec.b r4l\n\t" "bne 0b\n\t" ); #endif } |
unsigned char get_imask_ccr(void) |
extern __inline__ unsigned char get_imask_ccr(void) { unsigned char imask; asm("stc ccr,r0l":::"r0"); asm("and.b #0x80,r0l"); asm("rotl.b r0l"); asm("mov.b r0l, %0l":"=g"(imask)); return(imask); } |
unsigned char get_imask_exr(void) |
extern __inline__ unsigned char get_imask_exr(void) { unsigned char imask; asm("stc exr,r0l":::"r0"); asm("and.b #0x07,r0l"); asm("mov.b r0l, %0l":"=g"(imask)); return(imask); }This is available for H8S and H8SX only. |
void mac(long val, int *ptr1, int *ptr2, unsigned long count) |
extern __inline__ void mac(long val, int *ptr1, int *ptr2, unsigned long count) { asm ("mov.l %0,er2"::"g"(count):"er2"); asm ("mov.l %0,er3"::"g"(ptr1):"er3"); asm ("mov.l %0,er0"::"g"(ptr2):"er0"); asm ("mov.l %0,er1"::"g"(val):"er1"); asm ("clrmac"); asm ("ldmac er1,macl"); asm ("mov.l er2,er2\n\t" "beq 1f\n" "0:\n\t" "mac @er0+,@er3+\n\t" "dec.l #1,er2\n\t" "bne 0b\n" "1:\n\t" ); asm ("stmac macl,er2"); }This is available for H8S and H8SX only |
macl(long, int*, int*, unsigned long, unsigned long) |
Under Process |
void nop(void) |
extern __inline__ void nop(void) { asm ("nop"); } |
void or_ccr(unsigned char mask) |
asm ("orc.b %0,ccr"::"g"(mask)) Please replace occurrence of or_ccr(mask) with above. |
void or_exr(unsigned char mask) |
asm ("orc.b %0,exr"::"r"(mask)) Please replace occurance of or_exr(mask) with above. This is available for H8S and H8SX only. |
unsigned char get_ccr(void) |
extern __inline__ unsigned char get_ccr(void) { unsigned char ccr_val; asm("stc ccr,r0l":::"r0"); asm("mov.b r0l, %0l":"=g"(ccr_val)); return(ccr_val); } |
unsigned char get_exr(void) |
extern __inline__ unsigned char get_exr(void) { unsigned char exr_val; asm("stc exr,r0l":::"r0"); asm("mov.b r0l, %0l":"=g"(exr_val)); return(exr_val); } This is available for H8S and H8SX only |
char rotlc(int count, char data) int rotlw(int count, int data) long rotll(int count, long data) char rotrc(int count, char data) int rotrw(int count, int data) long rotrl(int count, long data) |
extern __inline__ int rotlw(int count, int data) { int ires; asm("mov.w %0,r0"::"r"(count):"r0"); asm("mov.w %0,r1"::"r"(data):"r1"); asm("mov.w r0, r0"); asm("beq 1f\n" " 0:\n\t" "rotl.w r1\n\t" "dec.w #1, r0\n\t" "bne 0b\n" "1:" ); asm("mov.w r1, %0":"=g"(ires)); return(ires); } |
void set_imask_ccr(unsigned char mask) |
extern __inline__ void set_imask_ccr(unsigned char mask) { if(mask==1) asm("orc.b #0x80, ccr"); else asm("andc.b #0x7f, ccr"); } |
void set_imask_exr(unsigned char mask) |
extern __inline__ void set_imask_exr(unsigned char mask) { switch(mask) { case 0 : asm("andc.b #0xf8, exr"); break; case 7 : asm("orc.b #0x07, exr"); break; default : asm("stc exr,r0h":::"r0"); asm("and.b #0xf8, r0h":::"r0"); asm("mov %0l, r0l"::"r"(mask):"r0"); asm("or.b r0l,r0h":::"r0"); asm("ldc r0h,exr":::"r0"); break; } } This is available for H8S and H8SX only. |
void sleep(void) |
extern __inline__ void sleep(void) { asm("sleep"); } |
void tas(char *addr) |
extern __inline__ void tas(char *addr) { asm("mov.l %0, er1"::"r"(addr):"er1"); asm("tas @er1"); } This is available only for H8S. |
void trapa(unsigned int trap_no) |
asm ("trapa %0"::"g"(trap_no)) Please replace occurance of trapa(trap_no) with above. |
void set_ccr(unsigned char value) |
extern __inline__ void set_ccr(unsigned char value) { asm("mov.b %0l,r0l"::"r"(value):"r0"); asm("ldc r0l, ccr"); } |
void set_exr(unsigned char value) |
extern __inline__ void set_exr(unsigned char value) { asm("mov.b %0l,r0l"::"r"(value):"r0"); asm("ldc r0l, exr"); } This is available for H8S and H8SX only. |
void xor_ccr(unsigned char mask) |
asm("xorc.b %0,ccr"::"g"(mask)) Please replace occurrence of xor_ccr(mask) with above. |
void xor_exr(unsigned char value) |
asm("xorc.b %0,exr"::"g"(value)); Please replace occurance of xor_exr(mask) with above. This is available for H8S and H8SX only. |
int ovfaddc(char dst, char src, char *rst) int ovfadduc(unsigned char dst, unsigned char src, unsigned char *rst) int ovfaddw(int dst, int src, int *rst) int ovfadduw(unsigned int dst, unsigned int src, unsigned int *rst) int ovfaddl(long dst, long src, long *rst) int ovfaddul(unsigned long dst, unsigned long src, unsigned long *rst) |
extern __inline__ int ovfaddw(int dst, int src, int *rst) { asm ("mov.w %0, r0"::"r"(src):"r0"); asm ("mov.w %0, r1"::"r"(dst)"r1"); asm ("add.w r1, r0"); asm ("stc ccr, r2l":::"r2"); asm ("mov.w r0, @%0"::"r"(rst)); asm ("ldc r2l, ccr"); } similarly for ovfaddc, ovfadduc, ovfadduw, ovfaddl,
ovfaddul |
int ovfsubc(char dst, char src, char *rst) int ovfsubuc(unsigned char dst, unsigned char src, unsigned char *rst) int ovfsubw(int dst, int src, int *rst) int ovfsubuw(unsigned int dst, unsigned int src, unsigned int *rst) int ovfsubl(long dst, long src, long *rst) int ovfsubul(unsigned long dst, unsigned long src, unsigned long *rst) |
extern __inline__ int ovfsubw(int dst, int src, int *rst) { asm ("mov.w %0, r0"::"r"(src):"r0"); asm ("mov.w %0, r1"::"r"(dst):"r1"); asm ("sub.w r1, r0"); asm ("stc ccr, r2l":::"r2"); asm ("mov.w r0, @%0"::"r"(rst)); asm ("ldc r2l, ccr"); } similarly for ovfsubc, ovfsubuc, ovfsubuw, ovfsubl,
ovfsubul |
Int ovfshlluc(char dst, char *rst) int ovfshlluw(int dst, int *rst) int ovfshllul(long dst, long *rst) |
extern __inline__ int ovfshllul(unsigned long dst, unsigned long *rst) { asm ("mov.l %0, er1"::"r"(dst):"er1"); asm ("shal.l er1"); asm ("stc ccr, r2l":::"r2"); asm ("mov.l er1, @%0"::"r"(rst)); asm ("ldc r2l, ccr"); } similarly for ovfshlluc and ovfshlluw |
int ovfshalc(char dst, char *rst) int ovfshalw(int dst, int *rst) int ovfshall(long dst, long *rst) |
extern __inline__ int ovfshalw(int dst, int *rst) { asm ("mov.w %0, r0"::"r"(dst):"r0"); asm ("shal.w r0"); asm ("stc ccr, r1l":::"r1"); asm ("mov.w r0, @%0"::"r"(rst)); asm ("ldc r1l, ccr"); } similarly for ovfshalc and ovfshall |
int ovfnegc(char dst, char *rst) int ovfnegw(int dst, int *rst) int ovfnegl(long dst, long *rst) |
extern __inline__ int ovfnegw(int dst, int *rst) { asm ("mov.w %0, r0"::"r"(dst):"r0"); asm ("not.w r0"); asm ("add.w #1, r0"); asm ("stc ccr, r1l":::"r1"); asm ("mov.w r0, @%0"::"r"(rst)); asm ("ldc r1l, ccr"); } similarly for ovfnegc and ovfnegl |
void movfpe(char *addr, char data) |
Under Process |
void movtpe(char data, char *addr) |
Under Process |
For more information on assembler constraints, please refer to the gcc manual.
For more information on assembler command line options, please refer to the as manual.
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) | ||
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 | 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) | ||
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
Useful Links:
http://sources.redhat.com/newlib/libc.html
http://sources.redhat.com/newlib/libm.html
Renesas Assembler Directives | GNU Assembler Directives |
.AIF | #if or .if |
.AELSE | #else or .else |
.AENDI | #endif or .endif |
Sym_name: .ASSIGN value | set sym_name , value |
.ALIGN <boundary alignment value> | .align abs-expr, abs-expr, abs-expr |
.CPU targetcpu:bitwidth | .h8300s .h8300sn .h8300h .h8300hn |
sym_name: .EQU value | .equ sym_name , value |
.EXPORT | .global |
.GLOBAL | .global |
.IMPORT sym_name | .extern sym_name |
Sym_name .RES.B 1 | .size sym_name , 1 .sym_name: .byte initial_value |
Sym_name .RES.L 1 | .size sym_name , 4 .sym_name: .long initial_value |
Sym_name .RES.W 1 | .size sym_name, 2 .sym_name: .word initial_value |
__2600N__ __2000N__ __300HN__ |
__NORMAL_MODE__ |
.section name , attribute (attribute- CODE OR DATA OR STACK) |
.section “ name” , “attributes” |
H’ address | 0x address |
Sym_name: .SDATA “str” | Sym_name: .string “str” |
For more information on the above
assembler directives, please refer to the
as manual.
Using Inline Assembly Language :
We can instruct the compiler to insert the code of a function into the code of its callers, to the point where actually the call is to be made. Such functions are inline functions. This method of inlining reduces the function-call overhead. And if any of the actual argument values are constant, their known values may permit simplifications at compile time so that not all of the inline function’s code needs to be included. The effect on code size is less predictable, it depends on the particular case. To declare an inline function, we’ve to use the keyword inline in its declaration. Inline assembly is important primarily because of its ability to operate and make its output visible on C variables. Because of this capability, "asm" works as an interface between the assembly instructions and the "C" program that contains it.
Syntax
GCC, the GNU C Compiler for Linux, uses AT&T/UNIX assembly syntax.
a) Source-Destination Ordering
The first operand is the source and the second operand is the destination. ie, "Op-code src dst".
This is similar to the syntax followed in Renesas.
b) Register Naming
Register names are prefixed by % ie, if r0 is to be used, write %r0.
c) Immediate Operand
Immediate operands are preceded by ’#’. For hexadecimal constants a ’0x’ is suffixed to the constant.
However, in order to support hexadecimal constants suffixed with a 'H', please pass ‘-h-tick-hex’ option to the
assembler.
e.g., Use the following command to build the “asm("mov #H'03,R0");” code statement,
$ h8300-elf-gcc test.c -Wa,-h-tick-hex
d) Operand Size
Size of memory operands is determined from the last character of the op-code name.
Op-code suffixes of ’b’, ’w’, and ’l’ specify byte(8-bit), word(16-bit), and long (32-bit) memory references.
e) Memory Operands
Base register is enclosed in ‘(’ and ’)’ and indirect memory reference is like
“section:disp(base, index, scale)”. When a constant is used for disp and sol; scale, ’#’ shouldn’t
be prefixed.