In order to qualify for the simplified ABI, your function must obey the following rules:
- It must not call any other function.
- It may only modify registers 3 through 12.
- It may only modify condition register fields
cr0
,cr1
,cr5
,cr6
, andcr7
. - It must not alter the link register, unless it restores it before calling
blr
to return.
So let's rewrite our maximum value program as a function, and call it from C.
The parameters we should pass are the pointer to the array as the first parameter (register 3), and the size of the array as the second parameter (register 4). Then, the maximum value will be placed into register 3 for the return value.
No comments:
Post a Comment