Microsoft KB Archive/63955

Subprograms X“85”, X“86”, X“94”, X“95” Unpredictable in 3.0

PSS ID Number: Q63955 Article last modified on 04-20-1993

3.00 3.00a MS-DOS

Summary: The special subprograms X“85”, X“86”, X“94”, and X“95” included with COBOL versions 3.0 and 3.0a do not work properly. The results of these functions are unpredictable. Microsoft has confirmed this to be a problem in Microsoft COBOL Compiler versions 3.0 and 3.0a for MS-DOS. This problem has been corrected in Microsoft COBOL Professional Development System version 4.0 for MS-DOS.

More Information: The special subprograms X“85” and X“94” are used for examining 1 or 2-byte memory locations (respectively) while X“86” and X“95” are used for setting 1 or 2-byte memory locations (respectively). Microsoft has found that all of these functions may fail. Therefore, until this problem is corrected, examining or setting bytes at specific memory locations must be done by a routine written in another language such as C or assembly language. The following sample program (POKEPEEK.CBL) illustrates the problem. The program attempts to set the first byte in text screen memory (for EGA and VGA) to a 65 via the subprogram X“86”. This should have the result of an “A” appearing in the upper-left corner of the screen, but this operation fails. Next, the program DISPLAYs a “B” immediately after the “A” (which never appeared) and attempts, via the subprogram X“85”, to read that memory location and display its contents. The contents should be “B”, but this operation also fails. To compile and link the program, enter the following at the DOS command prompt: cobol pokepeek; link pokepeek;

Code Example
$SET ANS85 IDENTIFICATION DIVISION. PROGRAM-ID. POKEPEEK. DATA DIVISION. WORKING-STORAGE SECTION. *  Starting segment of text screen memory (X&quot;B800&quot; hex) 01 ScreenSeg   PIC 9(5)        VALUE 47104. *  Specifies upper-left corner of screen. 01 ScreenOff   PIC 9(5)        VALUE 0. 01 Char        PIC X           VALUE &quot;A&quot;. *  Used to poll keyboard. 01 KeyHit      PIC 99   COMP-X VALUE 0. PROCEDURE DIVISION. *  Clear screen. CALL X&quot;E4&quot;. *  Attempt to put &quot;A&quot; at upper-left corner of screen. CALL X&quot;86&quot; USING ScreenSeg, ScreenOff, Char. *  Display a &quot;B&quot; one location to the right of the &quot;A&quot;, and *  attempt to read that location. DISPLAY &quot;B&quot; AT 0102. MOVE 2 TO ScreenOff. CALL X&quot;85&quot; USING ScreenSeg, ScreenOff, Char. DISPLAY Char. *  Loop until a key is hit. PERFORM UNTIL KeyHit NOT = 0 CALL X&quot;D9&quot; USING KeyHit END-PERFORM. STOP RUN. Additional reference words: 3.00 3.00a Copyright Microsoft Corporation 1993.