MASM 6.0 ALIGN Directive Requires Patch to Work Correctly

ID Number: Q73190

6.00 | 6.00

MS-DOS | OS/2

buglist6.00

Summary:

The Microsoft Macro Assembler (MASM) version 6.0 may generate

incorrect code with respect to the ALIGN directive. If the alignment

value specified is larger than 2, the padding generated by the

assembler may consist of incorrect instructions. Instead of generating

an opcode for a no-operation "mov ax,ax" instruction (8Bh C0h), the

assembler may reverse the bytes that are output (C0h 8Bh), resulting

in code that fails to run correctly.

This problem may be corrected by patching ML.EXE with one of the debug

scripts provided below.

More Information:

The ALIGN instruction is used to indicate the boundary on which to

start the next instruction. For example, a statement such as

ALIGN 4

indicates that the next instruction should start on a 4-byte

boundary.

MASM version 6.0 may use a 2-byte instruction (that has no effect) to

pad the code. In this case, the opcode may be reversed as described

above. This problem may be illustrated by assembling the sample code

below.

The following debug scripts will patch either the DOS or OS/2 version

of ML.EXE. Before performing this operation on your .EXE files, make a

backup copy in case something goes wrong.

Debug Script for DOS

--------------------

1: a 7d8a

2: mov ax, ax

3:

4: w

5: q

Debug Script for OS/2

---------------------

1: a 325a

2: mov ax, ax

3:

4: w

5: q

To utilize one of these scripts, type the specified commands (without

the line numbers) into a file called PATCH.SCR. Note that line 3 in

both scripts should be left blank as indicated. Next, create and run a

batch file that contains the following commands:

REN ML.EXE ML.DAT

DEBUG ML.DAT < PATCH.SCR

REN ML.DAT ML.EXE

Microsoft has confirmed this to be a problem in MASM version 6.0. We

are researching this problem and will post new information here as it

becomes available.

Sample Code

-----------

;Assemble options needed: none

.model large

.stack

.data

@data ends

_CodeSeg segment para public 'code'

main proc

mov ax, dx

align 8

mov ax, 0

main endp

_CodeSeg ends

end

Additional reference words: 6.00