forked from TCShenanigans/symphony_stdlib
Compare commits
17
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
26d3a4d4f4 | ||
|
|
786adfdb1c | ||
|
|
84636799b6 | ||
|
|
aa2cbe4ad8 | ||
|
|
8301d5988a | ||
|
|
dbd4865f14 | ||
|
|
8f1b970a2f | ||
|
|
ddca02d8a8 | ||
|
|
a3d6cb64b5 | ||
|
|
9816111f38 | ||
|
|
f2e5c830b3 | ||
|
|
60e7b6209f | ||
|
|
33b7886e70 | ||
|
|
daf4168129 | ||
|
|
4bce47209a | ||
|
|
af5a750031 | ||
|
|
8e0fdf0d28 |
+2
-2
@@ -16,8 +16,8 @@ All functions in the standard library should follow the following outline:
|
||||
; 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
|
||||
<label>: <;SHOULD BE INLINED>
|
||||
<CODE>
|
||||
|
||||
```
|
||||
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
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).
|
||||
|
||||
|
||||
-10
@@ -1,10 +0,0 @@
|
||||
jmp 0x100
|
||||
|
||||
@0x10
|
||||
screen:
|
||||
frambuffer_ptr: U32 0x0
|
||||
size: U32 0x0
|
||||
position_xy: U32 0x0
|
||||
mode: U32 0x0
|
||||
|
||||
@0x100
|
||||
@@ -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:
|
||||
mov r3, 0 ; result
|
||||
mov r4, 31 ; loop counter
|
||||
|
||||
mull_loop:
|
||||
mul_low_loop:
|
||||
asr r5, r2, 31
|
||||
and r5, r5, r1
|
||||
lsl r5, r5, r4
|
||||
@@ -10,14 +17,18 @@ pub mul_low:
|
||||
lsl r2, r2, 1
|
||||
sub r4, r4, 1
|
||||
cmp r4, 0
|
||||
jge mull_loop
|
||||
jge mul_low_loop
|
||||
mov r1, r3
|
||||
|
||||
jmp r13
|
||||
|
||||
; Calculates the absolute value of the value provided in the r1 register
|
||||
; Based on Stanford's BitHacks
|
||||
; Clobbers r2
|
||||
; Arguments:
|
||||
; 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
|
||||
; mask = v >> 31
|
||||
asr r2, r1, 31
|
||||
@@ -28,8 +39,13 @@ pub abs: ; SHOULD BE INLINED
|
||||
jmp r13
|
||||
|
||||
; Calculates the minimum value of the two values provided in the r1 and r2 registers
|
||||
; Based on Stanford's BitHacks
|
||||
; Clobbers flags
|
||||
; Arguments:
|
||||
; 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
|
||||
; x < y
|
||||
cmp r1, r2
|
||||
@@ -45,8 +61,13 @@ pub min: ; SHOULD BE INLINED
|
||||
jmp r13
|
||||
|
||||
; Calculates the maximum value of the two values provided in the r1 and r2 registers
|
||||
; Based on Stanford's BitHacks
|
||||
; Clobbers r2 and flags
|
||||
; Arguments:
|
||||
; 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
|
||||
; x < y
|
||||
cmp r1, r2
|
||||
|
||||
Reference in New Issue
Block a user