Everything
4.2.6 Intrinsic Functions

In the CCRX, 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 CCRX. When an intrinsic function is used, the compiler inserts the corresponding code into the program.

Table 4.10

Intrinsic Functions

No.

Item

Specifications

Function

Restriction in User Mode*

1

Maximum value and minimum value

signed long max(signed long data1, signed long data2)

Selects the maximum value.

O

signed long __max(signed long data1, signed long data2) [V2.05.00 or later]

2

signed long min(signed long data1, signed long data2)

Selects the minimum value.

O

signed long __min(signed long data1, signed long data2) [V2.05.00 or later]

3

Byte switch

unsigned long revl(unsigned long data)

Reverses the byte order in longword data.

O

unsigned long __revl(unsigned long data) [V2.05.00 or later]

4

unsigned long revw(unsigned long data)

Reverses the byte order in longword data in word units.

O

unsigned long __revw(unsigned long data) [V2.05.00 or later]

5

Data exchange

void xchg(signed long *data1, signed long *data2)

Exchanges data.

O

void __xchg(signed long *data1, signed long *data2) [V2.05.00 or later]

6

Multiply-and-accumulate operation

long long rmpab(long long init, unsigned long count, signed char *addr1, signed char *addr2)

Multiply-and-accumulate operation (byte).

O

long long __rmpab(long long init, unsigned long count, signed char *addr1, signed char *addr2) [V2.05.00 or later]

7

long long rmpaw(long long init, unsigned long count, short *addr1, short *addr2)

Multiply-and-accumulate operation (word).

O

long long __rmpaw(long long init, unsigned long count, short *addr1, short *addr2) [V2.05.00 or later]

8

long long rmpal(long long init, unsigned long count, long *addr1, long *addr2)

Multiply-and-accumulate operation (longword).

O

long long __rmpal(long long init, unsigned long count, long *addr1, long *addr2) [V2.05.00 or later]

9

Rotation

unsigned long rolc(unsigned long data)

Rotates data including the carry to left by one bit.

O

unsigned long __rolc(unsigned long data) [V2.05.00 or later]

10

unsigned long rorc(unsigned long data)

Rotates data including the carry to right by one bit.

O

unsigned long __rorc(unsigned long data) [V2.05.00 or later]

11

unsigned long rotl(unsigned long data, unsigned long num)

Rotates data to left.

O

unsigned long __rotl(unsigned long data, unsigned long num) [V2.05.00 or later]

12

unsigned long rotr(unsigned long data, unsigned long num)

Rotates data to right.

O

unsigned long __rotr(unsigned long data, unsigned long num) [V2.05.00 or later]

13

Special instructions

void brk(void)

BRK instruction exception.

O

void __brk(void) [V2.05.00 or later]

14

void int_exception(signed long num)

INT instruction exception.

O

void __int_exception(signed long num) [V2.05.00 or later]

15

void wait(void)

Stops program execution.

×

void __wait(void) [V2.05.00 or later]

16

void nop(void)

Expanded to a NOP instruction.

O

void __nop(void) [V2.05.00 or later]

17

Processor interrupt priority level (IPL)

void set_ipl(signed long level)

Sets the interrupt priority level.

×

void __set_ipl(signed long level) [V2.05.00 or later]

18

unsigned char get_ipl(void)

Refers to the interrupt priority level.

O

unsigned char __get_ipl(void) [V2.05.00 or later]

19

Processor status word (PSW)

void set_psw(unsigned long data)

Sets a value for PSW.

Δ

void __set_psw(unsigned long data) [V2.05.00 or later]

20

unsigned long get_psw(void)

Refers to PSW value.

O

unsigned long __get_psw(void) [V2.05.00 or later]

21

Floating-point status word (FPSW)

void set_fpsw(unsigned long data)

Sets a value for FPSW.

O

void __set_fpsw(unsigned long data) [V2.05.00 or later]

22

unsigned long get_fpsw(void)

Refers to FPSW value.

O

unsigned long __get_fpsw(void) [V2.05.00 or later]

23

User stack pointer (USP)

void set_usp(void *data)

Sets a value for USP.

O

void __set_usp(void *data) [V2.05.00 or later]

24

void *get_usp(void)

Refers to USP value.

O

void *__get_usp(void) [V2.05.00 or later]

25

Interrupt stack pointer (ISP)

void set_isp(void *data)

Sets a value for ISP.

Δ

void __set_isp(void *data) [V2.05.00 or later]

26

void *get_isp(void)

Refers to ISP value.

O

void *__get_isp(void) [V2.05.00 or later]

27

Interrupt table register (INTB)

void set_intb(void *data)

Sets a value for INTB.

Δ

void __set_intb(void *data) [V2.05.00 or later]

28

void *get_intb(void)

Refers to INTB value.

O

void *__get_intb(void) [V2.05.00 or later]

29

Backup PSW (BPSW)

void set_bpsw(unsigned long data)

Sets a value for BPSW.

Δ

void __set_bpsw(unsigned long data) [V2.05.00 or later]

30

unsigned long get_bpsw(void)

Refers to BPSW value.

O

unsigned long __get_bpsw(void) [V2.05.00 or later]

31

Backup PC (BPC)

void set_bpc(void *data)

Sets a value for BPC.

Δ

void __set_bpc(void *data) [V2.05.00 or later]

32

void *get_bpc(void)

Refers to BPC value.

O

void *__get_bpc(void) [V2.05.00 or later]

33

Fast interrupt vector register (FINTV)

void set_fintv(void *data)

Sets a value for FINTV.

Δ

void __set_fintv(void *data) [V2.05.00 or later]

34

void *get_fintv(void)

Refers to FINTV value.

O

void *__get_fintv(void) [V2.05.00 or later]

35

Significant
64-bit multiplication

signed long long emul(signed long data1, signed long data2)

Signed multiplication of significant 64 bits.

O

signed long long __emul(signed long data1, signed long data2) [V2.05.00 or later]

36

unsigned long long emulu(unsigned long data1, unsigned long data2)

Unsigned multiplication of significant 64 bits.

O

unsigned long long __emulu(unsigned long data1, unsigned long data2) [V2.05.00 or later]

37

Processor mode (PM)

void chg_pmusr(void)

Switches to user mode.

Δ

void __chg_pmusr(void) [V2.05.00 or later]

38

Accumulator (ACC)

void set_acc(signed long long data)

Sets the ACC.

O

void __set_acc(signed long long data) [V2.05.00 or later]

39

signed long long get_acc(void)

Refers to the ACC.

O

signed long long __get_acc(void) [V2.05.00 or later]

40

Control of the interrupt enable bits

void setpsw_i(void)

Sets the interrupt enable bit to 1.

Δ

void __setpsw_i(void) [V2.05.00 or later]

41

void clrpsw_i(void)

Clears the interrupt enable bit to 0.

Δ

void __clrpsw_i(void) [V2.05.00 or later]

42

Multiply-and-accumulate operation

long macl(short *data1, short *data2, unsigned long count)

Multiply-and-accumulate operation of 2-byte data.

O

long __macl(short *data1, short *data2, unsigned long count) [V2.05.00 or later]

43

short macw1(short *data1, short *data2, unsigned long count)

short macw2(short *data1, short *data2, unsigned long count)

Multiply-and-accumulate operation of fixed-point data.

O

short __macw1(short *data1, short *data2, unsigned long count) [V2.05.00 or later]

short __macw2(short *data1, short *data2, unsigned long count) [V2.05.00 or later]

44

Exception vector table register (EXTB)

void set_extb(void *data)

Sets a value for EXTB.

Δ

void __set_extb(void *data) [V2.05.00 or later]

45

void *get_extb(void)

Refers to EXTB value.

O

void *__get_extb(void) [V2.05.00 or later]

46

Bit manipulation

void __bclr(unsigned char *data, unsigned long bit) [V2.05.00 or later]

Clears one bit.

O

47

void __bset(unsigned char *data, unsigned long bit) [V2.05.00 or later]

Sets one bit.

O

48

void __bnot(unsigned char *data, unsigned long bit) [V2.05.00 or later]

Reverses one bit.

O

49

Double-precision floating-point status word (DPSW)

void __set_dpsw(unsigned long data)

[V3.01.00 or later]

Sets a value in DPSW.

O

50

unsigned long __get_dpsw(void)

[V3.01.00 or later]

Refers to the DPSW value.

O

51

Double-precision floating-point exception handling operation control register (DECNT)

void __set_decnt(unsigned long data)

[V3.01.00 or later]

Sets a value in DECNT.

O

52

unsigned long __get_decnt(void)

[V3.01.00 or later]

Refers to the DECNT value.

O

53

Double-precision floating-point exception program counter (DEPC)

void *__get_depc(void)

[V3.01.00 or later]

Refers to the DEPC value.

O

54

Trigonometric function unit

void __init_tfu(void)

[V3.01.00 or later]

Initializes the trigonometric function unit.

O

55

void __sincosf(float f, float *sin, float *cos)

[V3.01.00 or later]

Uses the trigonometric function unit to calculate the sine and cosine of an angle at the same time (single precision).

O

56

void __atan2hypotf(float y, float x, float *atan2, float *hypot)

[V3.01.00 or later]

Uses the trigonometric function unit to calculate the arc tangent of x and y and the square root of the sum of squares of these

 

values ( ) at the same time (single precision).

O

Note

* Indicates whether the function is limited when the RX processor mode is user mode.
O: Has no restriction.
×: Must not be used in user mode because a privileged instruction exception occurs.
Δ: Has no effect when executed in user mode.

 

 

signed long max(signed long data1, signed long data2)

signed long __max(signed long data1, signed long data2) [V2.05.00 or later]

[Description]

Selects the greater of two input values (this function is expanded into a MAX instruction).

[Header]

<machine.h>

[Parameters]

data1 Input value 1

data2 Input value 2

[Return value]

The greater value of data1 and data2

[Example]

#include <machine.h>
extern signed long ret,in1,in2;
void main(void)
{
    ret = max(in1,in2);// Stores the greater value of in1 and in2 in ret.
}

[Remarks]

The header does not have to be included when using an intrinsic function whose name starts with __.

 

 

 

signed long min(signed long data1, signed long data2)

signed long __min(signed long data1, signed long data2) [V2.05.00 or later]

[Description]

Selects the smaller of two input values (this function is expanded into a MIN instruction).

[Header]

<machine.h>

[Parameters]

data1 Input value 1

data2 Input value 2

[Return value]

The smaller value of data1 and data2

[Example]

#include <machine.h>
extern signed long ret,in1,in2;
void main(void)
{
    ret = min(in1,in2);// Stores the smaller value of in1 and in2 in ret.
}

[Remarks]

The header does not have to be included when using an intrinsic function whose name starts with __.

 

 

 

unsigned long revl(unsigned long data)

unsigned long __revl(unsigned long data) [V2.05.00 or later]

[Description]

Reverses the byte order in 4-byte data (this function is expanded into a REVL instruction).

[Header]

<machine.h>

[Parameters]

data Data for which byte order is to be reversed

[Return value]

Value of data with the byte order reversed

[Example]

#include <machine.h>
extern unsigned long ret,indata=0x12345678;
void main(void)
{
    ret = revl(indata);// ret = 0x78563412
}

[Remarks]

The header does not have to be included when using an intrinsic function whose name starts with __.

 

 

 

unsigned long revw(unsigned long data)

unsigned long __revw(unsigned long data) [V2.05.00 or later]

[Description]

Reverses the byte order within each of the upper and lower two bytes of 4-byte data (this function is expanded into a REVW instruction).

[Header]

<machine.h>

[Parameters]

data Data for which byte order is to be reversed

[Return value]

Value of data with the byte order reversed within the upper and lower two bytes

[Example]

#include <machine.h>
extern unsigned long ret;indata=0x12345678;
void main(void)
{
    ret = revw(indata);// ret = 0x34127856 
}

[Remarks]

The header does not have to be included when using an intrinsic function whose name starts with __.

 

 

 

void xchg(signed long *data1, signed long *data2)

void __xchg(signed long *data1, signed long *data2) [V2.05.00 or later]

[Description]

Exchanges the contents of the areas indicated by parameters (this function is expanded into an XCHG instruction).

[Header]

<machine.h>

[Parameters]

*data1 Input value 1

*data2 Input value 2

[Example]

#include <machine.h>
extern signed long *in1,*in2;
void main(void)
{
    xchg (in1,in2);// Exchanges data at address in1 and address in2.
}

[Remarks]

The XCHG instruction to be generated has a memory operand with a location indicated by data2.

The header does not have to be included when using an intrinsic function whose name starts with __.

 

 

 

long long rmpab(long long init, unsigned long count, signed char *addr1, signed char *addr2)

long long __rmpab(long long init, unsigned long count, signed char *addr1, signed char *addr2) [V2.05.00 or later]

[Description]

Performs a multiply-and-accumulate operation with the initial value specified by init, the number of multiply-and-accumulate operations specified by count, and the start addresses of values to be multiplied specified by addr1 and addr2 (this function is expanded into a RMPA.B instruction).

[Header]

<machine.h>

[Parameters]

init Initial value

count Count of multiply-and-accumulate operations

*addr1 Start address of values 1 to be multiplied

*addr2 Start address of values 2 to be multiplied

[Return value]

Lower 64 bits of the init + Σ(data1[n] * data2[n]) result (n = 0, 1, ..., const - 1)

[Example]

#include <machine.h>
extern signed char data1[8],data2[8];
long long sum;
void main(void)
{
    sum=rmpab(0, 8, data1, data2);
        // Specifies 0 as the initial value, adds the result 
        // of multiplication of arrays data1 and data2, 
        // and stores the result in sum.
}

[Remark]

The RMPA instruction obtains a result in a maximum of 80 bits, but this intrinsic function handles only 64 bits.

The header does not have to be included when using an intrinsic function whose name starts with __.

 

 

 

long long rmpaw(long long init, unsigned long count, short *addr1, short *addr2)

long long __rmpaw(long long init, unsigned long count, short *addr1, short *addr2) [V2.05.00 or later]

[Description]

Performs a multiply-and-accumulate operation with the initial value specified by init, the number of multiply-and-accumulate operations specified by count, and the start addresses of values to be multiplied specified by addr1 and addr2 (this function is expanded into a RMPA.W instruction).

[Header]

<machine.h>

[Parameters]

init Initial value

count Count of multiply-and-accumulate operations

*addr1 Start address of values 1 to be multiplied

*addr2 Start address of values 2 to be multiplied

[Return value]

Lower 64 bits of the init + Σ(data1[n] * data2[n]) result (n = 0, 1, ..., const - 1)

[Example]

#include <machine.h>
extern signed short data1[8],data2[8];
long long sum;
void main(void)
{
    sum=rmpaw(0, 8, data1, data2); 
        // Specifies 0 as the initial value, adds the result
        // of multiplication of arrays data1 and data2, 
        // and stores the result in sum.
}

[Remark]

The RMPA instruction obtains a result in a maximum of 80 bits, but this intrinsic function handles only 64 bits.

The header does not have to be included when using an intrinsic function whose name starts with __.

 

 

 

long long rmpal(long long init, unsigned long count, long *addr1, long *addr2)

long long __rmpal(long long init, unsigned long count, long *addr1, long *addr2) [V2.05.00 or later]

[Description]

Performs a multiply-and-accumulate operation with the initial value specified by init, the number of multiply-and-accumulate operations specified by count, and the start addresses of values to be multiplied specified by addr1 and addr2 (this function is expanded into a RMPA.L instruction).

[Header]

<machine.h>

[Parameters]

init Initial value

count Count of multiply-and-accumulate operations

*addr1 Start address of values 1 to be multiplied

*addr2 Start address of values 2 to be multiplied

[Return value]

Lower 64 bits of the init + Σ(data1[n] * data2[n]) result (n = 0, 1, ..., const - 1)

[Example]

#include <machine.h>
extern signed long data1[8],data2[8];
long long sum;
void main(void)
{
    sum=rmpal(0, 8, data1, data2); 
        // Specifies 0 as the initial value, adds the result 
        // of multiplication of arrays data1 and data2, 
        // and stores the result in sum.
}

[Remarks]

The RMPA instruction obtains a result in a maximum of 80 bits, but this intrinsic function handles only 64 bits.

The header does not have to be included when using an intrinsic function whose name starts with __.

 

 

 

unsigned long rolc(unsigned long data)

unsigned long __rolc(unsigned long data) [V2.05.00 or later]

[Description]

Rotates data including the C flag to left by one bit (this function is expanded into a ROLC instruction).

The bit pushed out of the operand is set to the C flag.

[Header]

<machine.h>

[Parameters]

data Data to be rotated to left

[Return value]

Result of 1-bit left rotation of data including the C flag

[Example]

#include <machine.h>
extern unsigned long ret, indata;
void main(void)
{
    ret = rolc(indata);// Rotates indata including the C flag 
        // to left by one bit and stores the result 
        // in ret.
}

[Remarks]

The header does not have to be included when using an intrinsic function whose name starts with __.

 

 

 

unsigned long rorc(unsigned long data)

unsigned long __rorc(unsigned long data) [V2.05.00 or later]

[Description]

Rotates data including the C flag to right by one bit (this function is expanded into a RORC instruction).

The bit pushed out of the operand is set to the C flag.

[Header]

<machine.h>

[Parameters]

data Data to be rotated to right

[Return value]

Result of 1-bit right rotation of data including the C flag

[Example]

#include <machine.h>
extern unsigned long ret, indata;
void main(void)
{
    ret = rorc(indata);// Rotates indata including the C flag 
        // to right by one bit and stores the result 
        // in ret.
}

[Remarks]

The header does not have to be included when using an intrinsic function whose name starts with __.

 

 

 

unsigned long rotl(unsigned long data, unsigned long num)

unsigned long __rotl(unsigned long data, unsigned long num) [V2.05.00 or later]

[Description]

Rotates data to left by the specified number of bits (this function is expanded into a ROTL instruction).

The bit pushed out of the operand is set to the C flag.

[Header]

<machine.h>

[Parameters]

data Data to be rotated to left

num Number of bits to be rotated

[Return value]

Result of num-bit left rotation of data

[Example]

#include <machine.h>
extern unsigned long ret, indata;
void main(void)
{
    ret = rotl(indata, 31); // Rotates indata to left by 31 bits 
    // and stores the result in ret.
}

[Remarks]

The header does not have to be included when using an intrinsic function whose name starts with __.

 

 

 

unsigned long rotr(unsigned long data, unsigned long num)

unsigned long __rotr(unsigned long data, unsigned long num) [V2.05.00 or later]

[Description]

Rotates data to right by the specified number of bits (this function is expanded into a ROTR instruction).

The bit pushed out of the operand is set to the C flag.

[Header]

<machine.h>

[Parameters]

data Data to be rotated to right

num Number of bits to be rotated

[Return value]

Result of num-bit right rotation of data

[Example]

#include <machine.h>
extern unsigned long ret, indata;
void main(void)
{
    ret = rotr(indata, 31); // Rotates indata to right by 31 bits 
        // and stores the result in ret.
}

[Remarks]

The header does not have to be included when using an intrinsic function whose name starts with __.

 

 

 

void brk(void)

void __brk(void) [V2.05.00 or later]

[Description]

This function is expanded into a BRK instruction.

[Header]

<machine.h>

[Parameters]

-

[Return value]

-

[Example]

#include <machine.h>
void main(void)
{
    brk();// BRK instruction
}

[Remarks]

The header does not have to be included when using an intrinsic function whose name starts with __.

 

 

 

void int_exception(signed long num)

void __int_exception(signed long num) [V2.05.00 or later]

[Description]

This function is expanded into an INT num instruction.

[Header]

<machine.h>

[Parameters]

num INT instruction number

[Return value]

-

[Example]

#include <machine.h>
void main(void)
{
    int_exception(10);// INT #10 instruction
}

[Remarks]

Only an integer from 0 to 255 can be specified as num.

The header does not have to be included when using an intrinsic function whose name starts with __.

 

 

 

void wait(void)

void __wait(void) [V2.05.00 or later]

[Description]

This function is expanded into a WAIT instruction.

[Header]

<machine.h>

[Parameters]

-

[Return value]

-

[Example]

#include <machine.h>
void main(void)
{
    wait();// WAIT instruction
}

[Remarks]

This function must not be executed when the RX processor mode is user mode. If executed, a privileged instruction exception of the RX occurs due to the specifications of the WAIT instruction.

The header does not have to be included when using an intrinsic function whose name starts with __.

 

 

 

void nop(void)

void __nop(void) [V2.05.00 or later]

[Description]

This function is expanded into a NOP instruction.

[Header]

<machine.h>

[Parameters]

-

[Return value]

-

[Example]

#include <machine.h>
void main(void)
{
    nop();// NOP instruction
}

[Remarks]

The header does not have to be included when using an intrinsic function whose name starts with __.

 

 

 

void set_ipl(signed long level)

void __set_ipl(signed long level) [V2.05.00 or later]

[Description]

Changes the interrupt mask level.

[Header]

<machine.h>

[Parameters]

-

[Return value]

level Interrupt mask level to be set

[Example]

#include <machine.h>
void main(void)
{
    set_ipl(7);// Sets PSW.IPL to 7.
}

[Remarks]

A value from 0 to 15 can be specified for level by default, and a value from 0 to 7 can be specified when -patch=rx610 is specified.

If a value outside the above range is specified when level is a constant, an error will be output.

This function must not be executed when the RX processor mode is user mode. If executed, a privileged instruction exception of the RX occurs due to the specifications of the MVTIPL instruction.

The header does not have to be included when using an intrinsic function whose name starts with __.

 

 

 

unsigned char get_ipl(void)

unsigned char __get_ipl(void) [V2.05.00 or later]

[Description]

Refers to the interrupt mask level.

[Header]

<machine.h>

[Parameters]

-

[Return value]

Interrupt mask level

[Example]

#include <machine.h>
extern unsigned char level;
void main(void)
{
    level=get_ipl();// Obtains the PSW.IPL value and 
        // stores it in level.
}

[Remarks]

If a value smaller than 0 or greater than 7 is specified as level, an error will be output.

The header does not have to be included when using an intrinsic function whose name starts with __.

 

 

 

void set_psw(unsigned long data)

void __set_psw(unsigned long data) [V2.05.00 or later]

[Description]

Sets a value to PSW.

[Header]

<machine.h>

[Parameters]

data Value to be set

[Return value]

-

[Example]

#include <machine.h>
extern unsigned long data;
void main(void)
{
    set_psw(data);// Sets PSW to the value specified by data.
}

[Remarks]

Due to the specifications of the RX instruction set, a write to the PM bit of PSW is ignored. In addition, a write to PSW is ignored when the RX processor mode is user mode.

The header does not have to be included when using an intrinsic function whose name starts with __.

 

 

 

unsigned long get_psw(void)

unsigned long __get_psw(void) [V2.05.00 or later]

[Description]

Refers to the PSW value.

[Header]

<machine.h>

[Parameters]

-

[Return value]

PSW value

[Example]

#include <machine.h>
extern unsigned long ret;
void main(void)
{
    ret=get_psw();// Obtains the PSW value and stores it in ret.
}

[Remarks]

In some cases, the timing at which the PSW value is obtained differs from the timing at which get_psw was called, due to the effect of optimization. Therefore when a code using the C, Z, S, or O flag included in the return value of this function is written after some sort of operation, correct operation will not be guaranteed.

The header does not have to be included when using an intrinsic function whose name starts with __.

 

 

 

void set_fpsw(unsigned long data)

void __set_fpsw(unsigned long data) [V2.05.00 or later]

[Description]

Sets a value to FPSW.

[Header]

<machine.h>

[Parameters]

data Value to be set

[Return value]

-

[Example]

#include <machine.h>
extern unsigned long data;
void main(void)
{
    set_fpsw(data);// Sets FPSW to the value specified by data.
}

[Remarks]

The header does not have to be included when using an intrinsic function whose name starts with __.

 

 

 

unsigned long get_fpsw(void)

unsigned long __get_fpsw(void) [V2.05.00 or later]

[Description]

Refers to the FPSW value.

[Header]

<machine.h>

[Parameters]

-

[Return value]

FPSW value

[Example]

#include <machine.h>
extern unsigned long ret;
void main(void)
{
    ret=get_fpsw();// Obtains the FPSW value and stores it 
        // in ret.
}

[Remarks]

In some cases, the timing at which the FPSW value is obtained differs from the timing at which get_fpsw was called, due to the effect of optimization. Therefore when a code using the CV, CO, CZ, CU, CX, CE, FV, FO, FZ, FU, FX, or FS flag included in the return value of this function is written after some sort of operation, correct operation will not be guaranteed.

The header does not have to be included when using an intrinsic function whose name starts with __.

 

 

 

void set_usp(void *data)

void __set_usp(void *data) [V2.05.00 or later]

[Description]

Sets a value to USP.

[Header]

<machine.h>

[Parameters]

data Value to be set

[Return value]

-

[Example]

#include <machine.h>
extern void * data;
void main(void)
{
    	set_usp(data);// Sets USP to the value specified by data.
}

[Remarks]

A 4-byte boundary address should be specified as data.

Program operation is not guaranteed when a 1-byte boundary address or 2-byte boundary address is specified.

The header does not have to be included when using an intrinsic function whose name starts with __.

 

 

 

void *get_usp(void)

void *__get_usp(void) [V2.05.00 or later]

[Description]

Refers to the USP value.

[Header]

<machine.h>

[Parameters]

-

[Return value]

USP value

[Example]

#include <machine.h>
extern void * ret;
void main(void)
{
    ret=get_usp();// Obtains the USP value and stores it in ret.
}

[Remarks]

The header does not have to be included when using an intrinsic function whose name starts with __.

 

 

 

void set_isp(void *data)

void __set_isp(void *data) [V2.05.00 or later]

[Description]

Sets a value to ISP.

[Header]

<machine.h>

[Parameters]

data Value to be set

[Return value]

-

[Example]

#include <machine.h>
extern void * data;
void main(void)
{
    set_isp(data);// Sets ISP to the value specified by data.
}

[Remarks]

Due to the specifications of the MVTC instruction used in this function, a write to ISP is ignored when the RX processor mode is user mode.

A 4-byte boundary address should be specified as data.

Program operation is not guaranteed when a 1-byte boundary address or 2-byte boundary address is specified.

The header does not have to be included when using an intrinsic function whose name starts with __.

 

 

 

void *get_isp(void)

void *__get_isp(void) [V2.05.00 or later]

[Description]

Refers to the ISP value.

[Header]

<machine.h>

[Parameters]

-

[Return value]

ISP value

[Example]

#include <machine.h>
extern void * ret;
void main(void)
{
    ret=get_isp();// Obtains the ISP value and stores it in ret.
}

[Remarks]

The header does not have to be included when using an intrinsic function whose name starts with __.

 

 

 

void set_intb (void *data)

void __set_intb(void *data) [V2.05.00 or later]

[Description]

Sets a value to INTB.

[Header]

<machine.h>

[Parameters]

data Value to be set

[Return value]

-

[Example]

#include <machine.h>
extern void * data;
void main(void)
{
    set_intb (data);// Sets INTB to the value specified by data.
}

[Remarks]

Due to the specifications of the MVTC instruction used in this function, a write to INTB is ignored when the RX processor mode is user mode.

The header does not have to be included when using an intrinsic function whose name starts with __.

 

 

 

void *get_intb(void)

void *__get_intb(void) [V2.05.00 or later]

[Description]

Refers to the INTB value.

[Header]

<machine.h>

[Parameters]

-

[Return value]

INTB value

[Example]

#include <machine.h>
extern void * ret;
void main(void)
{
    ret=get_intb();// Obtains the INTB value and stores it in ret.
}

[Remarks]

The header does not have to be included when using an intrinsic function whose name starts with __.

 

 

 

void set_bpsw(unsigned long data)

void __set_bpsw(unsigned long data) [V2.05.00 or later]

[Description]

Sets a value to BPSW.

[Header]

<machine.h>

[Parameters]

data Value to be set

[Return value]

-

[Example]

#include <machine.h>
extern unsigned long data;
void main(void)
{
    set_bpsw (data);// Sets BPSW to the value specified by data.
}

[Remarks]

Due to the specifications of the MVTC instruction used in this function, a write to BPSW is ignored when the RX processor mode is user mode.

The header does not have to be included when using an intrinsic function whose name starts with __.

 

 

 

unsigned long get_bpsw(void)

unsigned long __get_bpsw(void) [V2.05.00 or later]

[Description]

Refers to the BPSW value.

[Header]

<machine.h>

[Parameters]

-

[Return value]

BPSW value

[Example]

#include <machine.h>
extern unsigned long ret;
void main(void)
{
    ret=get_bpsw ();// Obtains the BPSW value and stores it 
        // in ret.
}

[Remarks]

The header does not have to be included when using an intrinsic function whose name starts with __.

 

 

 

void set_bpc(void *data)

void __set_bpc(void *data) [V2.05.00 or later]

[Description]

Sets a value to BPC.

[Header]

<machine.h>

[Parameters]

data Value to be set

[Return value]

-

[Example]

#include <machine.h>
extern void * data;
void main(void)
{
    set_bpc(data);// Sets BPC to the value specified by data.
}

[Remarks]

Due to the specifications of the MVTC instruction used in this function, a write to BPC is ignored when the RX processor mode is user mode.

The header does not have to be included when using an intrinsic function whose name starts with __.

 

 

 

void *get_bpc(void)

void *__get_bpc(void) [V2.05.00 or later]

[Description]

Refers to the BPC value.

[Header]

<machine.h>

[Parameters]

-

[Return value]

BPC value

[Example]

#include <machine.h>
extern void * ret;
void main(void)
{
    ret=get_bpc();// Obtains the BPC value and stores it in ret.
}

[Remarks]

The header does not have to be included when using an intrinsic function whose name starts with __.

 

 

 

void set_fintv(void *data)

void __set_fintv(void *data) [V2.05.00 or later]

[Description]

Sets a value to FINTV.

[Header]

<machine.h>

[Parameters]

data Value to be set

[Return value]

 

[Example]

#include <machine.h>
extern void * data;
void main(void)
{
    set_fintv(data);// Sets FINTV to the value specified by data.
}

[Remarks]

Due to the specifications of the MVTC instruction used in this function, a write to FINTV is ignored when the RX processor mode is user mode.

The header does not have to be included when using an intrinsic function whose name starts with __.

 

 

 

void *get_fintv(void)

void *__get_fintv(void) [V2.05.00 or later]

[Description]

Refers to the FINTV value.

[Header]

<machine.h>

[Parameters]

-

[Return value]

FINTV value

[Example]

#include <machine.h>
extern void * ret;
void main(void)
{
    ret=get_fintv();// Obtains the FINTV value and stores it 
        // in ret.
}

[Remarks]

The header does not have to be included when using an intrinsic function whose name starts with __.

 

 

 

signed long long emul(signed long data1, signed long data2)

signed long long __emul(signed long data1, signed long data2) [V2.05.00 or later]

[Description]

Performs signed multiplication of significant 64 bits.

[Header]

<machine.h>

[Parameters]

data 1 Input value 1

data 2 Input value 2

[Return value]

Result of signed multiplication (signed 64-bit value)

[Example]

#include <machine.h>
extern signed long long ret;
extern signed long data1, data2;
void main(void)
{
    ret=emul(data1, data2);// Calculates the value of 
        // "data1 * data2" and stores it in ret.
}

[Remarks]

The header does not have to be included when using an intrinsic function whose name starts with __.

 

 

 

unsigned long long emulu(unsigned long data1, unsigned long data2)

unsigned long long __emulu(unsigned long data1, unsigned long data2) [V2.05.00 or later]

[Description]

Performs unsigned multiplication of significant 64 bits.

[Header]

<machine.h>

[Parameters]

data 1 Input value 1

data 2 Input value 2

[Return value]

Result of unsigned multiplication (unsigned 64-bit value)

[Example]

#include <machine.h>
extern unsigned long long ret;
extern unsigned long data1, data2;
void main(void)
{
    ret=emulu(data1, data2);// Calculates the value of 
        // "data1 * data2" and stores it in ret.
}

[Remarks]

The header does not have to be included when using an intrinsic function whose name starts with __.

 

 

 

void chg_pmusr(void)

void __chg_pmusr(void) [V2.05.00 or later]

[Description]

Switches the RX processor mode to user mode.

[Header]

<machine.h>

[Parameters]

-

[Return value]

-

[Example]

#include <machine.h>
void main(void);
void Do_Main_on_UserMode(void)
{
    chg_pmusr();// Switches the RX processor mode to user mode.
    main();// Executes the main function.
}

[Remarks]

This function is provided for a reset processing function or interrupt function. Usage in any other function is not recommended.

The processor mode is not switched when the RX processor mode is user mode.

Since the stack is switched from the interrupt stack to the user stack when this function is executed, the following conditions must be met in a function that is calling this function. If the conditions are not met, code does not operate correctly because the stack is not the same before and after this function has been executed.

-

Execution cannot be returned to the calling function.

-

The auto variable cannot be declared.

-

Parameters cannot be declared.

The header does not have to be included when using an intrinsic function whose name starts with __.

 

 

 

void set_acc(signed long long data)

void __set_acc(signed long long data) [V2.05.00 or later]

[Description]

Sets a value to ACC.

[Header]

<machine.h>

[Parameters]

data Value to be set to ACC

[Return value]

-

[Example]

#include <machine.h>
void main(void)
{
    signed long long data = 0x123456789ab0000LL;
    set_acc(data);// Sets ACC to the value specified by data.
}

[Remarks]

The header does not have to be included when using an intrinsic function whose name starts with __.

 

 

 

signed long long get_acc(void)

signed long long __get_acc(void) [V2.05.00 or later]

[Description]

Refers to the ACC value.

[Header]

<machine.h>

[Parameters]

-

[Return value]

ACC value

[Example]

/* Example of program using the function to save and restore ACC by	*/
/* get_acc and set_acc	*/
#include <machine.h>
signed long a, b, c;
void func(void)
{
    signed long long bak_acc = get_acc();
        // Obtains the ACC value and saves it 
        // in bak_acc.
    c = a * b;// Multiplication (ACC is damaged).
    set_acc(bak_acc);// Restores ACC with a value saved by 
        // bak_acc.
}

[Remarks]

Due to the specifications of the RX instruction set, contents in the lower 16 bits of ACC cannot be obtained. This function returns the value of 0 for these bits.

The header does not have to be included when using an intrinsic function whose name starts with __.

 

 

 

void setpsw_i(void)

void __setpsw_i(void) [V2.05.00 or later]

[Description]

Sets the interrupt enable bit (I bit) in PSW to 1.

[Header]

<machine.h>

[Parameters]

-

[Return value]

-

[Example]

#include <machine.h>
void main(void)
{
    setpsw_i();// Sets the interrupt enable bit to 1.
}

[Remarks]

Due to the specifications of the SETPSW instruction used by this function, writing to the interrupt enable bit is ignored when the RX processor mode is set to user mode.

The header does not have to be included when using an intrinsic function whose name starts with __.

 

 

 

void clrpsw_i(void)

void __clrpsw_i(void) [V2.05.00 or later]

[Description]

Clears the interrupt enable bit (I bit) in PSW to 0.

[Header]

<machine.h>

[Parameters]

-

[Return value]

-

[Example]

#include <machine.h>
void main(void)
{
    clrpsw_i();// Clears the interrupt enable bit to 0.
}

[Remarks]

Due to the specifications of the CLRPSW instruction used by this function, writing to the interrupt enable bit is ignored when the RX processor mode is set to user mode.

The header does not have to be included when using an intrinsic function whose name starts with __.

 

 

 

long macl(short *data1, short *data2, unsigned long count)

long __macl(short *data1, short *data2, unsigned long count) [V2.05.00 or later]

[Description]

Performs a multiply-and-accumulate operation between data of two bytes each and returns the result as four bytes.

The multiply-and-accumulate operation is executed with DSP functional instructions (MULLO, MACLO, and MACHI).

Data in the middle of the multiply-and-accumulate operation is retained in ACC as 48-bit data.

After all multiply-and-accumulate operations have finished, the contents of ACC are fetched by the MVFACMI instruction and used as the return value of the intrinsic function.

Usage of this intrinsic function enables fast multiply-and-accumulate operations to be expected compared to as when writing multiply-and-accumulate operations without using this intrinsic function.

This intrinsic function can be used for multiply-and-accumulate operations of 2-byte integer data. Saturation and rounding are not performed to the results of multiply-and-accumulate operations.

[Header]

<machine.h>

[Parameters]

data1 Start address of values 1 to be multiplied

data2 Start address of values 2 to be multiplied

count Count of multiply-and-accumulate operations

[Return value]

Σ(data1[n] * data2[n]) result

[Example]

#include <machine.h>
short data1[3] = {a1, b1, c1};
short data2[3] = {a2, b2, c2};
void mac_calc()
{
    result = macl(data1, data2, 3);
        /* Obtains the result of "a1*a2+b1*b2+c1*c2". */
}

[Remarks]

Refer to the programming manual to confirm the detailed contents of the various DSP functional instructions used in multiply-and-accumulate operations.

When the multiplication count is 0, the return value of the intrinsic function is 0.

When using this intrinsic function, save and restore ACC in an interrupt processing in which the ACC value is rewritten.

For the function to save and restore ACC, refer to the compiler option save_acc or the extended language specifications #pragma interrupt.

The header does not have to be included when using an intrinsic function whose name starts with __.

 

 

 

short macw1(short *data1, short *data2, unsigned long count)

short macw2(short *data1, short *data2, unsigned long count)

short __macw1(short *data1, short *data2, unsigned long count) [V2.05.00 or later]

short __macw2(short *data1, short *data2, unsigned long count) [V2.05.00 or later]

[Description]

Performs a multiply-and-accumulate operation between data of two bytes each and returns the result as two bytes.

The multiply-and-accumulate operation is executed with DSP functional instructions (MULLO, MACLO, and MACHI).

Data in the middle of the multiply-and-accumulate operation is retained in ACC as 48-bit data.

After all multiply-and-accumulate operations have finished, rounding is applied to the multiply-and-accumulate operation result of ACC.

The macw1 function performs rounding with the "RACW #1" instruction while the macw2 function performs rounding with the "RACW #2" instruction.

Rounding is performed with the following procedure.

-

The contents of ACC are left-shifted by one bit with the macw1 function and by two bits with the macw2 function.

-

The MSB of the lower 32 bits of ACC is rounded off (binary).

-

The upper 32 bits of ACC are saturated with the upper limit as 0x00007FFF and the lower limit as 0xFFFF8000.

 

Finally, the contents of ACC are fetched by the MVFACHI instruction and used as the return value of these intrinsic functions.

Normally, the decimal point position of the multiplication result needs to be adjusted when fixed-point data is multiplied with each other. For example, in a case of multiplication of two Q15-format fixed-point data items, the multiplication result has to be left-shifted by one bit to make the multiplication result have the Q15 format. This left-shifting to adjust the decimal point position is achieved by the left-shift operation of the RACW instruction. Accordingly, in a case of multiply-and-accumulate operation of 2-byte fixed-point data, using these intrinsic functions facilitate multiply-and-accumulate processing. Note however that since the rounding mode of the operation result differs in macw1 and macw2, the intrinsic function to be used should be selected according to the desired accuracy for the operation result.

[Header]

<machine.h>

[Parameters]

data1 Start address of values 1 to be multiplied

data2 Start address of values 2 to be multiplied

count Count of multiply-and-accumulate operations

[Return value]

Value obtained by rounding the multiply-and-accumulate operation result with the RACW instruction

[Example]

#include <machine.h>
short data1[3] = {a1, b1, c1};
short data2[3] = {a2, b2, c2};
void mac_calc()
{
    result = macw1(data1, data2, 3);
        /* Obtains the value of rounding the result of "a1*a2+b1*b2+c1*c2"*/
        /* with the "RACW #1" instruction. */
}

[Remarks]

Refer to the programming manual to confirm the detailed contents of the various DSP functional instructions used in multiply-and-accumulate operations.

When the multiplication count is 0, the return value of the intrinsic function is 0.

When using this intrinsic function, save and restore ACC in an interrupt processing in which the ACC value is rewritten.

For the function to save and restore ACC, refer to the compiler option save_acc or the extended language specifications #pragma interrupt.

The header does not have to be included when using an intrinsic function whose name starts with __.

 

 

 

void set_extb(void *data)

void __set_extb(void *data) [V2.05.00 or later]

[Description]

Sets a value for EXTB.

[Header]

<machine.h>

[Parameters]

data Value to be set

[Return value]

-

[Example]

#include <machine.h>
extern void * data;
void main(void)
{
    set_extb (data);// Sets EXTB to the value specified by data.
}

[Remarks]

This function is only usable when a value other than RXv1 is specified for the isa option or the environment variable ISA_RX. In other cases, this option will lead to an error at compilation.

Due to the specifications of the MVTC instruction used in this function, a write to EXTB is ignored when the RX processor mode is user mode.

The header does not have to be included when using an intrinsic function whose name starts with __.

 

 

 

void *get_extb(void)

void *__get_extb(void) [V2.05.00 or later]

[Description]

Refers to the EXTB value.

[Header]

<machine.h>

[Parameters]

-

[Return value]

EXTB value

[Example]

#include <machine.h>
extern void * ret;
void main(void)
{
    ret=get_extb();// Obtains the EXTB value and stores it in ret.
}

[Remarks]

This function is only usable when a value other than RXv1 is specified for the isa option or the environment variable ISA_RX. In other cases, this option will lead to an error at compilation.

The header does not have to be included when using an intrinsic function whose name starts with __.

 

 

 

void __bclr(unsigned char *data, unsigned long bit) [V2.05.00 or later]

[Description]

Sets the specified one bit in the specified 1-byte area to 0 (this function is expanded into a BCLR instruction).

[Header]

-

[Parameters]

data Address of the target 1-byte area

bit Position of the bit to be manipulated

[Return value]

-

[Example]

unsigned char *data;
void main(void)
{
    __bclr(data, 0);  // Sets the least significant bit in the 1-byte area indicated
                      // by address data to 0.
}

[Remarks]

Only an integer constant from 0 to 7 can be specified as parameter bit.

This function is expanded into a BCLR instruction which directly modifies the bit specified by the parameter to 0 in memory.

 

 

 

void __bset(unsigned char *data, unsigned long bit) [V2.05.00 or later]

[Description]

Sets the specified one bit in the specified 1-byte area to 1 (this function is expanded into a BSET instruction).

[Header]

-

[Parameters]

data Address of the target 1-byte area

bit Position of the bit to be manipulated

[Return value]

-

[Example]

unsigned char *data;
void main(void)
{
    __bset(data, 0);  // Sets the least significant bit in the 1-byte area indicated
                      // by address data to 1.
}

[Remarks]

Only an integer constant from 0 to 7 can be specified as parameter bit.

This function is expanded into a BSET instruction which directly modifies the bit specified by the parameter to 1 in memory.

 

 

 

void __bnot(unsigned char *data, unsigned long bit) [V2.05.00 or later]

[Description]

Reverses the value of the specified one bit in the specified 1-byte area (this function is expanded into a BNOT instruction).

[Header]

-

[Parameters]

data Address of the target 1-byte area

bit Position of the bit to be manipulated

[Return value]

-

[Example]

unsigned char *data;
void main(void)
{
    __bnot(data, 0);  // Sets the least significant bit in the 1-byte area indicated
                      // by address data to 0 if the value is 1 or to 1 if the value
                      // is 0.
}

[Remarks]

Only an integer constant from 0 to 7 can be specified as parameter bit.

This function is expanded into a BNOT instruction which directly reverses the bit specified by the parameter in memory.

 

 

 

void __set_dpsw(unsigned long data) [V3.01.00 or later]

[Description]

Sets a value in DPSW.

[Header]

-

[Parameters]

data Value to be set

[Return value]

-

[Example]

unsigned long data;
void main(void)
{
    __set_dpsw(data);// Sets DPSW to the value specified by data.
}

[Remarks]

This function is only usable when the dpfpu option is specified. If this call is attempted with the option not specified, an error will occur at the time of compilation.

 

 

 

unsigned long __get_dpsw(void) [V3.01.00 or later]

[Description]

Refers to the DPSW value.

[Header]

-

[Parameters]

-

[Return value]

DPSW value

[Example]

unsigned long ret;
void main(void)
{
    ret=__get_dpsw();// Obtains the DPSW value and stores it in ret.
}

[Remarks]

This function is only usable when the dpfpu option is specified. If this call is attempted with the option not specified, an error will occur at the time of compilation.

 

 

 

void __set_decnt(unsigned long data) [V3.01.00 or later]

[Description]

Sets a value in DECNT.

[Header]

-

[Parameters]

data Value to be set

[Return value]

-

[Example]

unsigned long data;
void main(void)
{
    __set_decnt(data);// Sets DECNT to the value specified by data.
}

[Remarks]

This function is only usable when the dpfpu option is specified. If this call is attempted with the option not specified, an error will occur at the time of compilation.

 

 

 

unsigned long __get_decnt(void) [V3.01.00 or later]

[Description]

Refers to the DECNT value.

[Header]

-

[Parameters]

-

[Return value]

DECNT value

[Example]

unsigned long ret;
void main(void)
{
    ret=__get_decnt();// Obtains the DECNT value and stores it in ret.
}

[Remarks]

This function is only usable when the dpfpu option is specified. If this call is attempted with the option not specified, an error will occur at the time of compilation.

 

 

 

void *__get_depc(void) [V3.01.00 or later]

[Description]

Refers to the DEPC value.

[Header]

-

[Parameters]

-

[Return value]

DEPC value

[Example]

void *ret;
void main(void)
{
    ret=__get_depc();// Obtains the DEPC value and stores it in ret.
}

[Remarks]

This function is only usable when the dpfpu option is specified. If this call is attempted with the option not specified, an error will occur at the time of compilation.

 

 

 

void __init_tfu(void) [V3.01.00 or later]

[Description]

Initializes the trigonometric function unit.

[Header]

-

[Parameters]

-

[Return value]

-

[Example]

void main(void)
{
    __init_tfu();
}

[Remarks]

Before using the trigonometric function unit, initialize the unit from the startup program by calling this function. If you do not do so, correct operation is not guaranteed.

This function is only available when the tfu option is specified. If this call is attempted with the option not specified, an error will occur at the time of compilation.

 

 

 

void __sincosf(float f, float *sin, float *cos) [V3.01.00 or later]

[Description]

Uses the trigonometric function unit to calculate the sine and cosine of an angle at the same time (single precision).

[Header]

-

[Parameters]

f Value in radians from which to calculate the sine and cosine

sin Address for storing the result of the sine operation

cos Address for storing the result of the cosine operation

[Return value]

-

[Example]

float f, *sin, *cos;
void main(void)
{
    __init_tfu();  // The trigonometric function unit must be initialized in advance.
 
    __sincosf(f, sin, cos);
}

[Remarks]

Before calling this function, be sure to initialize the trigonometric function unit by calling the __init_tfu() intrinsic function.

This function is not reentrant.

This function is only available when the tfu option is specified. If this call is attempted with the option not specified, an error will occur at the time of compilation.

 

 

 

void __atan2hypotf(float y, float x, float *atan2, float *hypot) [V3.01.00 or later]

[Description]

Uses the trigonometric function unit to calculate the arc tangent of x and y and the square root of the sum of squares

 

of these values ( ) at the same time (single precision).

[Header]

-

[Parameters]

y Coordinate y (the numerator of the tangent)

x Coordinate x (the denominator of the tangent)

atan2 Address for storing the result of the arc tangent operation for y/x

hypot Address for storing the result of the square root of the sum of squares of x and y ( )

[Return value]

-

[Example]

float y, x, *atan2, *hypot;
void main(void)
{
    __init_tfu();  // The trigonometric function unit must be initialized in advance.
 
    __atan2hypotf(y, x, atan2, hypot);
}

[Remarks]

Before calling this function, be sure to initialize the trigonometric function unit by calling the __init_tfu() intrinsic function.

This function is not reentrant.

The result of the arc tangent operation is returned as a value in radians in the range from (-π to π)

This function is only available when the tfu option is specified. If this call is attempted with the option not specified, an error will occur at the time of compilation.