Flat memory model

A program written in native 32 bit Windows format is created in what is called FLAT memory model that has a single segment, which contains both code and data.  Such programs must be run on a 80386 or higher processor.

Differing from earlier 16-bit code that used combined segment and offset addressing with a 64 Kb segment limit, FLAT memory model works only in offsets and has a range of 4 Gigabytes.  This makes assembly code easier to write and the compiled (assembled) code is generally a lot faster than the equivalent 16-bit code.

All segment registers are automatically set to the same value with the flat memory model.  This means that segment / offset addressing must NOT be used in 32-bit programs that run in 32-bit Windows operating systems.

For programmers who have written code in DOS, a 32-bit Windows PE (executable) file is similar in some respects to a DOS COM file - they have a single segment that can contain both code and data and they both work directly in offsets.  That is, neither uses segment / offset addressing.

Flat-model assembler code defaults to NEAR code addressing and NEAR data addressing within the range of 4 gigabytes.

The FS and GS segment registers are rarely (if ever) used in application programs but may be used in some instances by the operating system itself.


See Also

The Inline Assembler

Protected mode programming

Mnemonics and Operands