Microsoft KB Archive/93159

From BetaArchive Wiki
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

PSS ID Number: 93159

Article Last Modified on 1/8/2003



The information in this article applies to:

  • Microsoft Visual Basic for MS-DOS 1.0



This article was previously published under Q93159

SYMPTOMS

When you are using overlays and working with a multiple module program, you may have trouble tracking down the location of an error in your code.

CAUSE

This trouble may be caused by the way the LINK linker overlays modules. All the code in an overlay is in the same segment and the offset is from the beginning of the segment.

The way code in an overlay is stored was changed in Visual Basic version 1.0 for MS-DOS. This behavior did not occur in Microsoft Basic Professional Development System (PDS) version 7.1 for MS-DOS.

STATUS

This behavior is by design.

MORE INFORMATION

Steps to Reproduce Behavior

  1. Start VBDOS.EXE.
  2. In the default code window, include a CALL statement to a procedure named "Test", similar to the lines of code below (Main.BAS).

       DECLARE SUB test ()
       REM This is the main module.
       CALL Test
                            
  3. Choose New Module... from the File Menu (Sup1.BAS). Add the following line:

       REM This is the first support module.
                            
  4. Choose New Module... from the File Menu (Sup2.BAS). Add the following line:

       REM This is the second support module.
                            
  5. Choose New Module... from the File Menu (Sup3.BAS). Add the following code:

       REM This is the third support module.
       SUB test ()
          x = 0
          Print 1 / x
       END SUB
                            
  6. Compile each .BAS module mentioned above. For example:

    BC Main.bas;
    BC Sup1.bas;
    BC Sup2.bas;
    BC Sup3.bas;

  7. Use LINK to link the four modules with overlays. For example:

    LINK Main.obj+(Sup1.obj+Sup2.obj+Sup3.obj);

  8. Once the MAIN.EXE program is created, run it. The following error is returned:

    Division by zero in module SUP3 at address 9FF1:00D1

  9. This address location is incorrect, which makes it difficult to track down the actual location of the error in overlaid modules.

Listed below is a portion of the README.TXT file that explains this limitation in more detail:

1.9 Overlays

Calculating the Offset of Errors

If you are using the assembly listing generated when compiling with /A to debug an overlaid program, you must subtract the start address of the overlaid module from the offset in the error message to get the correct code offset. For example:

Error Message:

Division by zero in line 0 of WILMA     as address 9FE9:0129

Excerpt of .MAP File Generated by LINK:

Start   Stop    Length Name                Class
. . .
Overlay 1H
00000H  00053H  00054H  FRED_CODE          BC_CODE
00060H  000B3H  00054H  BARNEY_CODE        BC_CODE
000C0H  00154H  00095H  WILMA_CODE         BC_CODE
Overlay 2H
. . .
                

To calculate the actual error address, subtract the start address of the module WILMA (000C0H) from the offset given in the error message (0129):

129H - C0H = 69H

The offset of the error is 0069 in the compiler assembly listing.


Additional query words: VBmsdos 1.00 7.10

Keywords: kbprb KB93159
Technology: kbAudDeveloper kbVB100DOS kbVBSearch kbZNotKeyword3