Setting Up the Procedure

The linker cannot combine the assembly-language procedure with the C program unless you define compatible segments and declare the procedure properly. Perform the following steps to set up the procedure:

Use the .MODEL directive at the beginning of the source file; this directive automatically causes the appropriate kind of returns to be generated (NEAR for tiny, small or compact models, FAR for medium, large, or huge models).

If you are using a version of MASM prior to 5.0, declare the procedure NEAR for small or compact model, FAR for medium, large, or huge models.

Use the simplified segment directives .CODE and .DATA to declare the code and data segments.

If you are using a version of MASM prior to 5.0, declare the segments using
the SEGMENT, GROUP, and ASSUME directives. These directives are described in the Microsoft Macro Assembler Reference.

Use the PUBLIC directive to declare the procedure label public. This declaration makes the procedure visible to other modules. Also declare any data you want to make public as PUBLIC.

Use the EXTRN directive to declare any global data or procedures accessed by the routine as external. The safest way to use EXTRN is to place the directive outside any segment definition; however, place near data inside the data segment.

Observe the C naming convention; precede all procedure names and global data names with an underscore.