English
Language : 

CC78K0S Datasheet, PDF (479/520 Pages) NEC – C Compiler Ver.1.30 or Later Language
CHAPTER 12 REFERENCING THE ASSEMBLER
(1) Saving base pointer, work register
A label with ‘_’ prefixed to the function name described in the C source is described. Base pointers and
work registers are saved with the same name as function names described inside the C source.
After the label is described, the HL register (base pointer) is saved.
In the case of programs generated by the C compiler, other functions are called without saving the register
for register variables. Therefore, if changing the values of these registers for functions that are called, be
sure to save the values beforehand. However, if register variables are not used on the calling side, saving
the work register is not required.
(2) Copying to base pointer (HL) of stack pointer (SP)
The stack pointer (SP) changes due to ‘PUSH, POP’ inside functions. Therefore, the stack pointer is copied
to register ‘HL’ and used as the base pointer of arguments.
(3) Basic processing of FUNC function
After the processing in (1) and (2) is performed, the basic processing of called functions is performed.
(4) Setting the return value
If there is a return value, it is set in the ‘BC’ and ‘DE’ registers. If there is no return value, setting is
unnecessary.
BC register
Return value of 16 or fewer bits:
Word
Return value of 17 or more bits:
DE register
Higher word
BC register
Lower word
(5) Restoring the registers
Restore the saved base pointer and work register.
(6) Returning to the main function
Figure 12-2. Stack Area After Returning
low address
Return address to main
Stack pointer
l (lower word)
AX register
i
high address
l (higher word)
Stack area
Return value
BC register
Word
Or
DE register
Higher word
BC register
Lower word
User’s Manual U14872EJ1V0UM
479