FIX: MASM Local Variables Unavailable in CodeView 4.0x

Last reviewed: September 16, 1997
Article ID: Q100426
4.00 4.01 MS-DOS kbtool kbcode kbbuglist kbfixlist

The information in this article applies to:

  • Microsoft CodeView for MS-DOS, versions 4.0 and 4.01

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.

  • Reset memory before running CodeView. On a machine that runs only MS-DOS, you must reboot your computer. On a machine that runs an MS-DOS session in Microsoft Windows, close the MS-DOS window and open another to reset memory.

    -or-

  • Open a memory window to display the storage location of the local variable. There are three methods available to determine the address of the variable, as follows:

        - Calculate an offset from the base pointer (BP+<offset>) as
          shown in the Locals window.
    

        - Add a watch on the address of the variable (&<variable>).
    

        - Type the command "? &<variable>" (without quotation marks) in
          the Command window to display the address.
    

    Enter the address in the address field of a Memory window to display the desired location.

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 reference words: 4.00
KBCategory: kbtool kbcode kbbuglist kbfixlist
KBSubcategory: CvwIss
Keywords : kb16bitonly
Version : 4.00 4.01
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.

Last reviewed: September 16, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.