beautypg.com

Calling assembly functions from c, Function naming convention, Argument locations – Zilog Z8F0130 User Manual

Page 245: Function naming convention argument locations

background image

UM013037-1212

Calling Assembly Functions from C

Zilog Developer Studio II – Z8 Encore!

User Manual

221

and

The function does not return a structure.

and

The function is compiled without the debug option.

Calling Assembly Functions from C

The Z8 Encore! C-Compiler allows mixed C and assembly programming. A function writ-
ten in assembly can be called from C if the assembly function follows the C calling con-
ventions as described in the

Calling Conventions

section on page 215.

This section covers the following topics:

Function Naming Convention

– see page 221

Argument Locations

– see page 221

Return Values

– see page 222

Preserving Registers

– see page 222

Function Naming Convention

Assembly function names must be preceded with an _ (underscore). The compiler prefixes
the function names with an underscore in the generated assembly. For example, a call to

myfunc()

in C is translated to a call to

_myfunc

in generated assembly by the compiler.

Argument Locations

The assembly function must assign the location of the arguments following the C calling
conventions as described in the

Calling Conventions

section on page 215.

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

void myfunc(short arga, long argb, char argc, short * argd)

The location of the arguments must be as follows for a static frame function:

arga : _0_myfunc

argb: _1_myfunc

argc: _2_myfunc

argd: _3_myfunc

The location of the arguments must be as follows for a static frame function with register
parameter passing: