IPR-NIOS Altera, IPR-NIOS Datasheet - Page 171

no-image

IPR-NIOS

Manufacturer Part Number
IPR-NIOS
Description
IP NIOS II MEGACORE RENEW
Manufacturer
Altera
Type
MegaCorer
Datasheet

Specifications of IPR-NIOS

License
Renewal License
Lead Free Status / RoHS Status
Not applicable / Not applicable
Chapter 7: Application Binary Interface
Arguments and Return Values
Arguments and Return Values
December 2010 Altera Corporation
1
An even better way to find out what the prologue has done is to use information
stored in the DWARF-2 debugging fields of the executable and linkable format (.elf)
file.
The instructions found in a Nios II function prologue perform the following tasks:
Example 7–1
Example 7–1. A function prologue
/* Adjust the stack pointer */
addi
/* Store registers to the frame */
stw
stw
stw
stw
/* Set the new frame pointer */
addi
Prologue Variations
The following variations can occur in a prologue:
This section discusses the details of passing arguments to functions and returning
values from functions.
Adjust the stack pointer (to allocate the frame)
Store registers to the frame
Set the frame pointer to the location of the saved frame pointer
If the function’s frame size is greater than 32,767 bytes, extra temporary registers
are used in the calculation of the new stack pointer as well as for the offsets of
where to store callee-saved registers. The extra registers are needed because of the
maximum size of immediate values allowed by the Nios II processor.
If the frame pointer is not in use, the final instruction, recalculating the frame
pointer, is not generated.
If variable arguments are used, extra instructions store the argument registers on
the stack.
If the compiler designates the function as a leaf function, the return address is not
saved.
If optimizations are on, especially instruction scheduling, the order of the
instructions might change and become interlaced with instructions located after
the prologue.
sp, sp, -16
ra, 12(sp)
fp, 8(sp)
r16, 4(sp)
r17, 0(sp)
fp, sp, 8
shows a function prologue.
/* make a 16-byte frame */
/* store the return address */
/* store the frame pointer*/
/* store callee-saved register */
/* store callee-saved register */
Nios II Processor Reference Handbook
7–7

Related parts for IPR-NIOS