Releases: qb40/masm
Releases · qb40/masm
MASM 6.11 : Microsoft.
Microsoft(R) Macro Assembler Package
Version 5.10
Copyright 1988, Microsoft Corporation
Text files on the Macro Assembler disks are tabbed to save
disk space. If your printer does not automatically handle
tabs during printing, you must use a print program that
expands tabs. For example, use the DOS PRINT program to print
this and other document or source files on the disk.
The Microsoft Macro Assembler (MASM)
Mixed-Language Support for Variables and Procedures
---------------------------------------------------
All EXTRN, PUBLIC, and PROC items, as well as uses of the .MODEL
directive, support a language type. The language type of EXTRN
and PUBLIC variables determine whether or not an underscore is
prefixed to the name (an underscore is prefixed only for variables
with a C language type), and the language type of a procedure determines
its calling and naming conventions. For an explanation of calling
and naming conventions, see the Microsoft Mixed-Language Programming
Guide.
The language type consists of the word "C" or "Pascal" and uses the
following syntax (lowercase items are placeholders, and bracketed items
are optional):
EXTRN [<langtype>] <varname>:<type>
PUBLIC [<langtype>] <varname>
procName PROC [NEAR|FAR] [<langtype>] [USES <regs>,] <args>
For example, the C and Pascal keywords are used correctly in the
following example:
.MODEL SMALL,C
EXTRN Pascal DosOpen:FAR
PUBLIC C myVar
myOpen PROC Pascal fName:PTR, mode:WORD
.
.
.
myOpen ENDP
EVEN and ALIGN Directives
-------------------------
Padding for EVEN and ALIGN is now optimized. Data segments
are padded with zeros. Code segments are padded with special
two-byte NOP instructions where possible. The two-byte NOP
consists of the instruction XCHG BX,BX (87 DB hexadecimal)
which is executed faster than two one-byte NOP instructions.
/B Option Ignored
-----------------
The /B option is now ignored, because its effect is irrelevant,
given the new file buffering mechanism. However, the option is
still accepted for the purposes of compatibility.
The PTR Operator
----------------
The PTR operator can be used to specify the size of a
register indirect operand for a CALL or JMP instruction.
However, the size cannot be specified with NEAR or FAR. Use
WORD or DWORD instead. (In 80386 32-bit segments, use DWORD
or FWORD.) Examples are shown below:
; 8086, 80826, or 80386 16-bit mode
jmp WORD PTR [bx] ; Legal near jump
call NEAR PTR [bx] ; Illegal near call
call DWORD PTR [bx] ; Legal far call
jmp FAR PTR [bx] ; Illegal far jump
; 80386 32-bit mode only
jmp DWORD PTR [bx] ; Legal near jump
call NEAR PTR [bx] ; Illegal near call
call FWORD PTR [bx] ; Legal far call
jmp FAR PTR [bx] ; Illegal far jump
This limitation only applies to register indirect operands.
NEAR or FAR can be applied to operands associated with
labels. Examples are shown below:
jmp NEAR PTR pointer[bx] ; Legal
call FAR PTR location ; Legal
Assembler Behavior Change
-------------------------
Some errors and questionable practices that were ignored by
earlier versions are now flagged as errors. As a result,
existing source code may produce errors or warnings.
The following are examples:
- Labels defined only during pass 1 cause errors if
used in expressions.
- A CS ASSUME that changes from pass 1 to pass 2 causes
an error.
- Constants are now checked for type overflow.
- Reserved words used as labels produce warnings.
- The OFFSET operator used with a constant causes an error.
The STACK Combine Type
----------------------
The description of the STACK combine type in Section 5.2.2.3
does not explain how multiple initialized stack segments are
combined. The total size of the stack is the total size of
all stack definitions. LINK puts initialized data for each
defined stack segment at the end of the stack. Data initialized
in the last segment linked override data initialized in
previous segments. This behavior is usually not relevant, since
most programs only define one stack of uninitialized data.
Stack data cannot be initialized with simplified segment
directives.
Clarification of Parsing Error
------------------------------
The following error can be difficult to interpret because of the
way the assembler parses (analyzes) source code:
A2015: Symbol already different kind: <name>
Typically, the assembler generates this error message when a
symbol is used in a way inconsistent with how it was declared: for
example, a symbol is declared as an external absolute but then used
as a local code label. However, the assembler also generates this
error when a symbol in the second source-code field can be interpreted
as either an operation or an operand. The following example illustrates
this problem:
SYM1 MACRO structName, varName
varName structName <>
ENDM
SYM2 STRUCT
field1 DB
field2 DW
SYM2 ENDS
SYM1 SYM2, <mylabel>
The last line of code causes error A2015 to be generated. The
assembler first looks at the second field of the line, which
contains the symbol SYM2. Since SYM2 is a structure, the assembler
considers SYM2 to be an operation rather than an operand, and therefore
it considers SYM1 to be a label (rather than an operation). The way
to avoid this error is simply code the instruction as:
SYM1 <SYM2>, <mylabel>
HIGH and LOW Operators
----------------------
The HIGH and LOW operators work reliably only with constants
and with offsets to external symbols. HIGH and LOW operations are
not supported for offsets to local symbols.
Mixed-Mode Programming (386 Only)
---------------------------------
When assembling code for .386 mode, the assembler now supports direct-
addressing modes between segments with different USE sizes. (Segments can
have the USE16 or USE32 attribute; these attributes refer to the default
size of offsets.) Direct-addressing references to labels in other segments
are correctly resolved. In the following example, the assembler correctly
uses a 32-bit offset to access the data at label a32:
.386
SEG32 SEGMENT USE32
a32 DD ?
SEG32 ENDS
SEG16 SEGMENT USE16
assume ds:seg32
mov eax,a32
SEG16 ENDS
You can also execute a CALL or a JMP to a label in a segment with a
different USE size. However, the label must be declared FAR, and the
CALL or JMP must not be a forward reference. The following example
shows the correct method for executing such a CALL or JMP:
.386
COD16 SEGMENT USE16 'CODE'
proc16 PROC FAR
ret
proc16 ENDP
lab16 LABEL FAR
COD16 ENDS
COD32 SEGMENT USE32 'CODE'
call proc16
jmp lab16
COD32 ENDS
Additional Error Messages
-------------------------
19 Wrong type of register
The register specified in the operand field was incompatible with the
directive or instruction in the operation field. For example, the following
instruction causes this error because you cannot increment the
code segment:
inc cs
36 Extra NOP inserted
During pass 1 the assembler did not have enough information to
correctly infer the length of the encoding for the instruction.
During pass 2 the encoding was found to be shorter than the space
allocated from pass 1, so one or more NOP instructions were inserted
as padding. It may be possible to generate a smaller amount of code
by eliminating a forward reference to a symbol.
The Microsoft Cross-Reference Utility (CREF)
New Feature
-----------
Cross-reference listing files created with CREF now have an
additional symbol. A line number followed by + indicates
that a symbol is modified at the given line. For example:
TST . . . . . . . . . . . . . . 134# 237 544+
The symbol TST is defined at line 134, used at line 237, and
modified at line 544.
The Mouse Driver
If you use the Microsoft Mouse with the Microsoft CodeView(R) debugger
you must have Version 6.0 or later of the Microsoft Mouse. If you do not, use
the version of the MOUSE.COM driver provided in this package. Copy MOUSE.COM
to the appropriate mouse directory. When you are ready to use the mouse, type
mouse
at the DOS command level. If you want to install the mouse driver automatically
every time you reboot, insert the "mouse" command in your AUTOEXEC.BAT file.
Note that in earlier releases of Microsoft C, both the MOUSE.SYS and the
MOUSE.COM driver were provided. If you have been using an earlier version
of the MOUSE.SYS driver, delete the following line from your CONFIG.SYS file:
device=\<directory>\mouse.sys
where <directory> is the directory where the earlier mouse driver resides.
Microsoft CodeView Debugger
New Command-Line Option
-----------------------
If you have an IBM Personal System/2, then you can use the /50
command-line option to start the CodeView debugger in 50-line mode.
Note that you must be in 25-line mode to effectively use either the
/43 or /50 command-line option.
CONFIG.SYS Setting for CVP
--------------------------
To run the protected-mode CodeView debugger (CVP.EXE), you must have
the following line in your CONFIG.SYS file:
IOPL=YES
Using the 7 Command in Protected Mode
-------------------------------------
If you are using OS/2 protected mode and have a math coprocessor, then
you need to use a patch before you can use the CVP 7 command. To apply
the patch, use the OS2PATCH.EXE and PTRACE87.PAT files that come on the
same disk that CVP.EXE comes on. You also need to locate the PATCH.EXE file
that comes with OS/2 and make sure that this file is in a directory listed
in your PATH environment variable. Then follow these steps:
1) Change the current drive and directory to the root directory of the
boot disk. (If the boo...