ID Number: Q74744
6.00 | 6.00
MS-DOS | OS/2
buglist6.00 fixlist6.00a
Summary:
SYMPTOMS
The Microsoft Macro Assembler (MASM) version 6.0 may generate
incorrect code when more than one label is used to calculate a
relative offset.
RESOLUTION
To work around this problem, offsets should be calculated using
another method. The sample program does generate the correct code
when structures are used to calculate the offsets.
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 sample program below illustrates this problem. The code actually
generated by the assembler is included as comments within the source.
As you can see from generated code, the address to place the value is
calculated correctly in all cases. However, if location arithmetic is
used, the assembler changes the first byte from hex 30 to hex 00. The
result is independent of the format used for the constant ('0' behaves
the same as 30h).
Sample Code
-----------
; Assemble options needed: none
;
; This program should display "Six Zeros -> 000000" on the screen.
; Instead, it displays "Six Zeros -> 0 0 ".
;
; To work around this problem, uncomment the code involving
; structures and remove the code using location arithmetic.
.MODEL small
.STACK
.DATA
VOLCANOS STRUCT
RAINER BYTE "Six"
BAKER BYTE "Zeros ->"
ADAMS BYTE 6 DUP(01H)
STHELENS BYTE '$'
VOLCANOS ENDS
MOUNTAINS LABEL BYTE
MACKENZIE BYTE "Six "
FUJI BYTE "Zeros -> "
GODWIN_AUSTEN BYTE 6 DUP(01H)
KILIMANJARO BYTE '$'
.CODE
main:
mov ax, @DATA
mov ds, ax
mov di, OFFSET MOUNTAINS
;Offsets calculated using structures
; mov BYTE PTR VOLCANOS.ADAMS+2 [DI], '0'
; mov WORD PTR VOLCANOS.ADAMS [DI], '00'
;
;3750:0008 C6450F30 MOV Byte Ptr [DI+0F],30
;3750:000C C7450D3030 MOV Word Ptr [DI+0D],3030
;
; mov BYTE PTR VOLCANOS.ADAMS+5 [DI], 30h
; mov WORD PTR VOLCANOS.ADAMS+3 [DI], 3030h
;
;3750:0011 C6451230 MOV Byte Ptr [DI+12],30
;3750:0015 C745103030 MOV Word Ptr [DI+10],3030
; Offsets calculated using location arithmetic
mov BYTE PTR [GODWIN_AUSTEN+2-MOUNTAINS+DI], '0'
mov WORD PTR [GODWIN_AUSTEN-MOUNTAINS+DI], '00'
;3750:001A C6450F00 MOV Byte Ptr [DI+0F],00
;3750:001E C7450D0030 MOV Word Ptr [DI+0D],3000
mov BYTE PTR [GODWIN_AUSTEN+5-MOUNTAINS+DI], 30H
mov WORD PTR [GODWIN_AUSTEN+3-MOUNTAINS+DI], 3030H
;3750:0023 C6451200 MOV Byte Ptr [DI+12],00
;3750:0027 C745100030 MOV Word Ptr [DI+10],3000
; Output
mov dx, OFFSET MOUNTAINS ; Load DX with offset of
; MOUNTAINS (segment already in DS)
mov ax, 09h
int 21h ; Display String to stdout
mov ax, 4C00h ; Exit functions with 0 in AL
int 21h ; Exit Program with Return Code
END main