clarify stack arguments
This commit is contained in:
@@ -20,16 +20,22 @@ If you are intersted in contributing have a look at [[CONTRIBUTING.md]]
|
|||||||
| n.a. | zr |
|
| n.a. | zr |
|
||||||
| preserved | sp, r8 - r12 |
|
| preserved | sp, r8 - r12 |
|
||||||
| scratch | flags, r1 - r7 |
|
| scratch | flags, r1 - r7 |
|
||||||
| arguments | r1 - r5, r6 = stack args, r7 = stack res |
|
| arguments | r1 - r7 |
|
||||||
| result | r1 = low word, r2 = high word |
|
| result | r1-r7 |
|
||||||
| return address | r13 |
|
| return address | r13 |
|
||||||
|
|
||||||
### Stack
|
Arguments not fitting into the 7 registers should be passed on the top of the stack, meaning they should be the last values pushed before the function call.
|
||||||
grows downwards from top of memory
|
Arguments are passed in reverse order with the stack so:
|
||||||
arguments are passed in reverse order with the stack so:
|
|
||||||
lowest address = 1st stack arg
|
lowest address = 1st stack arg
|
||||||
highest address = last stack arg
|
highest address = last stack arg
|
||||||
|
|
||||||
|
Should a function return more values than fit into the 7 registers, the caller has to allocate space on the stack for them, and pass the pointer to that space in r7.
|
||||||
|
This reduces the amount of argument registers to 6 and all arguments above that shall go on the stack, the pointer to the result stack shall **always** be passed in r7.
|
||||||
|
r7 points at the highest available address for results, with the 8th result being stored there, the 9th below it and so on.
|
||||||
|
|
||||||
|
### Stack
|
||||||
|
Grows downwards from top of memory.
|
||||||
|
|
||||||
### Types
|
### Types
|
||||||
|
|
||||||
#### String
|
#### String
|
||||||
|
|||||||
Reference in New Issue
Block a user