English
Language : 

CC78K4 Datasheet, PDF (161/523 Pages) NEC – CC78K4 Ver.2.30 or Later, C Compiler Language
CHAPTER 10 LIBRARY FUNCTIONS
<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 via 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 RP3 is to be used, RP3 is placed on the stack.
<4> Placing the first argument passed via 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, are
stored are stored in RP2.
<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.
Figure 10-1. Stack Area When Function Is Called (No –ZR Specified)
Stack pointer after <4>
Stack pointer after <3>
Stack pointer after <2>
Stack pointer after <1>
Stack pointer before
stacking arguments
High address
a
RP3
Return address
Lower 16 bits of b
Higher 16 bits of b
c
Return value in <5> is stored
Lower 16 bits
Higher 16 bits
BC
RP2
Stack pointer after <6>
Stack pointer after <7>
Stack pointer after <8>
Stack pointer after <9>
User’s Manual U15556EJ1V0UM
161