Compare commits

...
18 Commits
6 changed files with 108 additions and 26 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
+21
View File
@@ -0,0 +1,21 @@
# Memory Map
To not have to allocate a ton of things at run time the Standard Library uses a static memory map for some purposes
## Overview
| Start | Use |
| ---- | ---- |
| `0x0` | Reset Vector |
| `0x16` | Zero Page |
| `0x100` | User Code |
| `?` | Library Code |
| `0x1_0000` | LUTs |
| `?` | heap |
| `0xXXF0_0000` | Stack |
| `0xXXFF_0000` | quick access |
## Zero Page
Some values are needed not often enough to get their own special register, but often enough that it makes sense to keep them at a quickly accessible location.
This is what the zero page is for. its position in memory allows us to load them into a register with a single instruction.
+46 -2
View File
@@ -1,3 +1,47 @@
# symphony_stdlib
# Symphony Stdlib
standard library for symphony
This is a standard library for symphony.
It is both intended as a practical toolkit to develop more complex software as well as a teaching resource.
If you just want to use the standard library [[stdlib.asm]] is your main header, include it after your code.
You also need to include [[globals.asm]] as the first line in your assembly file.
If you are using it as a learning resource have a look at the [teaching folder](teaching).
If you are intersted in contributing have a look at [[CONTRIBUTING.md]]
---
## ABI
### Calling Convention
| class | registers |
| ----- | --------- |
| n.a. | zr |
| preserved | sp, r8 - r12 |
| scratch | flags, r1 - r7 |
| arguments | r1 - r7 |
| result | r1-r7 |
| return address | r13 |
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 the next free argument register.
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 an argument register.
This register 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 0xXXFE_0000 (so top of memory -0x1_0000).
### 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
+10
View File
@@ -0,0 +1,10 @@
jmp 0x100
@0x10
screen:
frambuffer_ptr: U32 0x0
size: U32 0x0
position_xy: U32 0x0
mode: U32 0x0
@0x100
+1 -24
View File
@@ -1,25 +1,2 @@
; ===== INTRODUCTION =====
; This is supposed to provide some standard library functionality for stock symphony.
; In particular its supposed to work with an unmodified ISA, that means some choices are not
; optimal (RA being stored in flags for example)
; ===== ABI =====
; ----- CALLING CONVENTION -----
; n.a. zr
; preserved: sp, r8 - r12
; scratch: flags, r1 - r7
; arguments: r1 - r7 (r1 = 1st argument, r6 = 6th arg/stack args, r7 = 7th arg/stack res)
; result: r1, r2 (r1 = low word, r2 = high word)
; return address: r13
; ----- STACK -----
; grows downwards from top of memory
; arguments are passed in reverse order with the stack so:
; lowest address = 1st stack arg
; highest address = last stack arg
; ===== TYPES =====
pub include bit
pub include imath
pub include imath
+5
View File
@@ -0,0 +1,5 @@
# Teaching
This is a collection of teaching advice regarding the stdlib.
**WIP**