Microsoft KB Archive/48744

= int86x and int86 Trap for Interrupts 25h, 26h =

Article ID: 48744

Article Last Modified on 12/12/2003

-

APPLIES TO

 The C Run-Time (CRT), when used with:  Microsoft C Professional Development System 5.1

 Microsoft C Professional Development System 6.0

 Microsoft C Professional Development System 6.0a

 Microsoft C Professional Development System 6.0a</li></ul>

 Microsoft C/C++ Professional Development System 7.0</li></ul>

 Microsoft Visual C++ 1.0 Professional Edition</li></ul>

 Microsoft Visual C++ 1.5 Professional Edition</li></ul> </li></ul>

-

<div class="notice_section">

This article was previously published under Q48744

<div class="summary_section">

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.

<div class="moreinformation_section">

MORE INFORMATION
The following example demonstrates the straight-forwardness of the function call:

Sample Code
/* Compile options needed: none


 * 1) include <stdio.h>
 * 2) include <dos.h>
 * 3) include <malloc.h>

/*****           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: 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);
 * 1) define DRIVE_A 0                   /* 0=A, 1=B, 2=C, etc. */
 * 2) define ONE_SECTOR 1
 * 3) define ABS_WRITE 38                /* Decimal value of int call */
 * 4) define ABS_READ 37                 /* Decimal value of int call */
 * 1) define ABS_READ 37                 /* Decimal value of int call */

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 (&quot;%u was read from drive A: \n&quot;, *input); }

Additional query words: kbinf 1.00 1.50 5.00 5.10 6.00 6.00a 6.00ax 7.00

Keywords: kb16bitonly KB48744

-

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

© Microsoft Corporation. All rights reserved.