Skip to content

[c86, paint] Support C86 __loadreg builtin, get paint back running w/OWC and C86#2342

Merged
ghaerr merged 2 commits intomasterfrom
loadreg
Jun 10, 2025
Merged

[c86, paint] Support C86 __loadreg builtin, get paint back running w/OWC and C86#2342
ghaerr merged 2 commits intomasterfrom
loadreg

Conversation

@ghaerr
Copy link
Copy Markdown
Owner

@ghaerr ghaerr commented Jun 9, 2025

Adds register definitions for the new builtin function __loadreg enhancement to C86 in ghaerr/8086-toolchain#69.

This will allow supporting non-constant parameters to VGA vgalib.h ASM graphics macros for high speed VGA operation when using the C86 compiler. Both IA16 and OWC already support such a mechanism.

The recently added high speed bucket fill algorithm in ELKS Paint only supported the IA16 compiler. The vgalib.h graphics macros are updated here to support OWC and C86. The C86 macros have not yet been updated to allow for non-constant arguments, required by the new fill algorithm in vga_cmp8_init().

Unfortunately, the C86 compiler doesn't seem to support functions returning structs, so the high speed fill routine is replaced with the original slower fill routine for the C86 compiled version only, at least for now.

Paint's render.c code that uses a GCC non-standard extension to initialize structures doesn't work in OWC or C86; the code was changed to initialize the two (xl, xr) Segment structure members individually so that Paint will compile with all three compilers. I wanted to keep Paint operational with all our supported compilers as it's a useful way to learn about compiler portability issues. (BTW, initializing non-static constant structures or arrays within functions is extremely slow: the compiler will store the constant data in the data segment, then emit memcpy code to copy to the stack frame - way slower than initializing individually unless the structure is large).

Finally, the C86 -obsolete=yes feature showed that the C library alloca.h header file wasn't including the definition of size_t, which is now fixed.

@ghaerr ghaerr merged commit a8c19c2 into master Jun 10, 2025
2 checks passed
@ghaerr ghaerr deleted the loadreg branch June 10, 2025 02:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant