The .MODEL directive establishes a predefined set of definitions, conventions, and modifications to various default operating behaviors of the assembler. These adjustments are designed to simply certain programming tasks and to allow a more seamless integration with routines written in high level languages.
Syntax
.MODEL Memory-Model[,Language-Type][,OS-Type][,Stack-Distance]
Memory-Model:
The .MODEL directive should be placed at the top of the file, after any processor control directives, but before any of the following simplified segmentation directives are encountered:
Each of these directives close any segment that is currently opened, then open a different segment whose name and attributes are determined by the Memory-Model argument.
Memory-Model
The fundamental purpose of establishing a programming memory model is to define how the program will be organized within the constraints of the segmented processor architecture. It defines whether there are single or multiple default code and data segments, or whether the default code and data segments are merged into a single segment. The operating system upon which the program will run is a determining factor of which memory models can be used. The following table describes these relationships.
┌────────┬────────┬────────┬────────┬────────────────────────┐ │Memory │Default │Default │Merged? │Operating Systems │ │Model │Code │Data │ │ │ ├────────┼────────┼────────┼────────┼────────────────────────┤ │Tiny │Near │Near │Yes │DOS │ ├────────┼────────┼────────┼────────┼────────────────────────┤ │Small │Near │Near │No │DOS, 16-Bit OS/2, Win16 │ ├────────┼────────┼────────┼────────┼────────────────────────┤ │Medium │Far │Near │No │DOS, 16-Bit OS/2, Win16 │ ├────────┼────────┼────────┼────────┼────────────────────────┤ │Compact │Near │Far │No │DOS, 16-Bit OS/2, Win16 │ ├────────┼────────┼────────┼────────┼────────────────────────┤ │Large │Far │Far │No │DOS, 16-Bit OS/2, Win16 │ ├────────┼────────┼────────┼────────┼────────────────────────┤ │Huge │Far │Far │No │DOS, 16-Bit OS/2, Win16 │ ├────────┼────────┼────────┼────────┼────────────────────────┤ │Flat │Near │Near │Yes │32-Bit OS/2, Win32 │ └────────┴────────┴────────┴────────┴────────────────────────┘
The assembler creates the default code and data segments, then automatically generates an ASSUME CS:@code and an ASSUME DS:@data statement to refer to them.
Language-Type
Specifies the default naming convention for all public identifiers written that to the object file, and the method whereby parameters are passed to procedures (the calling convention). See the section on the PROC directive for a detailed explanation of the effects of the Language-Type setting.
OS-Type
This parameter identifies the target operating system upon which the program will run, and is provided for compatibility with other assemblers. ALP ignores this parameter.
Stack-Distance
The NEARSTACK parameter causes the assembler to assume that the stack segment and the default data segment are the same, and that the DS register is equal to the SS register. This is the default setting. The assembler performs an automatic ASSUME SS:@data statement when a near stack is used.
The FARSTACK parameter causes the assembler to assume that the stack is in a different physical segment from that of the default data, and that SS register is not equal to DS. This is typically the case for code in a 16-bit dynamic link library that must use the caller's stack. The assembler performs an automatic ASSUME SS:STACK when this keyword is used.