Function Call - Epson S5U1C17001C Manual

Cmos 16-bit single chip microcontroller (c compiler package for s1c17 family) (ver. 3.2)
Hide thumbs Also See for S5U1C17001C:
Table of Contents

Advertisement

• First argument: long; second argument: pointer; third argument: pointer
foo( long lData, int *ip_Pt, char *cp_Pt );
%r0 ← lData (lower-order 16 bits)
%r1 ← lData (high-order 16 bits)
%r2 ← ip_Pt (24 bits or 16 bits)
%r3 ← cp_Pt (24 bits or 16 bits)
64-bit (long long or double) arguments are stored in the stack before delivery.
If the return value is 64-bit (long long, double) data, a return value area is secured during invocation, and its leading
address is placed in %r0 before being passed on to the function.
 Registers for storing returned values (%r0, %r1)
These registers are used to store returned values. They are used as scratch registers before storing a returned value.
• When the returned value is an 8-bit/16-bit data or a pointer (24 bits)
%r0 ← Returned value
%r1
Unused
• When the returned value is a 32-bit data
%r0 ← Returned value (low-order 16 bits)
%r1 ← Returned value (high-order 16 bits)
 Registers for saving values when calling a function (%r4 to %r7)
These registers are used to store the calculation results of expressions and local variables. These register values after returning
from a function must be the same as those when the function was called. Therefore, the called function has to save and restore the
register values if it modifies the register contents.
4.4.4

Function Call

 The way arguments are passed
When calling a function, up to four arguments are stored in registers for passing argument (%r0 to %r3) while larger arguments
are stored in the stack frame of the calling function (explained in the next section) before they are passed.
 Handling of structure arguments
When an argument is a 64-bit or smaller structure, the values of the structure members are stored in the registers to pass through
the function if the registers can be used. If the registers for passing argument (%r0 to %r3) cannot be used, the values of the
structure members are passed through the stack.
When an argument is a structure larger than 64 bits, the values of the structure members are passed through the stack.
S5U1C17001C Manual
(Rev. 1.0)
Seiko Epson Corporation
4 C Compiler
4-11

Advertisement

Table of Contents
loading

Table of Contents