4 Commits
Author SHA1 Message Date
ShatteredMINT 9816111f38 clarify stack arguments 2026-09-01 14:08:20 +02:00
ShatteredMINT f2e5c830b3 explain inline comment 2026-09-01 13:48:12 +02:00
ShatteredMINT 60e7b6209f basic contribution guidelines 2026-09-01 13:21:17 +02:00
ShatteredMINT 33b7886e70 add arrays to readme 2026-09-01 13:07:13 +02:00
2 changed files with 39 additions and 5 deletions
+25
View File
@@ -0,0 +1,25 @@
# Contributing
## Code of Conduct
Be nice, we are all just doing this to have fun
## General rules
- All text (names, comments, etc.) has to be in English
- You are responsible for ensuring that you have the rights for us to use the code you contribute to the project
- follow the guidelines, for code, documentation, etc.
- all code has to work with the standard symphony ISA
## Documenting Functions
All functions in the standard library should follow the following outline:
```
; <description>
; Arguments: <which register contains what argument>
; Result: <what is the result, and where is it stored>
; Clobbers: <list of registers that are clobbered>
fn_label: <;SHOULD BE INLINED>
CODE
```
Functions should be in the appropriate asm file, if you are unsure where functionality fits make a seperate file and ask in the pull request
Functions that are provided for convenience/reference but should be inlined in production code should be marked with `;SHOULD BE INLINED` after their label
+14 -5
View File
@@ -20,19 +20,28 @@ If you are intersted in contributing have a look at [[CONTRIBUTING.md]]
| n.a. | zr |
| preserved | sp, r8 - r12 |
| scratch | flags, r1 - r7 |
| arguments | r1 - r5, r6 = stack args, r7 = stack res |
| result | r1 = low word, r2 = high word |
| arguments | r1 - r7 |
| result | r1-r7 |
| return address | r13 |
### Stack
grows downwards from top of memory
arguments are passed in reverse order with the stack so:
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.
Arguments are passed in reverse order with the stack so:
lowest address = 1st 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
#### String
Strings are stored in memory as null terminated sequences of bytes encoding ascii characters.
They should be passed by reference.
#### Array
Arrays are stored in memory with a reference to them being the tuple (pointer, length) stored in a register pair.
Array elements may only have a size of 8/16/32 bits