Q59374: FIX: Incorrect Code With TYPE and SI Index Register
Article: Q59374
Product(s): Microsoft Macro Assembler
Version(s): 5.1,5.1a
Operating System(s):
Keyword(s):
Last Modified: 06-MAY-2001
-------------------------------------------------------------------------------
The information in this article applies to:
- Microsoft Macro Assembler (MASM), versions 5.1, 5.1a
-------------------------------------------------------------------------------
SYMPTOMS
========
An incorrect opcode is generated by the Microsoft Macro Assembler (MASM)
versions 5.1 and 5.1a when using the TYPE operator and the SI register are used
in an indirect memory operand.
STATUS
======
Microsoft has confirmed this to be a problem in MASM versions 5.1 and 5.1a. This
problem was corrected in MASM version 6.0.
MORE INFORMATION
================
The type operator returns a number that represents the type of an expression.
This is normally the size of the variable. For example, a variable declared as
dw will cause TYPE to return the number 2.
Each of the CMP instructions in the sample below should produce the exact same
encoding. Verify with a listing file that an incorrect encoding is produced. The
opcode portion of the instruction is 3b84 in the correct examples and 3b06 in
the incorrect examples.
Sample Code
-----------
; Assemble options needed: none
.MODEL small
.STACK 4096 ; Allocate 4K stack space
.DATA
var1 dw 0
.CODE
main proc
MOV ax, @data ; Set up the DS register
MOV ds, ax ;
CMP ax,var1[si]+type var1 ; Incorrect code generated
CMP ax,var1[si]+(type var1) ; Incorrect code generated
CMP ax,var1[si]+[type var1] ; Incorrect code generated
CMP ax,type var1+var1[si] ; correct code generated
CMP ax,var1[si+type var1] ; correct code generated
CMP ax,var1[si]+2 ; correct code generated
CMP ax,var1[si+2] ; correct code generated
main ENDP
END main
Additional query words: 5.10 5.10a buglist5.10 buglist5.10a fixlist6.00
======================================================================
Keywords :
Technology : kbMASMsearch kbAudDeveloper kbMASM510 kbMASM510a
Version : :5.1,5.1a
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 1986-2002.