MODEL            Set memory model                                   Directive

MODEL [model_modifier] memory_model [code_segment_name]
[,[language_modifier] language ]
[,model_modifier]


Sets the memory model for simplified segmentation directives.

Memory models set the size limits of the code and data areas for your
program. They determine whether the assembler considers data or code
references as NEAR or FAR addresses.

You must use the MODEL directive before using the simplified segment
directives such as CODESEG or DATASEG. In stand-alone assembly
programs, the STARTUPCODE directive must be used at the program's
entry point to enable the register assumptions described below,


Memory Register
model Code Data assumptions Description
────────────────────────────────────────────────────────────────────
TINY near near cs=dgroup All code and data combined
ds=ss=dgroup into a single group called
DGROUP. Used for .COM
assembly programs. Some
languages don't support
this model.
SMALL near near cs=_text Code is in a single segment.
ds=ss=dgroup All data is combined into a
group called DGROUP. This is
the most common model for
stand-alone assembly programs.
MEDIUM far near cs=<module>_text Code uses multiple segments,
ds=ss=dgroup one per module. Data is in a
group called DGROUP.
COMPACT near far cs=_text Code is in a single segment.
ds=ss=dgroup All near data is in a group
called DGROUP. Far pointers
are used to reference data.
LARGE far far cs=<module>_text Code uses multple segments,
ds=ss=dgroup one per module.
All near data is in a group
called DGROUP. Far pointers
are used to reference data.
HUGE far far cs=<module>_text Same as LARGE model, as far as
ds=ss=dgroup Turbo Assembler is concerned.
TCHUGE far far cs=<module>_text Same as LARGE model, but with
ds=nothing different register assumptions.
ss=nothing
TPASCAL near far cs=code This is a model to support
ds=data early versions of Turbo Pascal.
ss=nothing It's not required for later
versions.
FLAT near near cs=_text This is the same as the SMALL
ds=ss=flat model, but tailored for use
under OS/2.

model_modifier Function
NEARSTACK Indicates that the stack segment should be included
in DGROUP (if DGROUP is present), and SS should point
to DGROUP (default).
FARSTACK Specifies that the stack segment should never be
included in DGROUP, and SS should point to nothing.
USE16 Specifies (if ≥80386 code) that 16-bit segments
should be used for all segments in the selected model.
USE32 Specifies (if ≥80386 code) that 32-bit segments
should be used for all segments in the selected model
(default for ≥80386).
DOS, OS_DOS Specifies that DOS is the platform for the
application (default)
NT, OS_NT Specifies that Windows NT is the platform for the
application
OS2, OS_OS2 Specifies that OS/2 is the platform for the
application (undocumented !?)


More than one model modifier can be used. The model modifier can be
specified in two places, for MASM 5.2 compatibility.


code_segment_name (optional) can be used in the large models to
override the default name of the code segment. Normally, this is the
module name with _TEXT appended to it.


language and language_modifier together specify the default procedure
calling conventions, and the default style of the prolog and epilog
code present in each procedure. They also control how to publish
symbols externally for the linker to use. Turbo Assembler will auto-
matically generate the procedure entry and exit code (for procedures
declared with PROC/ENDP) that is proper for for procedures using any
of the following interfacing conventions: PASCAL, C, CPP (C++),
SYSCALL, STDCALL, BASIC, FORTRAN, PROLOG, and NOLANGUAGE (assembler).
If you don't specify language, TASM assumes the default language to
be NOLANGUAGE.

Use language_modifier to specify additional prolog and epilog code
when you write procedures for Windows, or for the Borland Overlay
loader. These options are: NORMAL, WINDOWS, ODDNEAR, and ODDFAR. If you
don't specify an option, TASM assumes the default to be NORMAL.

Also note that you can override the default language and language
modifier when you define a procedure. You can additionally override
the default language when you publish a symbol.


Predefined equates

Using the MODEL directive defines the following equates:

@Model, @32Bit, @CodeSize, @DataSize, @Interface

Using the simplified segment directives (CODESEG, DATASEG, UDATASEG,
FARDATA, UFARDATA, CONST, STACK) defines these symbols:

@code, @data, @fardata, @fardata?, @stack