2.1 Overview of Memory Segments

A physical segment is an area of memory in which all locations are contiguous and share the same segment address. A segment always begins on a 16-byte (paragraph) boundary (unless an alignment attribute is specified with ALIGN). While 16-bit segments can occupy up to 64K (kilobytes), 32-bit segments can be as large as 4 gigabytes.

Segments reflect the architecture of the original 8086 processor. Prior to the 80386 processors and OS/2 2.x, assembly-language programming meant using segmented memory. A flat address space is now available on 80386/486 processors in 32-bit mode. This space is still segmented at the hardware level, but it allows you to ignore most segmentation concerns.

Segments provide a means for associating similar kinds of data. Most programs have segments for code, data, constant data, and the stack. These logical segments are allocated by the assembler at assembly time.

You can define segments in two ways: with simplified segment directives and with full segment definitions. You can also use both kinds of segment definitions in the same program.

Summary: Simplified segment directives are easier to use than full segment definitions.

Simplified segment directives hide many of the details of segment definition and assume the same conventions used by Microsoft high-level languages. (See Section 2.2.) The simplified segment directives generate necessary code, specify segment attributes, and arrange segment order.

Full segment definitions require more complex syntax but provide more complete control over how the assembler generates segments. (See Section 2.3.) If you use full segment definitions, you must write code to handle all the tasks performed automatically by the simplified segment directives.