Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Microsoft C 6.0 - interrupt http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
Interrupt
 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 general 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 general
    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. On
                error, 'cflag' field in 'outregs' is non-zero, 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

 Portability:   Applies to MS DOS only.

-------------------------------- 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);
           }



See Also: intdos() intdosx() int86()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson