Q(uick)BASIC Keyword: INTERRUPTX

Quick View

CALL INTERRUPTX

A statement that allows BASIC programs to perform DOS system calls

Worth knowing

Useful and cross-version information about the programming environments of QBasic and QuickBasic.

Syntax
  • CALL INTERRUPT (interruptnum, inregs, outregs)
  • CALL INTERRUPTX (interruptnum, inregs, outregs)
Description/Parameter(s)
interruptnum The DOS interrupt number. It is an integer between 0 and 255. See your DOS documentation for information about interrupts.
inregs The inregs variable contains the register values used when the interrupt is performed. It is declared as type RegType. The user-defined type RegType is described below.
outregs The outregs variable contains the register values after the interrupt is performed. It is declared as type RegType. The user-defined type RegType is described below.

The CALL INTERRUPT and CALL INTERRUPTX statements replace the INT86 and INT86X routines used in earlier versions of BASIC. They provide a more convenient way for BASIC programs to use DOS interrupts and services.

CALL INTERRUPT and CALL INTERRUPTX are shipped in a Quick Library (QB.QLB) and in a conventional library (QB.LIB) on the QuickBASIC Utilities 1 distribution disk. There is also a header file (QB.BI) on the disks with the necessary declarations for using these procedures.

To use CALL INTERRUPT or CALL INTERRUPTX when running a program within the QuickBASIC environment, the Quick library QB.QLB must be loaded with QuickBASIC. For information on how to do this, see the QB command line options table .

The register values before and after the interrupt are passed in variables declared as type RegType. The following statement defines the RegType user-defined type:

  • TYPE RegType
  •   AX AS INTEGER
  •   BX AS INTEGER
  •   CX AS INTEGER
  •   DX AS INTEGER
  •   BP AS INTEGER
  •   SI AS INTEGER
  •   DI AS INTEGER
  •   FLAGS AS INTEGER
  •   DS AS INTEGER
  •   ES AS INTEGER
  • END TYPE

Each element of the type corresponds to a CPU register.

INTERRUPTX uses the values in the DS and ES registers. To use the current values of these registers, set the record elements to -1.

Example

This example uses INT86OLD to open a file and place some text in it.
Note: To use CALL INTERRUPT, you must load the Quick library QB.LIB with QuickBASIC. The program also uses the QB.BI header file.

' Include header file for INT86OLD, etc. $INCLUDE:'QB.BI' DIM INARY%(7),OUTARY%(7) 'Define input and output 'arrays for INT86. ' ' Define register-array indices to ' make program easier to understand. CONST AX=0, BX=1, CX=2, DX=3, BP=4, SI=5, DI=6, FL=7 ' INARY%(AX) = &H3C00 'DOS function to create a file. INARY%(CX) = 0 'DOS attribute for created file. INARY%(DX) = SADD("FOO.TXT"+CHR$(0)) 'Pointer to file-name string 'with zero byte termination. CALL INT86OLD(&H21,INARY%(),OUTARY%()) 'Perform the creation. ' INARY%(BX) = OUTARY%(AX) 'Move created file handle for write. INARY%(AX) = &H4000 'DOS function to write to file. TEXT$ = "hello, world"+CHR$(13)+CHR$(10) 'Define text to write to file. INARY%(CX) = LEN(TEXT$) 'Get length of text string. INARY%(DX) = SADD(TEXT$) 'Get address of text string. CALL INT86OLD(&H21,INARY%(),OUTARY%()) 'Perform the write. ' INARY%(AX) = &H3E00 'DOS function to close a file. CALL INT86OLD(&H21,INARY%(),OUTARY%()) 'Perform the close.
Syntax
  • CALL INTERRUPT (interruptnum%, inregs, outregs)
  • CALL INTERRUPTX (interruptnum%, inregs, outregs)
Description/Parameter(s)

Usage Notes

  • The INTERRUPT and INTERRUPTX routines replace the INT86 and INT86X routines used in earlier versions of BASIC. They provide a more convenient way for BASIC programs to use DOS interrupts and services.
  • To use INTERRUPT or INTERRUPTX in the QBX environment, use the QBX.QLB Quick library. To use INTERRUPT or INTERRUPTX outside the QBX environment, link your program with the QBX.LIB file.
  • The QBX.BI header file contains the necessary declarations for INTERRUPT and INTERRUPTX.
  • The register values before and after the interrupt are passed in variables declared as type RegType or RegTypeX. Each element of the type corresponds to a CPU element. The following statement defines RegTypeX:

  • TYPE RegTypeX
  •   ax AS INTEGER
  •   bx AS INTEGER
  •   cx AS INTEGER
  •   dx AS INTEGER
  •   bp AS INTEGER
  •   si AS INTEGER
  •   di AS INTEGER
  •   flags AS INTEGER
  •   ds AS INTEGER
  •   es AS INTEGER
  • END TYPE

  • The following statement defines RegType (the DS and ES registers are not included):

  • TYPE RegType
  •   ax AS INTEGER
  •   bx AS INTEGER
  •   cx AS INTEGER
  •   dx AS INTEGER
  •   bp AS INTEGER
  •   si AS INTEGER
  •   di AS INTEGER
  •   flags AS INTEGER
  • END TYPE

  • INTERRUPTX uses the values in the DS and ES registers. To use the current values of these registers, set the record elements to -1.

Programming with OS/2 Protected Mode

  • The INTERRUPT and INTERRUPTX routines are not available for OS/2 protected mode. For OS/2 protected mode, replace these routines with the equivalent OS/2 function invocations.
Example

This example uses the INTERRUPT routine to determine the current drive and the amount of free space remaining on the drive.
Note: To use the INTERRUPT routine, you must load the Quick library QBX.QLB using the /L switch when you begin QBX. The QBX.BI include file must also be present.

'$INCLUDE: 'QBX.BI' 'Define registers. DIM regs AS RegType 'Get current drive info; set up input and do system call. regs.ax = &H1900 CALL Interrupt(&H21, regs, regs) 'Convert drive info to readable form. Drive$ = CHR$((regs.ax AND &HFF) + 65) + ":" 'Get disk free space; set up input values and do system call. regs.ax = &H3600 regs.dx = ASC(UCASE$(Drive$)) - 64 CALL Interrupt(&H21, regs, regs) 'Decipher the results. SectorsInCluster = regs.ax BytesInSector = regs.cx IF regs.dx >= 0 THEN ClustersInDrive = regs.dx ELSE ClustersInDrive = regs.dx + 65536 END IF IF regs.bx >= 0 THEN ClustersAvailable = regs.bx ELSE ClustersAvailable = regx.bx + 65536 END IF Freespace = ClustersAvailable * SectorsInCluster * BytesInSector 'Report results. CLS PRINT "Drive "; Drive$; " has a total of"; PRINT USING "###,###,###"; Freespace; PRINT " bytes remaining free."