beautypg.com

Figure 127. call frame layout – Zilog ZUSBOPTS User Manual

Page 201

background image

UM017105-0511

Calling Conventions

Zilog Developer Studio II – ZNEO™

User Manual

173

4. Restore any of the registers R8–R14 that were saved in step 2.

5. If the function returns a scalar value, place it in the r0 register. For functions returning

an aggregate, see the Special Cases section, which follows.

6. Deallocate the local frame (set the stack pointer to the current value of frame pointer)

and restore the frame pointer from stack.

7. Return.

Registers R8–R13 are considered as callee saves; that is, they are saved and restored (if
necessary) by the called function. If the called function does not set up a frame pointer, it
can also use R14 as a general-purpose register but must still save it on entry and restore it
on exit. The flag register is not saved and restored by the called function.

The function call mechanism described in this section is a dynamic call mechanism. In a
dynamic call mechanism, each function allocates memory on stack for its locals and tem-
poraries during the run time of the program. When the function has returned, the memory
that it was using is freed from the stack. Figure 127 shows a diagram of the ZNEO C-
Compiler dynamic call frame layout.

Figure 127. Call Frame Layout

Temporaries

Locals

Callers Frame Pointer 31:0

Return Address 31:0

Parameter 0

Parameter 1

Parameter N

FP

SP

Run Time Stack

High Address

Low Address

This manual is related to the following products: