PRB: Error A2032 Using Indexed Addressing (119872)



The information in this article applies to:

  • Microsoft Macro Assembler (MASM) 6.0
  • Microsoft Macro Assembler (MASM) 6.0a
  • Microsoft Macro Assembler (MASM) 6.0b
  • Microsoft Macro Assembler (MASM) 6.1
  • Microsoft Macro Assembler (MASM) 6.1a
  • Microsoft Macro Assembler (MASM) 6.11

This article was previously published under Q119872

SYMPTOMS

Assembling a line of code that performs indexed addressing, such as the following:

mov dx,mylabel-2[bx]

produces the following error:
error A2032: invalid use of register
The same line of code assembles without error under MASM version 5.1.

CAUSE

The index operator '[]' is now at the very top of the MASM operator precedence list, while the binary "+" and "-" operators are in the lower half. So, for example, if the expression

2 - 3[bx]

is no longer equivalent to

2 - 3 + bx

but rather to

2 - (3 + bx) ; or 2 - 3 - bx

then it is the "- bx" that is causing the A2032 error.

RESOLUTION

Assemble using the OPTION M510 directive, the /Zm switch (which implies the OPTION M510), or use one of the following syntaxes:

mov dx, (mylabel-2)[bx]
mov dx, mylabel-2+[bx]
mov dx, mylabel[bx]-2

NOTE: The OPTION M510 is used for compilation with maximum MASM version 5.10 compatibility.

Modification Type:MinorLast Reviewed:2/11/2004
Keywords:KB119872