FIX: MASM Generates Incorrect Code for Indirect AddressingLast reviewed: September 16, 1997Article ID: Q99239 |
6.00 6.00a 6.00b 6.10 6.10a | 6.00 6.00a 6.00b
MS-DOS | OS/2kbtool kbfixlist kbbuglist The information in this article applies to:
SYMPTOMSMicrosoft Macro Assembler (MASM) generates incorrect code when an indirect addressing using 32-bit registers uses a label located in a 16-bit segment as the first argument in the list that forms the indirect address.
CAUSEWhen the first operand in the list of operands that forms the indirect address is a label located in a 16-bit segment, MASM interprets the indirect address as a 16-bit reference to the segment.
RESOLUTIONTo work around this problem, perform one of the following two steps:
STATUSMicrosoft has confirmed this to be a problem in MASM versions 6.0, 6.0a, 6.0b, 6.1, and 6.1a. This problem was corrected in MASM for MS-DOS version 6.11.
MORE INFORMATIONThe evaluation order precedence of the operands in indirect addressing is left to right inside the brackets, followed by the label outside the brackets, if one is present. MASM generates incorrect code when the code uses any combination of 32-bit registers and a label to calculate an address when the label is located in a 16-bit segment and the label is listed as the first operand enclosed in brackets. To work around this problem, make sure that the first operand MASM processes is a 32-bit register; then MASM calculates the address properly. You can do this by moving a 32-bit register to the beginning of the list in the brackets or moving the label outside the brackets. The code example below demonstrates both of these techniques.
MORE INFORMATION
Sample Code; Assemble options needed: /Zi ; Use CodeView to see the instructions generated by the assembler .386 sseg SEGMENT STACK USE16 'STACK' BYTE 4096 dup (?)sseg ENDS cseg SEGMENT PUBLIC USE16 'CODE' ASSUME cs:cseg, ds:cseg, es:cseg filler WORD 0 alabel DWORD 2 dup (?) start: mov eax, dword ptr [alabel+esi] ; assembles incorrectly ; MOV EDI,DWORD PTR [BX+SI+0002] mov eax, dword ptr [esi+alabel] ; assembles correctly ; MOV EAX,DWORD PTR [ESI+00000002] mov eax, dword ptr alabel[esi] ; assembles correctly ; MOV EAX,DWORD PTR [ESI+00000002] mov ax, 4C00h int 21hcseg ENDS END start
|
Additional reference words: 6.00 6.00a 6.00b 6.10 6.10a buglist6.00a
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |