The information in this article applies to:
SUMMARY
The information in this article is also included in the Help file
provided with the Standard and Professional Editions of Microsoft
Visual Basic for MS-DOS, version 1.0.
MORE INFORMATION
CALL INTERRUPT is a complicated statement that allows programmers to
have access to low-level MS-DOS and ROM BIOS information and control
from Basic. Effective use of the complex CALL INTERRUPT interface
requires an understanding of the Basic programming environment,
the Basic language, and lower-level MS-DOS and ROM BIOS functions. This
article explains many of these necessary features, including
the following:
Libraries and Quick LibrariesThe object code for the Interrupt routines is located in the VBDOS.LIB, VBDOS.QLB, QB.LIB, QB.QLB , QBX.LIB, and QBX.QLB files, which are supplied with Visual Basic for MS-DOS, version 1.0; and QuickBasic for MS-DOS, versions 4.0, 4.0b, and 4.5; and Basic Compiler for MS-DOS, versions 6.0 and 6.0b.The difference between LINK libraries (LIB files) and Quick libraries (QLB files) is that Quick libraries serve as executable code modules for use within the VBDOS or QuickBasic environment, and LINK libraries are used at link time to produce executable programs. To load a Quick library for use with the VBDOS or QuickBasic environment, you must start VBDOS or QuickBasic with the /L option (that is, VBDOS /L VBDOS.QLB or QB /L QB.QLB or QBX /L QBX.QLB). This will allow you to make CALLs to the routines in that Quick library. When you open the Run menu and choose Make EXE File, your program will automatically be linked with the library (LIB file) of the same name as your Quick library (in this case, VBDOS.LIB, QB.LIB or QBX.LIB). User-Defined TypesTo use the CALL INTERRUPT statement, you must first create a user- defined TYPE to contain the registers for the Interrupt. The TYPEs defined in the INCLUDE file (VBDOS.BI, QB.BI, or QBX.BI) that come with Visual Basic for MS-DOS, version 1.0, QuickBasic for MS-DOS, versions 4.0, 4.0b, and 4.50, and Basic PDS for MS-DOS, versions 7.0 and 7.1 are as follows:
Note: RegTypeX is used with the CALL INTERRUPTX statement,
which allows you to specify the DS and ES registers. For more
information on CALL INTERRUPTX, please refer to the section
"Differences Between CALL INTERRUPT and CALL INTERRUPTX" on
page 4 of this application note.
INCLUDE FilesTo simplify the TYPE definition for Interrupts, the INCLUDE file VBDOS.BI, QB.BI, or QBX.BI is shipped with Visual Basic for MS-DOS, version 1.0, with QuickBasic for MS-DOS, versions 4.0, 4.0, and 4.5, with Basic Compiler for MS-DOS, versions 6.0 and 6.0b and Basic PDS for MS-DOS, versions 7.0 and 7.1. VBDOS.BI, QB.BI, and QBX.BI have the TYPE definitions (see page 3 of this application note for TYPE example) and SUB DECLARations needed for Interrupts. To use this file, place the metacommand $INCLUDE at the beginning of your code. The syntax of this statement is as follows:
Please note the following:
CALL INTERRUPT Input and OutputBesides the Interrupt number, there are two other parameters for the CALL INTERRUPT statement: the input registers and the output registers. Before you use these registers, you must dimension two variables AS the RegType defined earlier, as follows:
For most Interrupts, you need to pass some information (function
number, function parameters) in one or more of the registers. This
assignment is done into individual elements of the user-defined TYPE
inregs, such as the following:
Note that the above assignment uses hexadecimal values -- denoted by
the "&H"-- instead of decimal values. Most references for Interrupts
use hexadecimal numbers rather than decimal numbers because the high
(1A) and low (00) bytes are easier to distinguish in hexadecimal
notation.
For some Interrupts, it is necessary to set the high-order or low- order byte of a register. These bytes are referred to in technical literature with H and L replacing X. For example, the high and low bytes of the BX register are BH and BL, respectively. To assign the registers when given high and low bytes, concatenate the hexadecimal values. For example, if you need to assign CH the value 2B hex and assign CL the value 3D hex, you would assign CX as follows:
If you are given only 1 byte (high or low), the other byte should be
assigned 00 (two zeros). For example, you would set AH to the value 01
hex as follows:
Note: The above statement is NOT equivalent to inregs.AX=&H01.
You must specify the low-order byte or the value will be stored
as &H0001.
Once you have set the values of the input registers, you are ready to make the CALL. The CALL INTERRUPT syntax is as follows:
If an Interrupt returns any values, those values will be passed back
in the outregs variable. As with inregs, values will often be passed
in the high or low bytes of a register. The routine BreakWord() in the
"Example CALL INTERRUPT" section below breaks a register into the 2-
byte values.
With many Interrupts, you need to check only a single bit (or a few bits) of any register. This is done using the bitwise operators AND, OR, XOR, and NOT. For example, the following statement will check to see if the third bit of AX is set:
Example of CALL INTERRUPTThe following program gives an example of the CALL INTERRUPT statement and provides two utility SUB programs for processing output:
Differences Between CALL INTERRUPT and CALL INTERRUPTXThe CALL INTERRUPT and CALL INTERRUPTX statements are very similar. Either statement allows you to make calls to MS-DOS and ROM BIOS Interrupts.The only difference is that with INTERRUPTX, you can specify the DS and ES registers. (The documentation for Interrupts -- see the following reference section -- will state whether those registers are necessary. For most Interrupts, DS and ES are not needed.) References for Documentation on InterruptsThe following books are excellent resources for the different Interrupts available from MS-DOS and the ROM BIOS. Be aware that the code in these books is written in assembly language; however, the necessary input and output is given by register.
Additional query words: VBmsdos QuickBas BasicCom 1.00 2.00 2.01 3.00 4.00 4.00b 4.50 6.00 6.00b 7.00 7.10
Keywords : kbcode |
Last Reviewed: December 4, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |