delorie.com/djgpp/doc/libc/libc_486.html   search  
libc.a reference

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

int86

Syntax

 
#include <dos.h>

int int86(int ivec, union REGS *in, union REGS *out);

Description

The union REGS is defined by <dos.h> as follows:

 
struct DWORDREGS {
  unsigned long edi;
  unsigned long esi;
  unsigned long ebp;
  unsigned long cflag;
  unsigned long ebx;
  unsigned long edx;
  unsigned long ecx;
  unsigned long eax;
  unsigned short eflags;
};

struct DWORDREGS_W {
  unsigned long di;
  unsigned long si;
  unsigned long bp;
  unsigned long cflag;
  unsigned long bx;
  unsigned long dx;
  unsigned long cx;
  unsigned long ax;
  unsigned short flags;
};

struct WORDREGS {
  unsigned short di, _upper_di;
  unsigned short si, _upper_si;
  unsigned short bp, _upper_bp;
  unsigned short cflag, _upper_cflag;
  unsigned short bx, _upper_bx;
  unsigned short dx, _upper_dx;
  unsigned short cx, _upper_cx;
  unsigned short ax, _upper_ax;
  unsigned short flags;
};

struct BYTEREGS {
  unsigned short di, _upper_di;
  unsigned short si, _upper_si;
  unsigned short bp, _upper_bp;
  unsigned long cflag;
  unsigned char bl;
  unsigned char bh;
  unsigned short _upper_bx;
  unsigned char dl;
  unsigned char dh;
  unsigned short _upper_dx;
  unsigned char cl;
  unsigned char ch;
  unsigned short _upper_cx;
  unsigned char al;
  unsigned char ah;
  unsigned short _upper_ax;
  unsigned short flags;
};

union REGS {
  struct DWORDREGS d;
#ifdef _NAIVE_DOS_REGS
  struct WORDREGS x;
#else
#ifdef _BORLAND_DOS_REGS
  struct DWORDREGS x;
#else
  struct DWORDREGS_W x;
#endif
#endif
  struct WORDREGS w;
  struct BYTEREGS h;
};

Note: The .x. branch is a problem generator. Most programs expect the .x. branch to have e.g. ".x.ax" members, and that they are 16-bit. If you know you want 32-bit values, use the .d.eax members. If you know you want 16-bit values, use the .w.ax members. The .x. members behave according to #defines, as follows:

default

If you specify no #define, the .x. branch has "ax" members and is 32-bit. This is compatible with previous versions of djgpp.

_NAIVE_DOS_REGS

This define gives you .x.ax, but they are 16-bit. This is probably what most programs ported from 16-bit dos compilers will want.

_BORLAND_DOS_REGS

This define gives you .x.eax which are 32-bit. This is compatible with Borland's 32-bit compilers.

This function simulates a software interrupt. Note that, unlike the __dpmi_int function, requests that go through int86 and similar functions are specially processed to make them suitable for invoking real-mode interrupts from protected-mode programs. For example, if a particular routine takes a pointer in BX, int86 expects you to put a (protected-mode) pointer in EBX. Therefore, int86 should have specific support for every interrupt and function you invoke this way. Currently, it supports only a subset of all available interrupts and functions:

1) All functions of any interrupt which expects only scalar arguments registers (i.e., no pointers to buffers).

2) In addition, the following functions of interrupt 21h are supported: 9, 39h, 3Ah, 3Bh, 3Ch, 3Dh, 3Fh, 40h, 41h, 43h, 47h, 56h.

When the interrupt is invoked, the CPU registers are copied from in. After the interrupt, the CPU registers are copied to out.

This function is just like int86x (see section int86x) except that suitable default values are used for the segment registers.

See also int86x, intdos, and bdos.

Return Value

The returned value of EAX.

Portability

ANSI/ISO C No
POSIX No

Example

 
union REGS r;
r.x.ax = 0x0100;
r.h.dl = 'c';
int86(0x21, &r, &r);


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

  webmaster     delorie software   privacy  
  Copyright © 2004     Updated Apr 2004