New MASM Language Features

MASM 6.0 includes a number of new features, described in the list below, designed to make programming more efficient and intuitive and to increase your productivity. For example, MASM's new high-level-language features mean that you can get the speed of assembly language with the ease of high-level languages. You can also maintain your programs more easily.

MASM 6.0 has many enhancements related to types. You can now use the same type specifiers in initializations as in other contexts (BYTE instead of DB). You can also define your own types, including pointer types, with the new TYPEDEF directive. See Chapter 3, “Using Addresses and Pointers,” and Chapter 4, “Defining and Using Integers.”

The syntax for defining and using structures and records has been enhanced. You can also define unions with the new UNION directive. See Chapter 5, “Defining and Using Complex Data Types.”

MASM now generates complete CodeView information for all types. See Chapter 3, “Using Addresses and Pointers,” and Chapter 4, “Defining and Using Integers.”

New control-flow directives let you use high-level-language constructs such as loops and if-then-else blocks defined with .REPEAT and .UNTIL (or .UNTILCXZ); .WHILE and .ENDW; and .IF, .ELSE, and .ELSEIF. The assembler generates the appropriate code to implement the control structure. See Chapter 7, “Controlling Program Flow.”

MASM now has more powerful features for defining and calling procedures. The extended PROC syntax for generating stack frames has been enhanced in version 6.0. You can also use the PROTO directive to prototype a procedure, which you can then call with the INVOKE directive. INVOKE automatically generates code to pass arguments (converting them to a related type, if appropriate) and make the call according to the specified calling convention. See Chapter 7, “Controlling Program Flow.”

MASM optimizes jumps by automatically determining the most efficient coding for a jump and then generating the appropriate code. See Chapter 7, “Controlling Program Flow.”

Maintaining multiple-module programs is easier in MASM 6.0. The EXTERNDEF and PROTO directives make it easy to maintain all global definitions in include files shared by all the source modules of a project. See Chapter 8, “Sharing Data and Procedures among Modules and Libraries.”

The assembler has many new macro features that make complex macros clearer and easier to write:

You can specify default values for macro arguments or mark arguments as required. And with the VARARG keyword, one parameter can accept a variable number of arguments.

You can implement loops inside of macros in various ways. For example, the new WHILE directive expands the statements in a macro body while an expression is not zero.

You can define macro functions, which return text macros. Several predefined text macros are also provided for processing strings. Macro operators and other features related to processing text macros and macro arguments have been enhanced. For more information on all these macro features, see Chapter 9, “Using Macros.”

Finally, MASM 6.0 has improved customizable capabilities:

With the new .STARTUP and .EXIT directives you can automatically generate appropriate start-up and exit code for DOS or OS/2 modules. See Chapter 2, “Organizing MASM Segments.”

MASM 6.0 supports flat memory model, available with OS/2 version 2.0. In flat model, segments can be as large as 4 gigabytes instead of 64K (kilobytes). Offsets are 32 bits instead of 16 bits. See Chapter 2, “Organizing MASM Segments.”

The program H2INC.EXE converts C include files to MASM include files and translates data structures and declarations. See Chapter 16, “Converting C Header Files to MASM Include Files.”

MASM 6.0 includes many other minor new features as well as extended support for features of earlier versions of MASM. These features are listed in Appendix A, “Differences between MASM 6.0 and 5.1,” with cross-references to the chapters where they are discussed in detail.