Argument locations, Return values, Argument locations return values – Zilog ZUSBOPTS User Manual

Page 203

Advertising
background image

UM017105-0511

Calling Assembly Functions from C

Zilog Developer Studio II – ZNEO™

User Manual

175

Argument Locations

The assembly function assigns the location of the arguments following the C calling con-
ventions as described in the

Calling Conventions

section on page 172. For example, if you

are using the following C prototype:

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

arge, int argf, char argg, long *argh, int argi)

then the location of the arguments are:

arga

: R1

argb

: R2

argc

: R3

argd

: R4

arge

: R5

argf

: R6

argg

: R7

The remaining arguments are on stack, and their offsets from Stack Pointer (SP, R15) at
the entry point of assembly function are:

argh

:

-

4(SP)

argi

:

-

8(SP)

The corresponding offsets from Frame Pointer (FP, R14) after a

Link #0

instruction are:

argh

:

-

8(FP)

argi

:

-

12(FP)

Return Values

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

Calling Conventions

on page 172.

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

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

then the assembly function returns the long value in register R0.

Advertising
This manual is related to the following products: