Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Turbo C - <b>intdosx() set seg regs and invoke dos function, long form</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
intdosx()                Set Seg Regs and Invoke DOS Function, Long Form

 #include   <dos.h>

 int          intdosx(inregs,outregs,segregs);
 union REGS    *inregs;                  Register values going into call
 union REGS    *outregs;                 Register values on return
 struct SREGS  *segregs;                 ES and DS values going into call

    intdosx() invokes a DOS system call (Interrupt 21h) after setting the
    registers to the values in 'inregs' and setting the DS and ES
    registers to the values in 'segregs'. 'outregs' is set to the value
    of the registers after the system call.  The 'cflag' field of
    'outregs' is set to the status of the system carry flag; a non-zero
    value indicates a DOS error. 'inregs.h.ah' is the DOS function
    number.

    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:    The values for segment registers can be obtained with the
                segread() function or the FP_SEG() macro.

                If the DS and ES registers don't need to be set, intdos()
                can be used.

                DOS functions that use only the DX and AL registers and
                that don't return error information in the carry flag can
                be invoked via the bdos() function.

  -------------------------------- Example ---------------------------------

    The following statements output 'string' to the standard output.

         #include <dos.h>      /* intdosx(), macros FP_SEG() and FP_OFF(),
                                  union REGS and struct SREGS */

         union REGS inregs, outregs;
         struct SREGS segregs;
         char far *string =
                       "this string is not in the default data segment$";

         main()
         {
             inregs.h.ah = 0x9;           /* output string function number */
             inregs.x.dx = FP_OFF(string);/*DS:DX is far address of 'string*/
             segregs.ds = FP_SEG(string);
             intdosx(&inregs, &outregs, &segregs);
         }

See Also: bdos() intdos() int86x() segread() FP_SEG()

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