Everything
A.3.2 Using CPU Instructions in C Language

The compiler provides the following intrinsic functions for cases of accessing control registers and special instructions that cannot be expressed in C language.

-

Maximum and minimum value selection

-

Byte switching in data

-

Data exchange

-

Multiply-and-accumulate operation

-

Rotation

-

Special instructions (BRK, WAIT, INT, and NOP)

-

Special instructions for the RX family (such as BRK and WAIT)

-

Control register setting and reference

The intrinsic functions are listed below.

Specifications

Function

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

Selects the maximum value.

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

Selects the minimum value.

unsigned long revl(unsigned long data)

Reverses the byte order in longword data.

unsigned long revw(unsigned long data)

Reverses the byte order in longword data in word units.

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

Exchanges data.

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

Multiply-and-accumulate operation (byte).

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

Multiply-and-accumulate operation (word).

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

Multiply-and-accumulate operation (longword).

unsigned long rolc(unsigned long data)

Rotates data including the carry to left by one bit.

unsigned long rorc(unsigned long data)

Rotates data including the carry to right by one bit.

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

Rotates data to left.

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

Rotates data to right.

void brk(void)

BRK instruction exception.

void int_exception(signed long num)

INT instruction exception.

void wait(void)

Stops program execution.

void nop(void)

Expanded to a NOP instruction.

void set_ipl(signed long level)

Sets the interrupt priority level.

unsigned char get_ipl(void)

Refers to the interrupt priority level.

void set_psw(unsigned long data)

Sets a value for PSW.

unsigned long get_psw(void)

Refers to the PSW value.

void set_fpsw(unsigned long data)

Sets a value for FPSW.

unsigned long get_fpsw(void)

Refers to the FPSW value.

void set_usp(void *data)

Sets a value for USP.

void *get_usp(void)

Refers to the USP value.

void set_isp(void *data)

Sets a value for ISP.

void *get_isp(void)

Refers to the ISP value.

void set_intb(void *data)

Sets a value for INTB.

void *get_intb(void)

Refers to the INTB value.

void set_bpsw(unsigned long data)

Sets a value for BPSW.

unsigned long get_bpsw(void)

Refers to the BPSW value.

void set_bpc(void *data)

Sets a value for BPC.

void *get_bpc(void)

Refers to the BPC value.

void set_fintv(void *data)

Sets a value for FINTV.

void *get_fintv(void)

Refers to the FINTV value.

signed long long emul(signed long, signed long)

Signed multiplication of valid 64 bits

unsigned long long emulu(unsigned long, unsigned long)

Unsigned multiplication of valid 64 bits