


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!



EECS 373 F99 Notes
4-
1998, 1999 Steven K. Reinhardt
Procedures (functions) are very important for writing modular,reusable, maintainable code, in assembly language just like inhigh-level languages.PowerPC features for procedure/function calls: •^
link register (LR)
-^
bl: branch and link
-^
blr: branch to link register
To implement a procedure call, the calling procedure (the caller
) and the called procedure (the
callee
) must agree on:
how to pass in parameters
-^
how to return the return value (if any)
-^
where the call stack is (for local variables etc.)
-^
etc.
-^
The PowerPC
architecture
defines none of this
Instead, these are defined by convention
-^
An
application binary interface
(ABI) defines everything
needed for a binary object file to run on a system (CPU plusoperating system), so that it can:•^
call system library routines
-^
call (and be called by) code generated by other people &other compilers
-^
The ABI includes:•^
file format
-^
rules for linker operation
-^
procedure calling conventions
-^
register usage conventions
-^
PowerPC has different (but very similar) ABIs for MacOS,AIX. embedded systems (EABI), SVR4 Unix, Windows NT
EECS 373 F99 Notes
4-
Arguments are passed in GPRs r3 to r10•^
first argument in r3, second in r4, etc.
-^
more than eight arguments: use stack (in memory)
-^
Return value is passed back in r Example: int
func(int a, int b) {
return (a+b);
} func(3,4);
int func2(int a,
int
b)
return func(a, b);
} func2(3,4);
EECS 373 F99 Notes
4-
int
func3(int a, int b, int c) {
int temp;temp = func2(b, c);return func2(temp, a);
} •^
Where can we keep
a
Need some rules about who gets to use which registers•^
Callee-save
-^
Caller-save
-^
Reserved
-^
PowerPC ABI conventions:•^
Caller-save: r0, r3-r12, LR, CTR, CR0, CR1, CR5-
-^
Callee-save: r14-r31, CR2-CR
-^
Reserved: r1, r2, r