Name
intdosx - Invokes a DOS system call.
Syntax
#include <dos.h>
int intdosx(inregs, outregs, segregs)
union REGS *inregs;
union REGS *outregs;
struct SREGS *segregs;
Description
The intdosx function invokes the DOS system call specified
by register values defined in inregs and returns the effect
of the system call in outregs. The REGS and SREGS unions are
described in the reference page for int86x. Unlike the
intdos function, intdosx accepts segment-register values in
segregs, letting programs that use long-model data segments
or far pointers specify which segment or pointer should be
used during the system call. The inregs and outregs
arguments are unions of type REGS. The segregs argument is a
structure of type SREGS. These types are defined in the
include file dos.h.
To invoke a system call, intdosx executes an INT 21H
instruction. Before executing the instruction, the function
copies the contents of inregs and segregs to the
corresponding registers. Only the DS and ES register values
in segregs are used. After the INT instruction returns,
intdosx copies the current register values to outregs and
restores DS. It also copies the status of the system carry
flag to the cflag field in outregs. If this field is
nonzero, the flag was set by the system call and indicates
an error condition.
The intdosx function is used to invoke DOS system calls that
take an argument in the ES register, or that take a DS
register value different from the default data segment.
Return Value
The intdosx function returns the value of the AX register
after the system call is completed. If the cflag field in
outregs is nonzero, an error has occurred; in such cases,
_doserrno is also set to the corresponding error code.
See Also
bdos(DOS), FP_SEG(DOS), intdos(DOS), segread(DOS)
Notes
Segment values for the segregs argument can be obtained by
using either the segread function or the FP_SEG macro.
Example
#include <dos.h> #include <stdio.h> #include <direct.h>
union REGS inregs, outregs; struct SREGS segregs; char
buffer[51], buf2[51]; /* Buffers for directory names */
char far *dir = "\\newdir"; /* Directory to create */ char
*result1, result2;
main() {
result1 = getcwd(buffer,50);
printf("Current working directory is =%s\n",
buffer);
mkdir(dir);
inregs.h.ah = 0x3B; /* Change directory
function */
inregs.x.dx = FP_OFF(dir); /* File name offset */
segregs.ds = FP_SEG(dir); /* File name segment */
intdosx(&inregs,&outregs,&segregs);
result1 = getcwd(buf2,50);
printf("Changed working directory is =%s\n", buf2 );
result2 = chdir(buffer); /* Change back */
result1 = getcwd(buf2, 50);
printf("Changed to original working directory
=%s\n", buf2); }
First, this program gets and displays the name of the
current directory and creates a directory named newdir on
the current drive. Then it invokes DOS system call 3BH
(change directory) using intdosx to change the current
working directory to newdir. Finally, it restores the
original directory as the current working directory.
(printed 6/18/89)