forked from TCShenanigans/symphony_stdlib
Add globals and error codes
Added support for global variables. This requires including `start.asm` as the first code. This includes a `jmp` to 0x100 for user code, and a magic number that modules can check to verify th the user has correctly reserved the space. The magic number is 0xb301534c: * This has the high bit set so is not a valid instruction * On builds that ignore the high bit this decodes to `nor zr, zr, 0x534c` a no-op. * The immediate is "SL" for standardl ibrary. Due to a bug start pads with U... 0, instead of @addr. `start.asm` also initialises `sp` so it start just below the 64KiB LUT memory alocation. Added some error codes for the upcoming graphics module.
This commit is contained in:
+12
-1
@@ -16,10 +16,21 @@ 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>
|
||||
; Globals: <list of globals are accessed. OPTIONAL>
|
||||
<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
|
||||
Functions that are provided for convenience/reference but should be inlined in production code should be marked with `;SHOULD BE INLINED` after their label.
|
||||
|
||||
If the function returns a status code in flags, the preamble should list all it might return.
|
||||
|
||||
## Globals
|
||||
|
||||
Any function that uses global variables should document this in the preamble comment, see above.
|
||||
|
||||
A file/module should check on intialisation that the address `globals.MAGIC_ADDRESS` contains the 16 bit value `globals.MAGIC_VALUE`, to ensure that the user has properly included [[src/start.asm]] and reservered the global variable area.
|
||||
|
||||
No opinion is offered on whether modules can assume globals variables are initialised to zero.
|
||||
Reference in New Issue
Block a user