FIX: Incorrect Code With TYPE and SI Index Register

ID: Q59374


The information in this article applies to:
  • Microsoft Macro Assembler for MS-DOS, versions 5.1, 5.1a
  • Microsoft Macro Assembler for OS/2, 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 :
Version : :5.1,5.1a
Platform :
Issue type :


Last Reviewed: January 7, 2000
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.