What defines a memory model?

In particular, this question concerns a flat and segmented model in real mode. I read an assembly book that mentions that DOS uses a flat memory model in COM files, and a segmented memory model is used in EXE files. However, I do not understand what DOS tells which memory model to use. I ask this question because I read about bootloaders.

+4
source share
3 answers

COM files used the โ€œflat memory modelโ€ in the sense that the segment registers were all set by DOS when the program was loaded to point to the same segment, and all codes and pointers were, by convention, relative to this one value in segments.

The EXE file format, on the other hand, allows you to load segments with different offsets. DOS will not set default segment registers; this was due to the code itself. 16-bit EXE code is much more complicated because the code must control the register of segments.

Currently, a lot of EXE code more or less ignores segment registers; 32 or 64-bit registers do not need to be added to the segment register to generate a useful address.

+4
source

The COM and EXE executable files had their own memory requirements in the file header: EXE header and COM (MS-DOS) . If the program requires <64 KB, use flat space; if> 64 KB, use segmented memory.

+1
source

In DOS, there is nothing that could force a COM file to use a segmented memory model, since DOS did not apply memory management policies in its applications.

You can read the wikipedia entry for COM files , it gives an idea of โ€‹โ€‹these old things.

+1
source

Source: https://habr.com/ru/post/1402325/


All Articles