Everything
4.2.6.7 Intrinsic functions

In the CC-RH, some of the assembler instructions can be described in C source as "Intrinsic functions". However, it is not described "as assembler instruction", but as a function format set in the CC-RH.

If a parameter is specified whose type cannot be implicitly converted to that of the parameter of the intrinsic function, then an warning is output, and it is treated as an intrinsic function.

See the user's manual of the relevant device for operation when a register number not available in hardware is specified for ldsr/stsr.

The instructions that can be described as functions are as follows.

Table 4.20

Assembler Instruction (1)

Assembler Instruction

Function

Intrinsic Function

di

Interrupt control

void __DI(void);
ei
void __EI(void);
-

Interrupt-priority-level controlNote 1

void __set_il_rh(long NUM, void* ADDRNote 2);
 

-

NUM : 1 - 16

  movhi highw1(ADDR), r0, rX
  ld.b  loww(ADDR)[rX], rY
  andi  0x00F0, rY, rY
  ori   (Priority - 1), rY, rY
  st.b  loww(ADDR)[rX]

-

NUM : 0

  movhi highw1(ADDR), r0, rX
  clr1  7, loww(ADDR)[rX]

-

NUM : -1

  movhi highw1(ADDR), r0, rX
  set1  7, loww(ADDR)[rX]

-

NUM : -2

  movhi highw1(ADDR), r0, rX
  clr1  6, loww(ADDR)[rX]

-

NUM : -3

  movhi highw1(ADDR), r0, rX
  set1  6, loww(ADDR)[rX]

-

NUM : No greater than 4 and no less than 17

  Out-of-range error
nop

No operation

void __nop(void);
halt

Stops the processor

void __halt(void);
satadd

Saturated addition

long __satadd(long a, long b);
satsub

Saturated subtraction

long __satsub(long a, long b);
bsh

Halfword data byte swap

long __bsh(long a);
bsw

Word data byte swap

long __bsw(long a);
hsw

Word data halfword swap

long __hsw(long a);
mul

Instruction that assigns higher 32 bits of signed 64-bit multiplication result to variable

long __mul32(long a, long b);
mulu

Instruction that assigns higher 32 bits of unsigned 64-bit multiplication result to variable

unsigned long __mul32u(unsigned long a, unsigned long b);
sch0l

Bit (0) search from MSB side

long __sch0l(long a);
sch0r

Bit (0) search from LSB side

long __sch0r(long a);
sch1l

Bit (1) search from MSB side

long __sch1l(long a);
sch1r

Bit (1) search from LSB side

long __sch1r(long a);
ldsr

Loads to system register

void __ldsr(long regIDNote 3, unsigned long a);
ldsr

Loads to system register

void __ldsr_rh(long regIDNote 3, long selIDNote 3, unsigned long a);
stsr

Stores contents of system register

unsigned long __stsr(long regIDNote 3);
stsr

Stores contents of system register

unsigned long __stsr_rh(long regIDNote 3, long selIDNote 3);
caxi

Compare and Exchange

long __caxi(long *a, long b, long c);
clr1

Bit clear

void __clr1(unsigned char *a, long bit);
set1

Bit set

void __set1(unsigned char *a, long bit);
not1

Bit not

void __not1(unsigned char *a, long bit);
ldl.wNote 4

Atomic load.

long __ldlw(long *a);
stc.wNote 4

Store

void __stcw(long *a, long b); [V1.04.00 or earlier]
long __stcw(long *a, long b); [V1.05.00 or later]
synce

Exception synchronization

void __synce(void);
synci

Instruction pipeline synchronization

void __synci(void);
syncm

Memory synchronization

void __syncm(void);
syncp

Pipeline synchronization

void __syncp(void);
dbcp

Debug checkpoint

void __dbcp(void);
dbpush

Debug push

void __dbpush(long regID1, long regID2);
dbtag

Debug tag

void __dbtag(long a);

Note 1.

The __set_il_rh function can be used only when the –Xcpu={g3m|g3k|g3mh|g3kh} option is specified.

Note 2.

For ADDR, specify the address of the interrupt control register.

Note 3.

Specified the system register number (0 to 31) in regID and 0 to 31 in selID.

Note 4.

A warning is output when the -Xcpu=g3k option is used.

Caution

Even if a function is defined with the same name as an intrinsic function, it cannot be used.
If an att isempt made to call such a function, processing for the intrinsic function provided by the compiler takes precedence.

 

When the -Xcpu=g4mh option is specified, the following intrinsic functions can also be used.

Table 4.21

Assembler Instruction (2)

Assembler Instruction

Function

Intrinsic Function

clip.b

Conversion of signed word data to byte data with saturation

long __clipb(long a);

clip.bu

Conversion of unsigned word data to byte data with saturation

unsigned long __clipbu(unsigned long a);

clip.h

Conversion of signed word data to halfword data with saturation

long __cliph(long a);

clip.hu

Conversion of unsigned word data to halfword data with saturation

unsigned long __cliphu(unsigned long a);

ldl.bu

Load which starts atomic byte data manipulation

long __ldlbu(unsigned char* a);

ldl.hu

Load which starts atomic halfword data manipulation

long __ldlhu(unsigned short* a);

stc.b

Store on the condition that byte data manipulation has been completed atomically

long __stcb(unsigned char* a, unsigned char b);

stc.h

Store on the condition that halfword data manipulation has been completed atomically

long __stch(unsigned short* a, unsigned short b);