Statements are the line-by-line components of source files. Each MASM statement specifies an instruction or directive for the assembler. Statements have up to four fields. The syntax is shown below:
[[name]] [[operation]] [[operands]] [[;comment]]
The fields are explained below:
Field | Purpose |
name | Defines a label that can be accessed from elsewhere in the program. For example, it can name a variable, type, segment, or code location. |
operation | States the action of the statement. This field contains either an instruction or an assembler directive. |
operands | Lists one or more items on which the instruction or directive operates. |
comment | Provides a comment for the programmer. Comments are for documentation only; they are ignored by the assembler. |
The following line contains all four fields:
mainlp: mov ax, 7 ; Comments follow the semicolon
Here, mainlp is the label, mov is the operation, and ax and 7 are the operands, separated by a comma. The comment follows the semicolon.
All fields are optional, although certain directives and instructions require an entry in the name or operand field. Some instructions and directives place restrictions on the choice of operands. By default, MASM is not case sensitive.
Each field (except the comment field) must be separated from other fields by white-space characters (spaces or tabs). MASM also requires code labels to be followed by a colon, operands to be separated by commas, and comments to be preceded by a semicolon.
Summary: The backslash character joins physical lines into one logical line.
A logical line can contain up to 512 characters and occupy one or more physical lines. To extend a logical line into two or more physical lines, put the backslash character (\) as the last non-whitespace character before the comment or end of the line. You can place a comment after the backslash as shown in this example:
.IF (x > 0) \ ; X must be positive
&& (ax > x) \ ; Result from function must be > x
&& (cx == 0) ; Check loop counter too
mov dx, 20h
.ENDIF
Multiline comments can also be specified with the COMMENT directive. The assembler ignores all code between the delimiter character following the directive and the line containing the next instance of the delimiter character. This example illustrates the use of COMMENT.
COMMENT ^ The assembler
ignores this text
^ mov ax, 1 and this code