Article ID: 94751 - Last Review: October 22, 2003 - Revision: 2.0

FIX: ORG Behavior Different with Span-Dependent Value

System TipThis article applies to a different operating system than the one you are using. Article content that may not be relevant to you is disabled.
This article was previously published under Q94751

On This Page

Expand all | Collapse all

SYMPTOMS

In Microsoft Macro Assembler (MASM) versions 6.0, 6.0a, and 6.0b, if the offset for an ORG directive depends on the difference between two labels (a span-dependent value), the assembled code differs from that produces by previous versions of MASM.

CAUSE

The offset for the ORG directive depends on label values that are not yet determined in the first assembly pass.

RESOLUTION

Modify the code to remove span-dependent values in an ORG directive in code assembled with MASM versions 6.0, 6.0a, or 6.0b.

STATUS

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

MORE INFORMATION

This problem usually occurs when a forward reference occurs between the two labels. The assembler adds padding bytes for the forward reference and eliminates these bytes during a subsequent assembly pass. When this occurs, the second label has a larger value during the first assembly pass than it does in subsequent passes.

The sample code below demonstrates this behavior.

Sample Code

; Assemble options needed: none

tst1 SEGMENT para public
ASSUME cs:tst1
start:
     jmp SHORT forward
forward:
     mov ax, 4C00h
     int 21h
tst1 ENDS

count = offset forward - offset start

tst2 SEGMENT para public
     DB 1
     ORG count  ; This assembles as ORG 10 in MASM versions 6.0, 6.0a, and
                ; 6.0b. It assembles as ORG 2 in MASM versions 5.1 and 6.1.
xxx  DB 1
tst2 ENDS

END start
				

APPLIES TO
  • Microsoft Macro Assembler 6.0 Standard Edition
  • Microsoft Macro Assembler 6.0a
  • Microsoft Macro Assembler 6.0b
Keywords: 
kbfix KB94751
Retired KB ArticleRetired KB Content Disclaimer
This article was written about products for which Microsoft no longer offers support. Therefore, this article is offered "as is" and will no longer be updated.