Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- TASM 2.x / MASM 6.x Assembly Language - <b>.model sets memory model directive</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
.MODEL           Sets Memory Model                                  Directive

  .MODEL name [,language]
  .MODEL TPASCAL (TASM Only)

     You use this directive to set the memory model in a program.

     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 .CODE or .DATA. For the 80386: if you
     want to use 16-bit segments, use the .386 directive after
     .MODEL. Otherwise, the assembler defaults to 32-bit segments.

     The memory model name can be TINY (TASM only), SMALL, MEDIUM,
     COMPACT, LARGE, or HUGE. Here is a list of memory models and their
     definitions:

     Model   Means
     -----   --------------------------------------------------------
     TINY    Code and Data fit into 64K. The program can be made into
             a .COM file. This model, also called Small Impure, is
             available only in Turbo C.

     SMALL   All data fits in one 64K segment, all code fits in one
             64K segment. Maximum program size is 128K.

     MEDIUM  All data fits in one 64K segment, but code may be
             greater than 64K.

     COMPACT Data may be greater than 64K (but no single array may
             be), code must be less than 64K. (Turbo: static data must be
             less than 64K.)

     LARGE   Both data and code may be greater than 64K, but no
             single array may be. (Turbo: static data must be less than
             64K.)

     HUGE    Data, Code, and and data arrays may be greater than 64K.

     Here is a summary:

     Model   DATA vs. 64K    CODE vs. 64K    Arrays vs. 64K
     -----   ------------    ------------    --------------
     TINY         <               <               < (TASM only)
     SMALL        <               <               <
     MEDIUM       <               >               <
     COMPACT      >               <               <
     LARGE        >               >               <
     HUGE         >               >               >

     If you want to link your program into a high level language, you
     should use the same memory model as it does, and specify the name of
     that language (BASIC, C, PASCAL, or FORTRAN) when you use .MODEL.

     For example, if you are linking to a SMALL model Pascal program, you
     should include the directive .MODEL SMALL, PASCAL. The assembler
     then uses the corresponding calling convention for the extended PROC
     and ENDP directives, and generates the correct entry and exit code.
     (See PROC for more information.)

     Note:   If you specify the C language, all PUBLIC procedure names
             will be prefixed with "_" automatically (as required for C
             library procedures).


See Also: PROC

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson