Implementation Details
5-54
find the correct size for bogus. Bogus can be made larger for extra safety as
long as enough memory is left over for the C–– variables and the stack. If
space allows, it is a good idea to add a few extra words to bogus in case
assembly variables are added to the project without modifying bogus.
It is also important not to alter the contents of registers R5 and R7. R7 is the
stack pointer and R5 is a frame pointer used in C to C function calls.
Parameters are passed on the stack and the return value is always int and
always located in a0. The stack usage for function calls is as follows.
C to C function call. The stack is shown after the operation on the bottom is
performed.
||||||
|–––––––––––––––| |–––––––––––––––| |–––––––––––––––|
||||||
|–––––––––––––––| |–––––––––––––––| |–––––––––––––––|
||||||
|–––––––––––––––| |–––––––––––––––| |–––––––––––––––|
||||||
|–––––––––––––––| |–––––––––––––––| |–––––––––––––––|
||||||
|–––––––––––––––| |–––––––––––––––| |–––––––––––––––|
||||||
|–––––––––––––––| |–––––––––––––––| |–––––––––––––––|
||||||
|–––––––––––––––| |–––––––––––––––| |–––––––––––––––|
| | | |R7|Param 2 |
|–––––––––––––––| |–––––––––––––––| |–––––––––––––––|
| | | | |Param 2 |
|–––––––––––––––| |–––––––––––––––| |–––––––––––––––|
| |R7|Param 1 | |Param 1 |
|–––––––––––––––| |–––––––––––––––| |–––––––––––––––|
| | |Param 1 | |Param 1 |
|–––––––––––––––| |–––––––––––––––| |–––––––––––––––|
R7,R5 |Stack data |R5|Stack data |R5|Stack data |
|–––––––––––––––| |–––––––––––––––| |–––––––––––––––|
Before call Parameter 1 Parameter 2