From 4d752ef67cfebccf22417da9e47e2e94e14c9687 Mon Sep 17 00:00:00 2001 From: Gelthor Date: Fri, 4 Sep 2026 15:25:40 +0100 Subject: [PATCH 1/7] Added initial draft of globals and errno --- errno.asm | 24 ++++++++++++++++++++++++ globals.asm | 18 ++++++++++++++++++ start.asm | 4 ++++ 3 files changed, 46 insertions(+) create mode 100755 errno.asm create mode 100755 globals.asm create mode 100755 start.asm diff --git a/errno.asm b/errno.asm new file mode 100755 index 0000000..6f2bfb3 --- /dev/null +++ b/errno.asm @@ -0,0 +1,24 @@ +; Error numbers should be 16 bit ODD numbers, so they can be loaded as immediates +; and can be checked with: +; +; qcall falible_function +; jne falible_ok ; Jump no error +; ; handle error +; falible_ok: +; ; Happy path +; ; ... +; OR +; qcall falible_function +; je handle_error ; Jump if error +; ; Happy path +; ; ... +; handle_error: +; ; handle error + +pub const OK = 0x0000 +pub const SCREEN_INVALID_MODE = 0x0001 +pub const SCREEN_INVALID_WIDTH = 0x0003 +pub const SCREEN_FB_TOO_SMALL = 0x0005 + +; Extended error codes, these would require loading a 32 bit value. +pub const EXT_OK = 0x00000000 \ No newline at end of file diff --git a/globals.asm b/globals.asm new file mode 100755 index 0000000..9dc0df4 --- /dev/null +++ b/globals.asm @@ -0,0 +1,18 @@ +; Addresses of global variables + +; If not double buffering these point to the same buffer +pub const FB_DISPLAY_PTR = 16 ; U32 Currently displayed buffer +pub const FB_DRAW_PTR = 20 ; U32 Draw to this buffer +pub const FRAME_BUFFER_SIZE = 24 ; U32 +pub const PIXEL_WIDTH = 28 ; U16 +pub const PIXEL_HEIGHT = 30 ; U16 + +; Log2 of width in pixels, e.g. +; * 10 => 1024 * 768 +pub const LOG_WIDTH = 32 ; U8 + +pub const BYTES_PER_PIXEL = 33 ; U8 +; Log2 of bytes per pixel +; * 0 => 8 bits per pixel +; * 2 => 32 bits per pixel +pub const LOG_BPP = 34 ; U8 diff --git a/start.asm b/start.asm new file mode 100755 index 0000000..4c7f7f2 --- /dev/null +++ b/start.asm @@ -0,0 +1,4 @@ +@0 ; Reserve space for globals + +jmp 0x100 ; jump over them +@0x100 ; start of user code \ No newline at end of file -- 2.54.0 From 04f3f03ad5c644cc23007f111ec3c8806eefa48c Mon Sep 17 00:00:00 2001 From: Gelthor Date: Fri, 4 Sep 2026 16:42:35 +0100 Subject: [PATCH 2/7] Moved new *.asm files into src/ v --- errno.asm => src/errno.asm | 0 globals.asm => src/globals.asm | 0 start.asm => src/start.asm | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename errno.asm => src/errno.asm (100%) rename globals.asm => src/globals.asm (100%) rename start.asm => src/start.asm (100%) diff --git a/errno.asm b/src/errno.asm similarity index 100% rename from errno.asm rename to src/errno.asm diff --git a/globals.asm b/src/globals.asm similarity index 100% rename from globals.asm rename to src/globals.asm diff --git a/start.asm b/src/start.asm similarity index 100% rename from start.asm rename to src/start.asm -- 2.54.0 From 46abf8d893ad55f5e20993456360d080184bf084 Mon Sep 17 00:00:00 2001 From: Gelthor Date: Sun, 6 Sep 2026 11:02:27 +0100 Subject: [PATCH 3/7] 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. --- CONTRIBUTING.md | 13 +- README.md | 9 +- src/errno.asm | 3 + src/globals.asm | 24 +- src/graphics_32.asm | 672 ++++++++++++++++++++++++++++++++++++++++++++ src/start.asm | 23 +- 6 files changed, 730 insertions(+), 14 deletions(-) create mode 100644 src/graphics_32.asm diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ed897a3..f316bb3 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -16,10 +16,21 @@ All functions in the standard library should follow the following outline: ; Arguments: ; Result: ; Clobbers: +; Globals: