Specifically this question is about flat and segmented model in real mode. I am reading a book on assembly which mentions that on DOS the COM files use flat memory model and EXE files use segmented memory model. However I am not understanding what tells DOS which memory model to use. I am asking this question because I am reading about bootloaders.
Share
COM files used a “flat memory model” in the sense that the segment registers were alll set by DOS when the program was loaded to point to the same segment, and all the code and pointers were, by convention, relative to that one value in the segment registers.
The EXE file format, on the other hand, allows for segments to be loaded at different offsets. DOS wouldn’t set the segment registers to default values; that was up to the code itself. 16-bit EXE code is a lot more complex because the code has to manage segment registers.
Nowadays a lot of EXE code more or less ignores segment registers again; 32 or 64-bit registers don’t need to be added to a segment register to generate a usable address.