INT86X(DOS) XENIX System V INT86X(DOS)
Name
int86x - Executes an interrupt.
Syntax
#include <dos.h>
int int86x (intno, inregs, outregs, segregs);
int intno;
union REGS *inregs;
union REGS *outregs;
struct SREGS *segregs;
Description
The int86x function executes the 8086 software interrupt
specified by the interrupt number intno. Unlike the int86
function, int86x 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.
Before executing the specified interrupt, int86x copies the
contents of inregs and segregs to the corresponding
registers. Only the DS and ES register values in segregs
are used. After the interrupt returns, the function 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. 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.
int86x is intended to be used to directly invoke DOS
interrupts that take an argument in the ES register, or take
a DS register value that is different than the default data
segment.
Return Value
The return value is the value in the AX register after the
interrupt returns. If the flag field in outregs is nonzero,
an error has occurred and the doserrno variable is also set
to the corresponding error code.
See Also
bdos(DOS), intdos(DOS), intdosx(DOS), int86(DOS), seg-
read(DOS), FP_SEG(DOS)
Page 1 (printed 8/7/87)
INT86X(DOS) XENIX System V INT86X(DOS)
Example
#include <signal.h> #include <dos.h> #include <stdio.h>
#include <process.h>
/*
* Use int86x routine to generate an interrupt 0x21 (system
* call), which invokes the DOS 'Change Attributes' system
* call. The int86x routine is used because the filename to
* be referenced may be in a segment other than the default
* data segment (it is referenced by a far pointer), so the
* DS register must be explicitly set via the SREGS struct.
*/
#define SYSCALL 0x21 /* INT 21H invokes system
calls */ #define
CHANGE_ATTR 0x43 /* system call 43H - change
attributes */
char far *filename; /* filename in 'far' data
segment */
union REGS inregs, outregs; struct SREGS segregs; int
result; . . . inregs.h.ah = CHANGE_ATTR;
/* AH is system call
number */ inregs.h.al =
0; /* AL is function (get
attributes) */
inregs.x.dx = FP_OFF(filename); /* DS:DX points to file
name */ segregs.ds =
FP_SEG(filename); result = int86x (SYSCALL, &inregs,
&outregs, &segregs); if (outregs.x.cflag) {
printf ("can't get attributes of file; error number
%d\n", result);
exit (1);
} else {
printf ("Attribs = %#x\n", outregs.x.cx);
}
Notes
Segment values for the segregs argument can be obtained by
using either the segread function or the FP_SEG macro.
This call must be compiled with the -dos flag.
Page 2 (printed 8/7/87)