Microsoft KB Archive/62212

COBOL Can Call an Interrupt to Position the Cursor

PSS ID Number: Q62212 Article last modified on 05-25-1990

3.00 3.00a MS-DOS

Summary: Microsoft COBOL versions 3.00 and 3.00a can call an interrupt to position the cursor. These versions of COBOL can call interrupts via the special subprogram X“84”. The interrupt in question is 10H, function 02H. It requires the following registers for input: AH (upper byte of AX) = 02H BH (upper byte of BX) = page DL (lower byte of DX) = row (y coordinate) DH (upper byte of DX) = column (x coordinate) AH holds the function number, BH the display page, DL the row, and DH the column. A separate cursor is maintained for each display page and each can be set independently with this function regardless of which page is currently visible. The maximum values for DL and DH depend on the current display mode, but the upper-left corner of the screen is always (0,0). This information applies to Microsoft COBOL Compiler versions 3.00 and 3.00a for MS-DOS.

More Information: For more information about calling interrupts from COBOL 3.00 and 3.00a, see Pages 8-4 and 8-5 of the “Microsoft COBOL Compiler 3.0: Operating Guide” included with the product. For more information about interrupt 10H, function 02H, see Pages 501 and 502 of “Advanced MS-DOS Programming, Second Edition,” by Ray Duncan (Microsoft Press, 1988). The following sample program displays messages in different parts of the screen, using the above interrupt to position the cursor maintained on page 0. After a key is pressed, the program terminates.

Code Example
$SET ANS85 DATA DIVISION. WORKING-STORAGE SECTION. 01 AX. *  Function 02H 05 A-H      PIC 99   COMP-X VALUE 2. 05 A-L      PIC 99   COMP-X. 01 BX. *  Display page 0 05 B-H      PIC 99   COMP-X VALUE 0. 05 B-L      PIC 99   COMP-X. 01 CX. 05 C-H      PIC 99   COMP-X. 05 C-L      PIC 99   COMP-X. 01 DX. *  Initialize to upper-left corner 05 D-H      PIC 99   COMP-X VALUE 0. 05 D-L      PIC 99   COMP-X VALUE 0. * Initialize to interrupt 10H 01 Interrupt   PIC X           VALUE X&quot;10&quot;. * Load actual registers with passed parameters 01 Flag        PIC X           VALUE X&quot;FF&quot;. * Flag whether the user pressed a key, initialize to 0 01 KeyWaiting  PIC 99   COMP-X VALUE 0. PROCEDURE DIVISION. *   Clear the screen CALL X&quot;E4&quot;. *   Call the interrupt to position the cursor CALL X&quot;84&quot; USING Interrupt, Flag, AX, BX, CX, DX. DISPLAY &quot;UPPER-LEFT CORNER&quot; WITH NO ADVANCING. *   Set to bottom-left corner MOVE 24 TO D-H. CALL X&quot;84&quot; USING Interrupt, Flag, AX, BX, CX, DX. DISPLAY &quot;BOTTOM-LEFT CORNER&quot; WITH NO ADVANCING. MOVE 12 TO D-H. MOVE 35 TO D-L. CALL X&quot;84&quot; USING Interrupt, Flag, AX, BX, CX, DX. DISPLAY &quot;CENTERED&quot; WITH NO ADVANCING. *   When KeyWaiting NOT = 0, the user pressed a key PERFORM UNTIL KeyWaiting NOT = 0 *      Check if key is in the buffer CALL X&quot;D9&quot; USING KeyWaiting END-PERFORM. STOP RUN. Copyright Microsoft Corporation 1990.