Microsoft KB Archive/82287

= FIX: MASM 6.0 Does Not Align on Page Boundary =

Article ID: 82287

Article Last Modified on 10/20/2003

-

APPLIES TO


 * Microsoft Macro Assembler 6.0 Standard Edition
 * Microsoft Macro Assembler 6.0a
 * Microsoft Macro Assembler 6.0b

-



This article was previously published under Q82287



SYMPTOMS
When using the Microsoft Macro Assembler (MASM), the ALIGN directive does not work properly when attempting to place data or code on a page (256 byte) boundary. If aligning inside of a code segment, the &quot;ALIGN 256&quot; directive has no effect on the placement of subsequent instructions; it may insert 256 bytes somewhere else later in that segment. When aligning inside of a data segment, the data to be aligned is placed 1 byte past the page boundary.



RESOLUTION
To work around this problem, follow the steps below:

  Edit your source to use an &quot;ALIGN 128&quot; where you previously used &quot;ALIGN 256&quot;. For example, .                   .      .                    .      XOR   AL,AL          XOR   AL,AL ALIGN 256    --->  ALIGN 128 MOV  CX,5           MOV   CX,5 .                   .      .                    .                         Assemble your source with the options &quot;/Fl /c&quot;. This will generate a listing file with the same base name of your source file and a .LST extension.  Viewing the .LST file, locate the line of code you want to align. The value to the left of your source code represents the offset of that item in the relative segment. This value will be a multiple of 128 (80h). There is a possibility that this value will fall on a page frame (100h). If this is the case then the code is aligned on a 256-byte boundary and you are done.      Offset Machine Code  Source Code --  ---      .      .      0000  32 C0          XOR   AL,AL ALIGN 128 0080 B9 0005        MOV   CX,5    **Not Aligned on page** .     .      .      .      0000  32 C0          XOR   AL,AL ALIGN 128 0100 B9 0005        MOV   CX,5    **Aligned on page** .     .                          If the offset value is not a multiple of 256, go back to your source file and add the line &quot;DB 128 DUP(?)&quot; beneath the &quot;ALIGN 128&quot; line. This will add the bytes necessary to align your code to a page frame. Reassemble with &quot;/Fl /c&quot; and view the .LST file to verify. .                   .      .                    .      XOR   AL,AL          XOR   AL,AL ALIGN 128    --->   ALIGN 128 DB   128 DUP(?) MOV  CX,5           MOV   CX,5 .                   .      .                    . 



STATUS
Microsoft has confirmed this to be a problem in MASM versions 6.0, 6.0a, and 6.0b. This problem was corrected in MASM for MS-DOS version 6.1.



MORE INFORMATION
The following sample code can be used to demonstrate the problem.

Sample Code
; Assemble options needed: none

_TEST SEGMENT PAGE PUBLIC 'CODE' start: xor al, al ALIGN 256 xor al, al   mov ax,4C00h int 21h _TEST ENDS END start

Additional query words: 6.00 6.00a 6.00b buglist6.00 buglist6.00a buglist6.00b fixlist6.10

Keywords: kbfix KB82287

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.