Microsoft KB Archive/39859

= CALL INTERRUPT 25H Doesn't Return Error Flags in the AX Reg =

Article ID: 39859

Article Last Modified on 11/21/2006

-

APPLIES TO


 * Microsoft QuickBasic 4.0
 * Microsoft QuickBASIC 4.0b
 * Microsoft QuickBasic 4.5 for MS-DOS
 * Microsoft BASIC Compiler 6.0
 * Microsoft BASIC Compiler 6.0b
 * Microsoft BASIC Professional Development System 7.0

-



This article was previously published under Q39859



SUMMARY
Microsoft QuickBasic supports the CALL INTERRUPT and CALL INTERRUPTX statements for calling MS-DOS and ROM BIOS functions/interrupts. The Interrupt Hex 25 is used to perform an absolute read from disk to a memory location. If there are any errors during this operation, the interrupt will return them in the AH register.

If the CALL INTERRUPT or CALL INTERRUPTX are used to execute Interrupt 25 Hex, the correct error code is not returned. This problem occurs because Interrupt 25H does not POP the CPU flags from the stack after its operation; these are flags the INT 25 Hex function originally PUSHed onto the stack. Therefore, when INTERRUPTX returns to QuickBasic, it returns the &quot;old&quot; flags. These do not reflect the Interrupt 25 Hex function-flag return. Most MS-DOS and ROM BIOS interrupts do POP the CPU flags from the stack upon completion and this problem does not exist. INTERRUPTX does not compensate for the extra set of flags on the stack.



MORE INFORMATION
The two workarounds for this problems are as follows:

 Call an assembly-language subroutine that performs the Interrupt 25 Hex. The correct flags will be directly accessible by the subroutine and can then be cleared with a POPF or ADD SP,2 instruction. More information on this can be found on Pages 388-389 of &quot;Advanced MS-DOS&quot; by Ray Duncan (published by Microsoft Press, 1986). OR

  Call a different but very similar interrupt as follows: Interrupt 13 Hex Function 02 Hex This is not an MS-DOS function, but rather a ROM BIOS interrupt, which (unlike Interrupt 25 Hex) does its own stack clearing. This is described below. 

In the following programs, Prog1 demonstrates the problem. No matter what Interrupt 25 Hex error occurs, the AX flags are always returned the same. Prog2 follows the second workaround described above and uses the Interrupt 13 Hex, which will return the proper error flags.

Prog1 is as follows: 'The include file below needs to be 'QBX.BI' when using 'Basic PDS 7.00 and the Quick library is QBX.QLB.

'$INCLUDE: 'QB.BI' DEFINT A-Z DIM InRegs AS RegTypeX, OutRegs AS RegTypeX DIM buffit(1 TO 8000) AS INTEGER CLS InRegs.ax = &H0 InRegs.cx = &H0 InRegs.dx = &H0 InRegs.ds = VARSEG(buffit(1)) InRegs.bx = VARPTR(buffit(1)) CALL INTERRUPTX(&H25, InRegs, OutRegs) PRINT OutRegs.ax END

Prog2 is as follows:

'The include file below needs to be 'QBX.BI' when using 'Basic PDS 7.00

'$INCLUDE: 'QB.BI' DEFINT A-Z DIM InRegs AS RegTypeX, OutRegs AS RegTypeX DIM buffit(1 TO 8000) AS INTEGER CLS InRegs.ax = &H201 InRegs.cx = &H1 InRegs.dx = &H0 InRegs.es = VARSEG(buffit(1)) InRegs.bx = VARPTR(buffit(1)) CALL INTERRUPTX(&H13, InRegs, OutRegs) PRINT OutRegs.ax END

Additional query words: QuickBas BasicCom

Keywords: KB39859

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.