Special cases, Calling assembly functions from c, Function naming convention – Zilog ZUSBOPTS User Manual
Page 202

Calling Assembly Functions from C
UM017105-0511
174
Zilog Developer Studio II – ZNEO™
User Manual
Special Cases
Some function calls do not follow the mechanism described in the
section on page 172. Such cases are described in this section.
Returning Structure
If the function returns a structure, the caller allocates the space for the structure and then
passes the address of the return space to the called function as an additional and first argu-
ment. To return a structure, the called function then copies the structure to the memory
block pointed to by this argument.
Not Allocating a Local Frame
The compiler does not allocate a local stack frame for a function in the following case:
•
The function does not have any local stack variables, stack arguments, or compiler-
generated temporaries on the stack
and:
•
The function does not return a structure
and:
•
The function is compiled without the debug option.
Calling Assembly Functions from C
The ZNEO C-Compiler allows mixed C and assembly programming. A function written in
assembly can be called from C if the assembly function follows the C calling conventions
as described in the
This section covers the following topics:
•
•
•
•
Function Naming Convention
Assembly function names must be preceded by 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 assembly generated by the compiler.