English
Language : 

CC78K0S Datasheet, PDF (164/520 Pages) NEC – C Compiler Ver.1.30 or Later Language
CHAPTER 10 LIBRARY FUNCTIONS
10.1 Interface Between Functions
To use a library function, the function must be called. Calling a library function is carried out by a call instruction.
The arguments and return value of a function are passed by a stack and a register, respectively. However, when the
old function interface supporting option (-ZO) is not specified in the normal model, the first argument is, if possible,
also passed by the register. In addition, all of the arguments are passed by the register in the static model.
For the -ZO option, refer to the CC78K0S C Compiler Operation User’s Manual (U14871E) CHAPTER 5
COMPILER OPTION.
10.1.1 Arguments
Placing or removing arguments on or from the stack is performed by the caller (calling side). The callee (called
side) only references the argument values. However, when the argument is passed by the register, the callee directly
refers to the register and copies the value of the argument to another register, if necessary. Also, when specifying
the function call interface automatic pascal function option -ZR, removal of arguments from the stack is performed by
the called side if the argument is passed on the stack.
Arguments are placed on the stack one by one in descending order from last to top if the argument is passed on
the stack.
The minimum unit of data that can be stacked is 16 bits. A data type larger than 16 bits is stacked in units of 16
bits one by one from its MSB. An 8-bit type data is extended to a 16-bit type data for stacking.
For the static model, all of arguments are passed by a register.
A maximum of 3 arguments and a total of 6 bytes can be passed. Passing float, double, and structure arguments
is not supported.
Lists of argument passing are shown below. The second argument and thereafter is passed via a stack in the
normal model.
The function interface (passing of argument and storing of return value) of the standard library is the same as that
of a normal function.
Table 10-1. List of Passing First Argument (Normal Model)
Type of First Argument
Passing Method
1-byte, 2-byte integers
AX
3-byte integer
AX, BC
4-byte integer
AX, BC
Floating-point number
(float type)
AX, BC
Floating-point number (double type)
AX, BC
Others
Passed via a stack
Remark Of the types shown above, 1- to 4-byte integers include structures and unions.
164
User’s Manual U14872EJ1V0UM