#include <dos.h>
#include <string.h>

unsigned short __callint( void *in, void *out );
#pragma aux __callint =             \
    "push bp"                       \
    "push es"                       \
    "push bx"                       \
    "push ds"                       \
    "push dx"                       \
    "mov ax,  [di]"                 \
    "mov bx, 2[di]"                 \
    "mov cx, 4[di]"                 \
    "mov dx, 6[di]"                 \
    "mov si, 8[di]"                 \
    "mov es,12[di]"                 \
    "mov bp,18[di]"                 \
    "mov di,10[di]"                 \
    "mov ds, bp"                    \
    "stc"                           \
    "int 0x21"                      \
    "push ds"                       \
    "push di"                       \
    "mov bp, sp"                    \
    "mov di, 4[bp]"                 \
    "mov ds, 6[bp]"                 \
    "mov   [di], ax"                \
    "pushf"                         \
    "pop ax" /* flags */            \
    "mov 20[di], ax"                \
    "mov  2[di], bx"                \
    "mov  4[di], cx"                \
    "mov  6[di], dx"                \
    "mov  8[di], si"                \
    "pop 10[di]"                    \
    "pop ax"                        \
    "pop bx"                        \
    "pop bx"                        \
    "pop bx"                        \
    "mov 18[di], ax"                \
    "mov 12[di], es"                \
    "sbb ax, ax" /* ax=<0 if cf */  \
    "pop es"                        \
    "pop bp"                        \
    "pop es"                        \
    parm caller     [di] [dx] \
    value           [ax] \
    modify          [bx cx dx si di];

int _callint( union INTR *regs )
{
    register short retval;

    retval = __callint( regs, regs );
    if( regs->x.flags & 1 ) regs->x.cflag = 1;

    return( regs->x.ax );
}

