beautypg.com

Return values, Preserving registers, Return values preserving registers – Zilog Z8F0130 User Manual

Page 246

background image

Using the ANSI C-Compiler

UM013037-1212

222

Zilog Developer Studio II – Z8 Encore!
User Manual

arga: R8, R9

argb: R10, R11, R12, R13

argc: _0_myfunc

argd: _1_myfunc

For a dynamic frame function, the arguments will be on stack. Their offsets from the stack
pointer at the entry point of the assembly function are as follows:

arga: -2

argb: -4

argc: -8

argd: -9

For a dynamic frame function with register parameter passing, some of the arguments will
be in registers and some on stack. Their registers/offsets from the stack pointer at the entry
point of the assembly function are as follows:

arga: R8, R9

argb: R10, R11, R12, R13

argc: -2

argd: -3

Return Values

The assembly function must return the value in the location specified by the C calling con-
vention as described in the

Calling Conventions

section on page 215.

For example, if you are using the following C prototype:

long myfunc(short arga, long argb, short *argc)

The assembly function must return the long value in registers R0, R1, R2, and R3.

Preserving Registers

The Z8 Encore! C-Compiler implements a caller save scheme. The caller function pre-
serves the registers, and the called assembly function is not expected to save and restore
any registers that it uses.