FIX: MASM Local Variables Unavailable in CodeView 4.0x

Q100426


The information in this article applies to:


SYMPTOMS

An attempt to display the local variables of an assembly language module created in Microsoft Macro Assembler (MASM) version 6.1 may fail. MASM displays one of the following messages when you attempt to display a local variable either in the command window or in the locals window:

CAN0030: Error: expression cannot be evaluated
-or-
CXX0030: Error: expression cannot be evaluated
The actual error message depends on the expression evaluator (C or C++) CodeView is using at the time.


CAUSE

Apparently, this problem is caused by CodeView incorrectly initializing memory. It occurs only after certain programs run, particularly those that use extended memory. Because MASM 6.1 is a DOS-extended application, the error occurs when CodeView runs after the assembler.


RESOLUTION

At present, there are two methods to work around this problem.


STATUS

Microsoft has confirmed this to be a problem in CodeView versions 4.0 and 4.01 for MS-DOS. This problem was corrected in CodeView version 4.1 distributed with Microsoft Visual C++ version 1.0 for Windows.


MORE INFORMATION

If you have Visual C++, use LINK version 5.5 and CVPACK version 4.1 from the Visual C++ package with CodeView version 4.1 to debug applications developed in MASM version 6.1.

You can use the Watch window to view global variables without any difficulties. The following code example illustrates the problem with local variables and allows you to experiment with the Memory window to watch the local variable. If you use CodeView to debug this application immediately after you start your computer or immediately after opening an MS-DOS window in Windows, the error does not occur. If you run CodeView after running MASM 6.1, it will not evaluate the local variable.

Sample Code


; Assembly options needed: /Zi
 
.model small
.stack
.data
a WORD ?
 
.code
mainproc PROC NEAR
 
        .STARTUP
        mov ax,30h
        mov a, ax
        mov ax, 0
        call myproc
        mov ax, a
        .EXIT
 
mainproc ENDP
 
myproc PROC NEAR
LOCAL loc:WORD
 
        mov ax, 60h
        mov loc, ax
        mov dx, loc
        mov a, dx
        ret
 
myproc ENDP
 
END 

Additional query words: 4.00

Keywords : kb16bitonly
Issue type :
Technology : kbAudDeveloper kbCodeView kbZNotKeyword3


Last Reviewed: June 26, 2001
© 2001 Microsoft Corporation. All rights reserved. Terms of Use.