int86x()                 Set Segment Registers and Execute Software Interrupt
 
 #include   <dos.h>
 
 int           int86x(intno,inregs,outregs,segregs);
 int           intno;                    Interrupt number
 union  REGS   *inregs;                  Register values going into call
 union  REGS   *outregs;                 Register values on return
 struct SREGS  *segregs;                 Segment-register values on call
 
    int86x() executes the 8086 software interrupt 'intno'; it is similar
    to int86(), but it allows you to set the DS and ES segment registers
    also. The registers are set to the values in 'inregs'; the DS and ES
    segment registers are set to the corresponding values in 'segregs'.
    On return, 'outregs' is set to the value of the registers after the
    interrupt has executed; DS is restored; and the 'cflag' field of
    'outregs' is set to the status of the system carry flag.
 
    Returns:    The value of the AX register after the system call. If
                the 'cflag' field in 'outregs' is non-zero, an error has
                occurred and '_doserrno' (defined in <stdlib.h>) is set
                to the error code.
 
      Notes:    If the DS and ES registers don't need to be set, int86()
                should be used. The values for the segment registers can
                be obtained with the segread() function or the FP_SEG
                macro.
 
                Use bdos(), intdos() and intdosx() to execute DOS system
                calls (interrupt 21h).
 
                The DS register is restored upon completion of the
                int86x() call
 
  -------------------------------- Example ---------------------------------
 
    The following statements read the boot sector (track 0, sector 1) of
    the disk in drive A: by calling BIOS interrupt 13h.
 
          #include <dos.h>     /* for int86x(), macros FP_SEG() and FP_OFF(),
                                  segread(), union REGS and struct SREGS */
          #include <stdio.h>   /* for printf() */
          #include <stdlib.h>  /* for _doserrno */
 
          char buf [1024];
 
          main()
          {
              char far * bufptr;
              union REGS inregs, outregs;
              struct SREGS segregs;
 
              segread(&segregs);           /* set the segment registers */
              bufptr = (char far *) buf;   /* need a far pointer to 'buf' */
              segregs.es = FP_SEG(bufptr); /* ...to set the address of */
              inregs.x.bx = FP_OFF(bufptr);/* ...'buf' for the BIOS */
              inregs.h.ah = 2;             /* set the BIOS function number */
              inregs.h.al = 1;             /* set # of sectors to read */
              inregs.h.ch = 0;             /* set track # of boot sector */
              inregs.h.cl = 1;             /* set sector # of boot sector */
              inregs.h.dh = 0;             /* set disk side number */
              inregs.h.dl = 0;             /* set drive number to A: */
              int86x(0x13, &inregs, &outregs, &segregs);  /* read sector */
 
              if (outregs.x.cflag)
                  printf("ERROR #%d: status = %d, # sectors read = %d\n",
                         _doserrno, outregs.h.ah, outregs.h.al);
          }

Seealso:



This page last updated on Fri Nov 30 10:48:32 MSK 2001
Copyright © 1992-2001, Vitaly Filatov, Moscow, Russia
Webmaster