4.1.3 Processing system dependent items

This section explains items dependent on processing system in the ANSI standards.

(1)

Data types and sizes

The byte order in a word (2 bytes) is "from least significant to most significant byte" Signed integers are expressed by 2's complements. The sign is added to the most significant bit (0 for positive or 0, and 1 for negative).

-

The number of bits of 1 byte is 8.

-

The number of bytes, byte order, and encoding in an object files are stipulated below.

Table 4.1

Data Types and Sizes

Data Types

Sizes

char

1 byte

short, int

2 bytes

long, float

4 bytes

double, long double

8 bytesNote

long long

8 bytes

near pointer

2 bytes

far pointer

4 bytes

Note

4 bytes when -dbl_size=4 is specified. -dbl_size=4 is the default setting in the CC-RL.

(2)

Translation stages

The ANSI standards specify eight translation stages (known as "phases") of priorities among syntax rules for translation. The arrangement of "non-empty white space characters excluding line feed characters" which is defined as processing system dependent in phase 3 "Decomposition of source file into preprocessing tokens and white space characters" is maintained as it is without being replaced by single white space character.

(3)

Diagnostic messages

When syntax rule violation or restriction violation occurs on a translation unit, the compiler outputs as error message containing source file name and (when it can be determined) the number of line containing the error. These error messages are classified: "Warning", "Abort error", "Fatal error" and "other" messages. For output formats of messages, see the "10.2 Message Formats".

(4)

Program startup processing

The name and type of a function that is called on starting program processing are not stipulted.

Therefore, it is dependent on the user-own coding and target system.

(5)

Program execution

The configuration of the interactive unit is not stipulated.

Therefore, it is dependent on the user-own coding and target system.

(6)

Character set

The values of elements of the execution environment character set are ASCII codes.

(7)

Multi-byte characters

Supported multi-byte characters are ECU, SJIS, UTF-8, big5 and gbk.

Japanese and Chinese description in comments and character strings is supported.

(8)

Significance of character display

The values of expanded notation are stipulated as follows.

Table 4.2

Expanded Notation and Meaning

Expanded Notation

Value (ASCII)

Meaning

\a

07

Alert (Warning tone)

\b

08

Backspace

\f

0C

Form feed (New Page)

\n

0A

New line (Line feed)

\r

0D

Carriage return (Restore)

\t

09

Horizontal tab

\v

0B

Vertical tab

(9)

Translation limit

There are no limits on translation. The maximum translatable value depends on the memory of the host machine on which the program is running.

Remark 1.

In a single declaration, the maximum number of pointer, array, and function declarators (and their combinations) that qualify a single arithmetic type, structure type, union type, or incomplete type is 128.

Remark 2.

The maximum number of bytes for one object is 32767 (in the host environment). However, when the -large_variable option is specified, the maximum number is 65,535.

(10)

Quantitative limit

(a)

The limit values of the general integer types (limits.h file)

The limits.h file specifies the limit values of the values that can be expressed as general integer types (char type, signed/unsigned integer type, and enumerated type).

The limit values defined by the limits.h file are as follows.

Table 4.3

Limit Values of General Integer Type (limits.h File)

Name

Value

Meaning

CHAR_BIT

+8

The number of bits (= 1 byte) of the minimum object not in bit field

SCHAR_MIN

-128

Minimum value of signed char

SCHAR_MAX

+127

Maximum value of signed char

UCHAR_MAX

+255

Maximum value of unsigned char

CHAR_MIN

0 (-128)

Minimum value of char (The default is the value of unsigned char. When the -signed_char option is specified, it becomes the value of signed char.)

CHAR_MAX

+255 (+127)

Maximum value of char (The default is the value of unsigned char. When the -signed_char option is specified, it becomes the value of signed char.)

SHRT_MIN

-32768

Minimum value of short int

SHRT_MAX

+32767

Maximum value of short int

USHRT_MAX

+65535

Maximum value of unsigned short int

INT_MIN

-32768

Minimum value of int

INT_MAX

+32767

Maximum value of int

UINT_MAX

+65535

Maximum value of unsigned int

LONG_MIN

-2147483648

Minimum value of long int

LONG_MAX

+2147483647

Maximum value of long int

ULONG_MAX

+4294967295

Maximum value of unsigned long int

LLONG_MIN

-9223372036854775807

Minimum value of long long int

LLONG_MAX

+9223372036854775807

Maximum value of long long int

ULLONG_MAX

+18446744073709551615

Maximum value of unsigned long long int

(b)

The limit values of the floating-point type (float.h file)

The limit values related to characteristics of the floating-point type are defined in float.h file.

The limit values defined by the float.h file are as follows.

The values in parentheses are for the case when the -dbl_size=4 option is used, which specifies sizeof(double) = sizeof(long double) = 4. -dbl_size=4 is the default setting in the CC-RL.

Table 4.4

Definition of Limit Values of Floating-point Type (float.h File)

Name

Value

Meaning

FLT_ROUNDS

+1

Rounding mode for floating-point addition.

1 for the RL78 family (rounding in the nearest direction).

FLT_RADIX

+2

Radix of exponent (b)

FLT_MANT_DIG

+24

Number of numerals (p) with FLT_RADIX of floating- point mantissa as base

DBL_MANT_DIG

+53 (+24)

LDBL_MANT_DIG

+53 (+24)

FLT_DIG

+6

Number of digits of a decimal number (q) that can round a decimal number of q digits to a floating-point number of p digits of the radix b and then restore the decimal number of q

DBL_DIG

+15 (+6)

LDBL_DIG

+15 (+6)

FLT_MIN_EXP

-125

Minimum negative integer (emin) that is a normalized floating-point number when FLT_RADIX is raised to the power of the value of FLT_RADIX minus 1.

DBL_MIN_EXP

-1021 (-125)

LDBL_MIN_EXP

-1021 (-125)

FLT_MIN_10_EXP

-37

Minimum negative integer log10bemin-1 that falls in the range of a normalized floating-point number when 10 is raised to the power of its value.

DBL_MIN_10_EXP

-307 (-37)

LDBL_MIN_10_EXP

-307 (-37)

FLT_MAX_EXP

+128

Maximum integer (emax) that is a finite floating-point number that can be expressed when FLT_RADIX is raised to the power of its value minus 1.

DBL_MAX_EXP

+1024 (+128)

LDBL_MAX_EXP

+1024 (+128)

FLT_MAX_10_EXP

+38

Maximum integer that falls in the range of a normalized floating-point number when 10 is raised to this power.

log10 ((1 - b-p) * bemax)

DBL_MAX_10_EXP

+308 (+38)

LDBL_MAX_10_EXP

+308 (+38)

FLT_MAX

3.40282347E + 38F

Maximum value of finite floating-point numbers that can be expressed

(1 - b-p) * bemax

DBL_MAX

1.7976931348623158E+308 (3.40282347E+38F)

LDBL_MAX

1.7976931348623158E+308 (3.40282347E+38F)

FLT_EPSILON

1.19209290E - 07F

Difference between 1.0 that can be expressed by specified floating-point number type and the lowest value which is greater than 1.

b1 - p

DBL_EPSILON

2.2204460492503131E-016 (1.19209290E - 07)

LDBL_EPSILON

2.2204460492503131E-016 (1.19209290E - 07F)

FLT_MIN

1.17549435E - 38F

Minimum value of normalized positive floating-point number

bemin - 1

DBL_MIN

2.2250738585072014E-308 (1.17549435E - 38F)

LDBL_MIN

2.2250738585072014E-308 (1.17549435E - 38F)

(11)

Identifier

All identifiers are considered to have meaning.

Uppercase and lowercase characters are distinguished.

(12)

char type

If a quantity that is not a member of the source character set is stored in the char type, it is handled as the value converted to the char type.

When the -signed_char option is not used, the simple char type is handled as unsigned char. When the -signed_char option is used, the simple char type is handled as signed char.

char    ch = '\777';     /*Value of ch is +255.*/

(13)

Floating-point constants

A value is rounded toward the result obtained by assuming an infinite number of significant digits. The center value between a multiplication result and the result obtained by assuming an infinite number of significant digits is rounded so that the result becomes an even value.

(14)

Character constants

(a)

Both the character set of the source program and the character set in the execution environment are basically ASCII codes, and correspond to members having the same value.
However, for the character set of the source program, character codes in Japanese can be used (see "(8) Significance of character display").

(b)

The last character of the value of an integer character constant including two or more characters is valid.

(c)

A character that cannot be expressed by the basic execution environment character set or escape sequence is expressed as follows.

<1>

An octal or hexadecimal escape sequence takes the value indicated by the octal or hexadecimal notation

\777

511

<2>

The simple escape sequence is expressed as follows.

\'

'

\"

"

\?

?

\\

\

<3>

Values of \a, \b, \f, \n, \r, \t, \v are same as the values explained in "(8) Significance of character display".

(d)

Character constants of multi byte characters are not supported.

(15)

Character string

A character string can be described in Japanese and Chinese.

The default character code is Shift JIS.

A character code in input source file can be selected by using the -character_set option of the CC-RL.

-character_set=[none | euc_jp | sjis | utf8 | big5 | gbk]

(16)

Header file name

The method to reflect the string in the two formats (< > and " ") of a header file name on the header file or an external source file name is stipulated in "(34) Loading header file".

(17)

Comment

A comment can be described in Japanese and Chinese. The character code is the same as the character string in "(15) Character string".

(18)

Character and integer types

A simple char type not specified as signed or unsigned is handled as unsigned. When the -signed_char option is specified, it is handled as signed.

(19)

Signed constants and unsigned constants

If the value of a general integer type is converted into a signed integer of a smaller size, the higher bits are truncated and a bit string image is copied.

If an unsigned integer is converted into the corresponding signed integer, the internal representation is not changed.

(20)

Floating-points and general integers

If the value of a general integer type is converted into the value of a floating-point type, and if the value to be converted is within a range that can be expressed but not accurately, the result is rounded toward the result obtained by assuming an infinite number of significant digits. An intermediate value is rounded so that the result becomes an even value.

(21)

double type and float type

When casting a double to a float, or a long double to a double or a float, if the typecast value cannot be represented accurately in the available value range, the result is rounded toward the result obtained by assuming an infinite number of significant digits. An intermediate value is rounded so that the result becomes an even value.

(22)

Signed type in operator in bit units

The characteristics of the shift operator conform to the stipulation in "(28) Shift operator in bit units".

The other operators in bit units for signed type are calculated as unsigned values (as in the bit image).

(23)

Members of structures and unions

If the value of a union member is stored in a different member, the value will be stored in accordance with the alignment condition. As a result, access to members of the union will be of the subsequently accessed type.

(24)

sizeof operator

The result of the "sizeof" operator is handled as the unsigned int type.

(25)

Cast operator

When a pointer is converted to a general integer type, the required variable size is as follows.

-

near : 2 -byte

-

far : 4-byte

 

The bit string is saved as is as the conversion result. Note that the most significant byte (undefined value) of a far pointer is converted to 0.

Any integer can be converted to a pointer type but if the size of the pointer type is smaller than that of the integer type, the value is truncated to the pointer size. If the size of the pointer type is larger than that of the integer type, the integer type is normally converted up to the pointer size and then converted to the pointer type.

As the near and far pointers affect conversion, see the "Cast" description in "Specifying memory allocation area (__near /__far)".

(26)

Division/remainder operator

The result of the division operator ("/") when the operands are negative and do not divide perfectly with integer division, is as follows: If either the divisor or the dividend is negative, the result is the smallest integer greater than the algebraic quotient.

If both the divisor and the dividend are negative, the result is the largest integer less than the algebraic quotient.

If the operand is negative, the result of the "%" operator takes the sign of the first operand in the expression.

(27)

Addition and subtraction operators

If two pointers indicating the elements of the same array are subtracted, the type of the result is signed int type.

(28)

Shift operator in bit units

If E1 of "E1 >> E2" is of signed type and takes a negative value, an arithmetic shift is executed.

(29)

Storage area class specifier

Optimize for the fastest possible access, regardless of whether there is a storage-class area specifier "register" declaration.

(30)

Structure and union specifier

(a)

A simple int type bit field not specified as signed or unsigned is handled as an unsigned int type. However, when the -signed_bitfield option is specified, it becomes the value of signed int.

(b)

To retain a bit field, a storage area unit to which any address with sufficient size can be assigned can be allocated. If there is insufficient area, however, the bit field that does not match is packed into to the next unit according to the alignment condition of the type of the field.
The allocation sequence of the bit field in unit is from lower to higher.

(c)

Each member of the non-bit field of one structure or union is aligned at a boundary as follows:

_Bool, char, signed char, unsigned char type

1-byte enumerated type and its array

1-byte boundary

Types other than the above except for structure type and union type, and 2-byte enumerated type

2-byte boundary

 

When a member is a structure or union object, it is aligned to the boundary specified in the structure or union definition of the member.

(31)

Enumerated type specifier

The type of an enumerator is char, signed char, unsigned char, or signed short depending on the range of the enumeration constants to be defined. For the details of description, see "(4) Enumerated type".

(32)

Type qualifier

The configuration of access to data having a type qualified to be "volatile" is dependent upon the address (I/O port, etc.) to which the data is mapped. However, optimization is not applied to the locations where such a variable is accessed.

The size of access to such a variable is guaranteed when the following conditions are satisfied.

-

When a variable is not a bit field and is declared in any of the following types, the variable is accessed in the same size as the declared type.

-

(signed/unsigned)int

-

(signed/unsigned)short

-

near variable pointer

-

near function pointer

-

(signed/unsigned)char

-

_Bool

-

Enumerated type

(33)

Condition embedding

(a)

The value for the constant specified for condition embedding and the value of the character constant appearing in the other expressions are equal.

(b)

A single-character character constant cannot have a negative value.

(34)

Loading header file

(a)

A preprocessing directive in the form of "#include <character string>"

A preprocessing directive in the form of "#include <character string>" searches for a header file from the folder specified by the -I option if "character string" does not begin with "\"Note, and then searches standard include file folder (..\inc folder with a relative path from the bin folder where the ccrl is placed).

If a header file uniformly identified is searched with a character string specified between delimiters "<" and ">", the whole contents of the header file are replaced.

Note

"/" are regarded as the delimiters of a folder.

Example

#include    <header.h>

 

The search order is as follows.

-

Folder specified by -I

-

Standard include file folder

(b)

A preprocessing directive in the form of "#include "character string""

A preprocessing directive in the form of "#include "character string"" searches for a header file from the folder where the source file exists if "character string" does not begin with "\"Note, and then searches specified folder (-I option), and then searches standard include file folder (..\inc folder with a relative path from the bin folder where the ccrl is placed).

If a header file uniformly identified is searched with a character string specified between delimiters " " " and " " ", the whole contents of the header file are replaced.

Note

"/" are regarded as the delimiters of a folder.

Example

#include    "header.h"

 

The search order is as follows.

-

Folder including the current file to be translated (file containing #include "character string")

-

Folder specified by -I

-

Standard include file folder

(c)

The format of "#include preprocessing character phrase string"

The format of "#include preprocessing character phrase string" is treated as the preprocessing character phrase of single header file only if the preprocessing character phrase string is a macro that is replaced to the form of <character string> or "character string".

(d)

A preprocessing directive in the form of "#include <character string>"

Between a string delimited (finally) and a header file name, the length of the alphabetic characters in the strings is identified,

"And the file name length valid in the compiler operating environment is valid."

The folder where the file is searched for conforms to the above stipulation.

(35)

#pragma directive

The CC-RL can specify the following #pragma directives.

(a)

Interrupt handler specification

#pragma interrupt    [(]Function-name[(interrupt specification [,...])][)]
#pragma interrupt_brk   [(]Function-name[(interrupt specification [,...])][)]

 

Interrupt handlers are described in C language.

For the details of description, see "Hardware interrupt handler (#pragma interrupt)" and "Software interrupt handler (#pragma interrupt_brk)".

(b)

Section allocation

#pragma section [ section-type][ new-section-name]

 

Allocates variables to an arbitrary section.

For the details of description, see "Changing compiler output section name (#pragma section)".

(c)

Inline expansion specification

#pragma inline      [(]function-name [,...][)]
#pragma noinline    [(]function-name [,...][)]

 

A function that is expanded inline can be specified.

For the details of expansion specification, see "Inline expansion of function (#pragma inline, #pragma noinline)".

(d)

Interrupt handler for RTOS specification

#pragma rtos_interrupt  [(]function-name[(vect=address)][)]

 

Interrupt handlers for RTOS are described in C language.

For the details of description, see "Interrupt handler for RTOS (#pragma rtos_interrupt)".

(e)

Task for RTOS

#pragma rtos_task   [(]task-function-name [ ,...][)]

 

The task for RTOS is described by C language.

For the details of description, see "Task function for RTOS (#pragma rtos_task)".

(f)

Specifying absolute address

#pragma address [(]variable-name=absolute-address[,...][)]

 

This specifies an absolute address.

For details of description, see "Absolute address allocation specification (#pragma address)".

(g)

Describing assembler instruction

#pragma inline_asm  [(]function-name [,...][)]

 

Assembler directives can be described in a C source program.

For the details of description, see "Describing assembler instruction (#pragma inline_asm)".

(36)

Predefined macro names

All the following macro names are supported.

Table 4.5

List of Supported Macros

Macro Name

Definition

__LINE__

Line number of source line at that point (decimal).

__FILE__

Name of source file (character string constant).

__DATE__

Date of translating source file (character string constant in the form of "Mmm dd yyyy"). Here, the name of the month is the same as that created by the asctime function stipulated by ANSI standards (3 alphabetic characters with only the first character is capital letter) (The first character of dd is blank if its value is less than 10).

__TIME__

Translation time of source file (character string constant having format "hh:mm:ss" similar to the time created by the asctime function).

__STDC__

Decimal constant 1 (defined when the -ansi option is specified).Note

__RENESAS__

Decimal constant 1.

__RENESAS_VERSION__

If the version is V.XX.YY.ZZ, this will be 0xXXYYZZ00.

Example) V.1.00.00 -> -D__RENESAS_VERSION__=0x01000000

__RL78__

Decimal constant 1.

__RL78_S1__

Decimal constant 1 (defined when S1 is specified by the -cpu option).

__RL78_S2__

Decimal constant 1 (defined when S2 is specified by the -cpu option).

__RL78_S3__

Decimal constant 1 (defined when S3 is specified by the -cpu option).

__RL78_SMALL__

Decimal constant 1 (defined when small is specified by the -memory_model option or when S1 is specified by the -cpu option while the -memory_model option is not specified).

__RL78_MEDIUM__

Decimal constant 1 (defined when medium is specified by the -memory_model option or when S2 or S3 is specified by the -cpu option while the
-memory_model option is not specified).

__CCRL__

Decimal constant 1.

__CCRL

Decimal constant 1.

__DBL4

Decimal constant 1 (defined when 4 is specified by the -dbl_size option).

__DBL8

Decimal constant 1 (defined when 8 is specified by the -dbl_size option).

__SCHAR

Decimal constant 1 (defined when the -signed_char option is specified).

__UCHAR

Decimal constant 1 (defined when the -signed_char option is not specified).

__SBIT

Decimal constant 1 (defined when the -signed_bitfield option is specified).

__UBIT

Decimal constant 1 (defined when the -signed_bitfield option is not specified).

__FAR_ROM__

Decimal constant 1 (defined when the -far_rom option is specified).

__CNV_CA78K0R__

Decimal constant 1 (defined when ca78k0r is specified by the -convert_cc option).

__CNV_NC30__

Decimal constant 1 (defined when nc30 is specified by the -convert_cc option).

__CNV_IAR__

Decimal constant 1 (defined when iar is specified by the -convert_cc option)

__BASE_FILE__

C source file name (character string constant).

Unlike __FILE__, the C source file name is returned even when used in an include file.

__STDC_VERSION__

Decimal constant 199409L (defined when the -ansi option is specified).Note

Note

For the processing to be performed when the -ansi option is specified, see "4.1.5 Option to process in strict accordance with ANSI standard".