DOCUMENT:Q73190 04-MAY-2001 [masm] TITLE :FIX: MASM 6.0 ALIGN Directive Requires Patch to Work Correctly PRODUCT :Microsoft Macro Assembler PROD/VER:MS-DOS:6.0 OPER/SYS: KEYWORDS: ====================================================================== ------------------------------------------------------------------------------- The information in this article applies to: - Microsoft Macro Assembler (MASM), version 6.0 ------------------------------------------------------------------------------- SYMPTOMS ======== 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. RESOLUTION ========== This problem may be corrected by patching ML.EXE with one of the following debug scripts. Before performing this operation on your EXE files, you might want to make a backup copy. 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 STATUS ====== Microsoft has confirmed this to be a problem in MASM version 6.0. This problem was corrected in MASM version 6.0a. 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. Sample Code ----------- ; Assemble options needed: none .MODEL large .STACK 4096 .DATA _data ENDS _CodeSeg SEGMENT para public 'code' main PROC mov ax, dx ALIGN 8 mov ax, 0 main ENDP _CodeSeg ENDS END main Additional query words: 6.00 buglist6.00 fixlist6.00a ====================================================================== Keywords : Technology : kbMASMsearch kbAudDeveloper kbMASM600 Version : MS-DOS:6.0 Solution Type : kbfix ============================================================================= THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY. Copyright Microsoft Corporation 2001.