Open stsp opened 1 year ago
Hello @stsp,
There is no support for linear addressing yet — but it does sound like such a thing might be useful. :thinking:
Thank you!
Hi,
Actually this is partially supported if you use far pointers in C. If you declare a far pointer like: char __far *str
it will be a 32 bits pointer that allows you to address anywhere in your memory.
However, the 32 bit address stored in the pointer will have the following representation : segment << 16 | offset
where segment
is the value that should be set in the segment register. For instance a pointer to somewhere in the segment 1 at offset xxxx will be an adress like 0x1000xxxx
. Which prevent from doing pointer arithmetic as if it was a linear address space.
@tkchia is there any particular reason why this representation was chosen ? Would it be possible to use a representation like 0x000axxxx
where a
is the segment number and xxxx
the offset ? It would then allow to consider the full address space as flat, and would allow pointer arithmetic to work. It would be more work on code generation side tho.
Hi, just a quick question. Does ia16-gcc support flat memory model? I.e. I want to be able to construct flat pointers from 32bit ints (staying within 1st MB of course), and on a dereference of such a pointer, gcc should convert it to seg/off pair. This will allow to port some existing 32bit code. Is that possible?