DOCUMENT:Q48744 22-JUL-2001 [visualc] TITLE :int86x() and int86() Trap for Interrupts 25h, 26h PRODUCT :Microsoft C Compiler PROD/VER:winnt: OPER/SYS: KEYWORDS:kb16bitonly ====================================================================== ------------------------------------------------------------------------------- The information in this article applies to: - The C Run-Time (CRT), included with: - Microsoft C for MS-DOS, versions 5.1, 6.0, 6.0a, 6.0ax - Microsoft C/C++ for MS-DOS, version 7.0 - Microsoft Visual C++, versions 1.0, 1.5 ------------------------------------------------------------------------------- SUMMARY ======= MS-DOS interrupts 25h (absolute disk read) and 26h (absolute disk write) require special handling when being used because they leave the CPU flags on the stack upon termination. Functions int86x() and int86() work reliably with these interrupts. The int86() functions trap for these two interrupts, and take care of the stack appropriately. Use one of the int86() functions to make these calls as you would any other MS-DOS interrupt call. Extra precautions aren't needed with these interrupts. MORE INFORMATION ================ The following example demonstrates the straight-forwardness of the function call: Sample Code ----------- /* Compile options needed: none */ #include #include #include /***** WARNING!!!!! ******/ /* If you change the following line so that DRIVE_A is assigned a 2 or above, you could destroy data on your hard drive. This test program segment was written to read and write from the floppy disk A: */ #define DRIVE_A 0 /* 0=A, 1=B, 2=C, etc. */ #define ONE_SECTOR 1 #define ABS_WRITE 38 /* Decimal value of int call */ #define ABS_READ 37 /* Decimal value of int call */ unsigned int far *out; /* Pointer to Data to be output */ unsigned int far *input; /* Pointer to Data Transfer Area */ unsigned int output; /* Data to be output */ union REGS inregs, outregs; struct SREGS segregs; void main(void) { out = &output; input = (unsigned int far *) malloc(1024 * sizeof(unsigned int)); *out = 11; inregs.h.al = DRIVE_A; /* Write to drive A */ inregs.x.cx = ONE_SECTOR; /* Write one sector only */ inregs.x.dx = 3; /* Logical sector 3 */ segregs.ds = FP_SEG(out); /* Get Seg address of output */ inregs.x.bx = FP_OFF(out); /* Get Offset of output */ outregs.x.ax = 0; /* No error */ int86x (ABS_WRITE, &inregs, &outregs, &segregs); inregs.h.al = DRIVE_A; /* Read to drive A */ inregs.x.cx = ONE_SECTOR; /* Read one sector only */ inregs.x.dx = 3; /* Logical sector 3 */ segregs.ds = FP_SEG(input); /* Get Seg address of buffer */ inregs.x.bx = FP_OFF(input); /* Get Offset of buffer */ outregs.x.ax = 0; /* No error */ int86x (ABS_READ, &inregs, &outregs, &segregs); printf ("%u was read from drive A: \n", *input); } Additional query words: kbinf 1.00 1.50 5.00 5.10 6.00 6.00a 6.00ax 7.00 ====================================================================== Keywords : kb16bitonly Technology : kbVCsearch kbAudDeveloper kbCRT Version : winnt: ============================================================================= THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY. Copyright Microsoft Corporation 2001.