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 that 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 Standard Library.
start.asm also initialises sp so it starts just below the 64KiB LUT memory allocation.
Added some error codes for the upcoming graphics module.
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 that 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 Standard Library.
`start.asm` also initialises `sp` so it starts just below the 64KiB LUT memory allocation.
Added some error codes for the upcoming graphics module.
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.
Since this function lives in graphics_32, I'd expect that to imply 32 bits per pixel. If the same function is intended to be used for both modes, it should live in a generic graphics file.
Since this function lives in `graphics_32`, I'd expect that to imply 32 bits per pixel. If the same function is intended to be used for both modes, it should live in a generic graphics file.
If you are worried about register pressure, rather than having 2 bool arguments like this you could have a single u32 argument holding a bitwise OR of flags.
If you are worried about register pressure, rather than having 2 bool arguments like this you could have a single u32 argument holding a bitwise OR of flags.
I'd recommend centralizing the function epilogue. Otherwise, if a future refactor changes which registers need to be saved and one of the return sites is missed that could lead to nasty errors.
I'd recommend centralizing the function epilogue. Otherwise, if a future refactor changes which registers need to be saved and one of the return sites is missed that could lead to nasty errors.
Should we document these as returns instead? If any caller is writing to the buffer directly, they could then rely on this return and skip the extra load.
Should we document these as returns instead? If any caller is writing to the buffer directly, they could then rely on this return and skip the extra load.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Added support for global variables.
This requires including
start.asmas the first code. This includes ajmpto 0x100 for user code, and a magic number that modules can check to verify that the user has correctly reserved the space.The magic number is 0xb301534c:
nor zr, zr, 0x534ca no-op.start.asmalso initialisesspso it starts just below the 64KiB LUT memory allocation.Added some error codes for the upcoming graphics module.
@@ -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>Which errors can occur (if any) should probably have its own section here, probably called "Errors"
@@ -0,0 +28,4 @@; - r5: If non-zero, clears the current framebuffer.; - r6: If non-zero, enable double buffering; Returns:; - r1: StatusThe status is returned in
flags, notr1. Errors should probably have their own dedicated section here@@ -0,0 +1,28 @@; Addresses of global variablesI'd personally rather see reserved addresses put in hex, but I don't have a good reasoning for that.
@@ -0,0 +22,4 @@; * 2 => 32 bits per pixelpub const FB_LOG_BPP = 43 ; U8 Specialisations should hardcode thispub const MAGIC_ADDRESS_LONG = 12 ; U32 Location of the magic valueIf we do not declare these addresses in order, I fear we will accidentally introduce double use of an address at some point.
@@ -0,0 +23,4 @@; Arguments:; - r1: Point to allocated framebuffer; - r2: Size of FB allocation, in bytes; - r3: Bits per pixel: One of `8` or `32`Since this function lives in
graphics_32, I'd expect that to imply 32 bits per pixel. If the same function is intended to be used for both modes, it should live in a generic graphics file.@@ -0,0 +25,4 @@; - r2: Size of FB allocation, in bytes; - r3: Bits per pixel: One of `8` or `32`; - r4: Width - height is set to `width / 4 * 3`; - r5: If non-zero, clears the current framebuffer.If you are worried about register pressure, rather than having 2 bool arguments like this you could have a single u32 argument holding a bitwise OR of flags.
I'm not sure register pressure is important for a rarely called initialisation function.
@@ -0,0 +67,4 @@mov r8, 0jmp mode_okinvalid_mode:I'd recommend centralizing the function epilogue. Otherwise, if a future refactor changes which registers need to be saved and one of the return sites is missed that could lead to nasty errors.
@@ -0,0 +81,4 @@ja width_invalidcmp r4, 4jb width_invalid; Is width a power of two?There is a bit trick for this:
!(v & (v - 1)). Though that does not yield the log2.Fixed the comment to describe what the code actually does.
@@ -0,0 +178,4 @@mov flags, 0 ; OKjmp r13 ; returnpub set_text_mode:I think I'd rather see graphics mode and text mode code in separate files.
@@ -0,0 +415,4 @@; Returns:; - None; Clobbers:; - r1: Old display FB => new draw FBShould we document these as returns instead? If any caller is writing to the buffer directly, they could then rely on this return and skip the extra load.
@@ -0,0 +438,4 @@; Framebuffer pointer is stored in FB_PTR.;; Arguments:; - r1 Color 24 bit RGB0 PRESERVEDThe function code does not match this argument list