English
Language : 

CC78K0S Datasheet, PDF (166/520 Pages) NEC – C Compiler Ver.1.30 or Later Language
CHAPTER 10 LIBRARY FUNCTIONS
(1) No -ZR option specified
The procedure of passing arguments and return values is shown below.
Called function "long func(int a, long b, char *c);"
<1> Placing arguments on the stack (by the caller)
The higher 16 bits of arguments “c” and “b” and lower 16 bits of argument “b” are placed on the stack in the
order named. a is passed by the AX register.
<2> Calling func by call instruction (by the caller)
The return address is placed on the stack next to the lower 16 bits of argument “b” and control is
transferred to the function func.
<3> Saving registers to be used within the function (by the callee)
If register HL is to be used, HL is placed on the stack.
<4> Placing the first argument passed by the register on the stack (by the callee)
<5> Processing func and storing the return value in registers (by the callee)
The lower 16 bits of the return value “long” are stored in BC and the higher 16 bits of the return value in
DE.
<6> Restoring the stored first argument (by the callee)
<7> Restoring the saved registers (by the callee)
<8> Returning control to the caller with ret instruction (by the callee)
<9> Removing arguments from the stack (by the caller)
The number of bytes (in units of 2 bytes) of the arguments is added to the stack pointer. In the example
shown in Figure 10-1, 6 is added.
166
User’s Manual U14872EJ1V0UM