Re:Djgpp
by zozbot234 on Thursday January 18, 2024 @05:30AM
(#39040147)
16-bit x86 support requires supporting the old segment-based real mode memory models and _near / _far / _huge pointer types, which can be very fiddly. I'm not even sure if the existing standard extension for "multiple address spaces" in C can accommodate this, or if something even more bespoke is needed. If it can be done it would be great to have in LLVM, if only for completeness sake.
[ Parent
| on HN ]
You do not need segment registers much if you stick to the tiny model. Here is someone compiling Rust to a 16-bit DOS COM executable:
https://github.com/o8vm/rust_dos
Not sure what the approach would be for them to expand that to support segments.
In DJGPP there are macros to allow your protected mode application access physical real-mode addresses (like when you want to write to video RAM). I don't know if IA-16 also does something like that, or if they added far/near keywords to the language like old 16-bit C compilers did (at least the ones I used).
Free Pascal has helper-functions to work with segment+offset pointer pairs, also without having to modify the language itself. I think that would work well enough in C, but I guess the old method of adding non-standard keywords was seen as slightly more convenient.