tkchia / gcc-ia16

Fork of Lambertsen & Jenner (& al.)'s IA-16 (Intel 16-bit x86) port of GNU compilers ― added far pointers & more • use https://github.com/tkchia/build-ia16 to build • Ubuntu binaries at https://launchpad.net/%7Etkchia/+archive/ubuntu/build-ia16/ • DJGPP/MS-DOS binaries at https://gitlab.com/tkchia/build-ia16/-/releases • mirror of https://gitlab.com/tkchia/gcc-ia16
GNU General Public License v2.0
178 stars 13 forks source link

Medium memory model! #24

Closed tkchia closed 5 years ago

tkchia commented 6 years ago

Now that I have got the IA-16 toolchain to support far functions --- and the MZ relocations needed to support them --- it now looks feasible to me to add support for the "medium" memory model, with one data segment and multiple text segments. This should help expand the range of programs we can express and build using gcc-ia16.

The main modifications to the toolchain will be to make sure that all functions are far by default --- even internal libgcc functions such as __udivsi3 --- and to make sure that pointer sizes, stack frame offsets, library routine implementations, etc. all reflect that.

(Unfortunately, it still seems tricky to implement the memory models with multiple data segments, i.e. "compact", "large", and "huge", or even separate data and stack segments for things like callbacks and interrupt handlers. These probably require some more thought.)

tkchia commented 6 years ago

(Argh! I think I am getting a roadblock at an unexpected place --- the libstdc++ library code included with the rest of GCC. My initial idea for implementing the medium model was to hack the machine-independent middle end to make all functions have a "non-default" far address space by default, but GCC's C++ parser started throwing out error messages whenever it saw any kind of type qualifier --- including __far --- tacked onto a function.)

zfigura commented 5 years ago

Realistically all functions shouldn't be far by default, only those that need to be put in different text segments (and those that are global symbols or can be accessed externally).

xor2003 commented 5 years ago

Vote for this feature. Huge model need for my masm2c project.

tkchia commented 5 years ago

Hello all,

I am now giving another try at implementing the medium memory model, using a slightly less intrusive method (which avoids hacking the machine-independent middle end). This is still work in progress, and is currently in a separate Git branch.

Thank you!

tkchia commented 5 years ago

Hello all,

I have got medium memory model support for C pretty much working, so I am merging the code into my main Git branch.

I hope to do further tests to get everything stabilized.

The medium model is still not supported for C++ though. The machine-independent C++ middle-end code has no concept of named address spaces or even different kinds of pointers; it seems to me that getting everything to work correctly would require rather extensive changes to this middle-end, which I prefer not to do yet. So I think I will hold off on implementing C++ support for now.

Thank you!