4.2.6 Embedded functions

CC-RL provides the following "embedded functions". The embedded functions can only be called from function definitions.

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

Table 4.15

Embedded Function

Embedded Function

Function

Format

__DI

Outputs a DI instruction.

void __DI(void);
__EI

Outputs a EI instruction.

void __EI(void);
__halt

Outputs a HALT instruction.

void __halt(void);
__stop

Outputs a STOP instruction.

void __stop(void);
__brk

Outputs a BRK instruction.

void __brk(void);
__nop

Outputs a NOP instruction.

void __nop(void);
__rolb

Rotates x to the left y times assuming that x has a size of eight bits.

Operation is undefined for the case where the rotation count is greater than the size of the value.

If the rotation count may be greater than the size, mask the count to not exceed the size.

unsigned char   x, y;
unsigned char   __rolb(x, y);
__rorb

Rotates x to the right y times assuming that x has a size of eight bits.

Operation is undefined for the case where the rotation count is greater than the size of the value.

If the rotation count may be greater than the size, mask the count to not exceed the size.

unsigned char   x, y;
unsigned char   __rorb(x, y);
__rolw

Rotates x to the left y times assuming that x has a size of 16 bits.

Operation is undefined for the case where the rotation count is greater than the size of the value.

If the rotation count may be greater than the size, mask the count to not exceed the size.

unsigned int    x;
unsigned char   y;
unsigned int    __rolw(x, y);
__rorw

Rotates x to the right y times assuming that x has a size of 16 bits.

Operation is undefined for the case where the rotation count is greater than the size of the value.

If the rotation count may be greater than the size, mask the count to not exceed the size.

unsigned int    x;
unsigned char   y;
unsigned int    __rorw(x, y);
__mulu

Executes 8-bit unsigned multiplication between x and y and returns a 16-bit result.

unsigned char   x, y;
unsigned int    __mulu(x, y);
__mului

Executes 16-bit unsigned multiplication between x and y and returns a 32-bit result.

unsigned int    x, y;
unsigned long   __mului(x, y);
__mulsi

Executes 16-bit signed multiplication between x and y and returns a 32-bit result.

signed int      x, y;
signed long     __mulsi(x, y);
__mulul

Executes 32-bit unsigned multiplication between x and y and returns a 64-bit result.

unsigned long   x, y;
unsigned long long  __mulul(x, y);
__mulsl

Executes 32-bit signed multiplication between x and y and returns a 64-bit result.

signed long     x, y;
signed long long    __mulsl(x, y);
__divui

Executes unsigned division between x and y and returns a 16-bit result.

When divisor y is 0, 0xFFFF is returned.

unsigned int    x;
unsigned char   y;
unsigned int    __divui(x, y);
__divul

Executes unsigned division between x and y and returns a 32-bit result.

When divisor y is 0, 0xFFFFFFFF is returned.

unsigned long   x;
unsigned int    y;
unsigned long   __divul(x, y);
__remui

Executes unsigned remainder operation between x and y and returns a 8-bit result.

When divisor y is 0, the lower-order 8 bits of dividend x are returned.

unsigned int    x;
unsigned char   y;
unsigned char   __remui(x, y);
__remul

Executes unsigned remainder operation between x and y and returns a 16-bit result.

When divisor y is 0, the lower-order 16 bits of dividend x are returned.

unsigned long   x;
unsigned int    y;
unsigned int    __remul(x, y);
__macui

Executes unsigned multiply-accumulate operation (unsigned long) x * (unsigned long) y + z, and returns a 32-bit result.

unsigned int    x, y;
unsigned long   z;
unsigned long   __macui(x, y, z);
__macsi

Executes unsigned multiply-accumulate operation (signed long) x * (signed long) y + z, and returns a 32-bit result.

signed int      x, y;
signed long     z;
signed long     __macsi(x, y, z);
__get_psw

Returns the contents of PSW.

unsigned char   __get_psw(void);
__set_psw

Sets x to PSW.

unsigned char   x;
void            __set_psw(x);
__set1

The set1 instruction is used to set bit y of the address indicated by x to 1.

Only a constant from 0 to 7 can be specified for bit y and a compile error will occur when any other value is specified.

unsigned char   __near *x;
unsigned char   y;
void            __set1(x, y);
__clr1

The clr1 instruction is used to clear bit y of the address indicated by x to 0.

Only a constant from 0 to 7 can be specified for bit y and a compile error will occur when any other value is specified.

unsigned char   __near *x;
unsigned char   y;
void            __clr1(x, y);
__not1

The not1 instruction (xor instruction for the saddr area) is used to invert bit y of the address indicated by x.

Only a constant from 0 to 7 can be specified for bit y and a compile error will occur when any other value is specified.

unsigned char   __near *x;
unsigned char   y;
void            __not1(x, y);