Zilog EZ80F916 User Manual
Page 170

UM014423-0607
Using the ANSI C-Compiler
ZiLOG Developer Studio II
eZ80Acclaim!
®
User Manual
150
LD BC,123456h ; BC is used across function call
PUSH BC; Must be pushed before arguments are pushed
PUSH HL; Push argument
CALL _foo; Might modify BC
POP BC; Remove argument
POP BC; Must be popped after arguments are deallocated
ADD HL,BC; Wrong value of BC could be used if BC not
; saved by caller
In the eZ80
®
, a multiple of 3 bytes is always used when pushing arguments on the stack.
The following table shows how arguments of different types are passed.
The called function performs the following tasks:
1. Push the frame pointer (that is, the IX register) onto the stack and allocate the local
frame:
–
Set the frame pointer to the current value of the stack pointer.
–
Decrement the stack pointer by the size of locals and temporaries, if required.
2. Execute the code for the function.
3. If the function returns a scalar value, place it in the appropriate register as defined in
the following table. For functions returning an aggregate, see “Special Cases” on
page 151.
4. Deallocate the local frame (set the stack pointer to the current value of frame pointer)
and restore the frame pointer register (IX) from stack.
5. Return.
The following table specifies how scalar values (those other than structs or unions) are
returned.
Table 1. Passing Arguments
Type
Size
Memory (Low to High)
char
3 bytes
xx ?? ??
short
3 bytes
xx xx ??
int
3 bytes
xx xx xx
long
6 bytes
xx xx xx xx ?? ??
float
6 bytes
xx xx xx xx ?? ??
double
6 bytes
xx xx xx xx ?? ??
pointer
3 bytes
xx xx xx