LMAPGC08 - 211 CHAPTER 1 Sharing Data and Procedures Among...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
211 CHAPTER 1 \z "MODULW.DOC-1001" To use symbols and procedures in more than one module, the assembler must be able to recognize the shared data as global to all the modules where they are used. MASM provides techniques to simplify data-sharing and give a high-level interface to multiple-module programming. With these techniques, you can place shared symbols in include files. This makes the data declarations in the file available to all modules that use the include file. This chapter explains the two data-sharing methods MASM 6.1 offers. The first method simplifies data sharing between modules with include files. The second does not involve include files. Instead, this method allows modules to share procedures and data items using the PUBLIC and EXTERN directives. The last section of this chapter explains how to create program libraries and access their routines. Selecting Data-Sharing Methods \z "MODULW.DOC-1002" \z "MODULW.DOC-1003" \z "MODULW.DOC-1004" \z "MODULW.DOC-1005" \z "MODULW.DOC-1006" \z "MODULW.DOC-1007" \z "MODULW.DOC-1008" \z "MODULW.DOC-1009" \z "MODULW.DOC-1010" If data defined in one module is to be used in other modules of a program, you must declare the data public and external. MASM provides several ways to do this: u Declare a symbol public with the PUBLIC directive in the module where it is defined. This makes the symbol available to other modules. You must also place an EXTERN statement for that symbol in all other modules that refer to the public symbol. This statement informs the assembler that the symbol is external — that is, defined in another module. Sharing Data and Procedures Among Modules and Libraries Filename: b24f81fa54debd2de4c42c3cf235999721476eb9.DOC Project: Template: Author: Last Saved By: Revision #: 0 Page: 211 of 14 Printed:
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Programmer’s Guide \z "MODULW.DOC-1011" \z "MODULW.DOC-1012" u Declare the data communal with the COMM directive. However, communal variables have limitations. You cannot depend on their location in memory because they are allocated by the linker, and they cannot be initialized. \z "MODULW.DOC-1013" \z "MODULW.DOC-1014" The EXTERNDEF directive declares a symbol either public or external, as appropriate. EXTERNDEF simplifies the declarations for global (public and external) variables and encourages the use of include files. The next section provides further details on using include files. For more information on PUBLIC and EXTERN , see “Using Alternatives to Include Files,” page 219. Sharing Symbols with Include Files \z "MODULW.DOC-1015" \z "MODULW.DOC-1016" \z "MODULW.DOC-1017" Include files can contain any valid MASM statement, but typically consist of type and symbol declarations. The assembler inserts the contents of the include file into a module at the location of the INCLUDE directive. Include files are optional, but can simplify project organization by eliminating the need to insert common declarations into all modules of a program. An alternative to using include files is described in “Using Alternatives to Include Files,” page 219. \z "MODULW.DOC-1018"
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 01/24/2012 for the course EE 3751 taught by Professor Desouza during the Spring '04 term at LSU.

Page1 / 14

LMAPGC08 - 211 CHAPTER 1 Sharing Data and Procedures Among...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online