18 Commits
Author SHA1 Message Date
ShatteredMINT 37d0e556d2 Merge pull request 'clean up confusion about function template' (#14) from meta-documentation into main
Reviewed-on: TCShenanigans/symphony_stdlib#14
2026-09-02 20:49:38 +02:00
ShatteredMINT 26d3a4d4f4 clean up confusion about function template 2026-09-02 20:49:22 +02:00
ShatteredMINT 786adfdb1c Merge pull request 'Changed docs of math functions to conform to new guidelines' (#12) from Micha_i/symphony_stdlib:math-functions-docs into main
Reviewed-on: TCShenanigans/symphony_stdlib#12
2026-09-02 11:46:14 +02:00
Michał Isalski 84636799b6 Changed docs of math functions to conform to new guidelines 2026-09-02 11:44:30 +02:00
ShatteredMINT aa2cbe4ad8 Merge pull request 'Add basic meta documentation' (#11) from meta-documentation into main
Documentation efforts are ongoing but this should be good enough for now
2026-09-02 11:39:25 +02:00
ShatteredMINT 8301d5988a create teaching directory 2026-09-02 11:32:46 +02:00
ShatteredMINT dbd4865f14 change stack start 2026-09-02 11:31:52 +02:00
ShatteredMINT 8f1b970a2f remove mention of non existent file 2026-09-02 11:31:33 +02:00
ShatteredMINT ddca02d8a8 relax r7 requirement for result stack 2026-09-02 11:21:03 +02:00
ShatteredMINT a3d6cb64b5 remove duplicate documentation from stdlib.asm 2026-09-02 11:17:18 +02:00
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
ShatteredMINT daf4168129 format calling convention 2026-08-31 10:17:25 +02:00
ShatteredMINT 4bce47209a fix remaining links 2026-08-31 10:12:57 +02:00
ShatteredMINT af5a750031 link test 2026-08-31 10:10:10 +02:00
ShatteredMINT 8e0fdf0d28 start readme 2026-08-31 10:08:44 +02:00
5 changed files with 31 additions and 42 deletions
+2 -2
View File
@@ -16,8 +16,8 @@ All functions in the standard library should follow the following outline:
; Arguments: <which register contains what argument> ; Arguments: <which register contains what argument>
; Result: <what is the result, and where is it stored> ; Result: <what is the result, and where is it stored>
; Clobbers: <list of registers that are clobbered> ; Clobbers: <list of registers that are clobbered>
fn_label: <;SHOULD BE INLINED> <label>: <;SHOULD BE INLINED>
CODE <CODE>
``` ```
-21
View File
@@ -1,21 +0,0 @@
# 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.
-1
View File
@@ -4,7 +4,6 @@ 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. 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. 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 using it as a learning resource have a look at the [teaching folder](teaching).
-10
View File
@@ -1,10 +0,0 @@
jmp 0x100
@0x10
screen:
frambuffer_ptr: U32 0x0
size: U32 0x0
position_xy: U32 0x0
mode: U32 0x0
@0x100
+29 -8
View File
@@ -1,8 +1,15 @@
; Multiplies r1 and r2, returning the lower part of the result
; Arguments:
; r1 - The first value
; r2 - The second value
; Result:
; r1 - The lower 32 bits of the result
; Clobbers: r2, r3, r4, r5
pub mul_low: pub mul_low:
mov r3, 0 ; result mov r3, 0 ; result
mov r4, 31 ; loop counter mov r4, 31 ; loop counter
mull_loop: mul_low_loop:
asr r5, r2, 31 asr r5, r2, 31
and r5, r5, r1 and r5, r5, r1
lsl r5, r5, r4 lsl r5, r5, r4
@@ -10,14 +17,18 @@ pub mul_low:
lsl r2, r2, 1 lsl r2, r2, 1
sub r4, r4, 1 sub r4, r4, 1
cmp r4, 0 cmp r4, 0
jge mull_loop jge mul_low_loop
mov r1, r3 mov r1, r3
jmp r13 jmp r13
; Calculates the absolute value of the value provided in the r1 register ; Calculates the absolute value of the value provided in the r1 register
; Based on Stanford's BitHacks ; Arguments:
; Clobbers r2 ; r1 - The value for which we want the absolute value
; Result:
; r1 - The calculated absolute value
; Clobbers: r2
; Info: Based on Stanford's BitHacks
pub abs: ; SHOULD BE INLINED pub abs: ; SHOULD BE INLINED
; mask = v >> 31 ; mask = v >> 31
asr r2, r1, 31 asr r2, r1, 31
@@ -28,8 +39,13 @@ pub abs: ; SHOULD BE INLINED
jmp r13 jmp r13
; Calculates the minimum value of the two values provided in the r1 and r2 registers ; Calculates the minimum value of the two values provided in the r1 and r2 registers
; Based on Stanford's BitHacks ; Arguments:
; Clobbers flags ; r1 - The first value
; r2 - The second value
; Result:
; r1 - The smaller value
; Clobbers: Nothing
; Info: Based on Stanford's BitHacks
pub min: ; SHOULD BE INLINED pub min: ; SHOULD BE INLINED
; x < y ; x < y
cmp r1, r2 cmp r1, r2
@@ -45,8 +61,13 @@ pub min: ; SHOULD BE INLINED
jmp r13 jmp r13
; Calculates the maximum value of the two values provided in the r1 and r2 registers ; Calculates the maximum value of the two values provided in the r1 and r2 registers
; Based on Stanford's BitHacks ; Arguments:
; Clobbers r2 and flags ; r1 - The first value
; r2 - The second value
; Result:
; r1 - The smaller value
; Clobbers: r2
; Info: Based on Stanford's BitHacks
pub max: ; SHOULD BE INLINED pub max: ; SHOULD BE INLINED
; x < y ; x < y
cmp r1, r2 cmp r1, r2