home *** CD-ROM | disk | FTP | other *** search
- /* intr.c - title
- Description
- What it does.
- Limitations.
- How to use it (compile instructions)
-
- Revison History
- date name change
- 01/13/92 C. J. Kent original
- */
-
- // IMPORT CONTROL MACROS
-
- // IMPORTS
- # include "regpack.h"
-
-
- // LOCAL MACROS
-
-
-
- // LOCAL DATA DECLARATIONS
-
-
-
- // LOCAL DATA
-
-
-
- // EXPORT DATA
-
-
-
- // LOCAL FUNCTION PROTOTYPES
-
-
-
- // FUNCTIONS
-
- int _far intr( int IntNum, struct REGPACK _far * pRegs )
- { unsigned char Code[10];
- _asm
- { push ds
- mov Code[4],0cdh ; an 'int' opcode
- mov ax,IntNum
- mov Code[5], al ; the interrupt number
- cmp al,25h
- je abnorm
- cmp al,26h
- je abnorm
- mov Code[6],0cbh ; a 'retf' opcode
- jmp short continue
-
- abnorm: mov Code[8],0cbh ; a 'retf' opcode
- mov Code[7],044h ; a 'inc sp' opcode for flags on stack
- mov Code[6],044h ; a 'inc sp' opcode for flags on stack
-
- continue:
- mov word ptr Code[2],ss ; seg part of far call addr
- lea ax,word ptr Code[4] ; offset part of far call addr
- mov word ptr Code[0],ax ; we're going to jump onto the stack
-
- lds di,pRegs ; get struct REGPACK addr
-
- mov ax,[di].r_ax
- mov bx,[di].r_bx
- mov cx,[di].r_cx
- mov dx,[di].r_dx
- mov si,[di].r_si
- push [di].r_di ; save di, need it for indexing
-
- mov es,[di].r_es
- mov ds,[di].r_ds
- pop di ; restore di
- push bp
- call dword ptr Code[0] ; execute interrupt
-
- pop bp ; bp points to old bp
- push di ; save di
- push ds
-
- lds di,pRegs ; get struct REGPACK addr
-
- mov [di].r_es,es
- pop [di].r_ds
-
- mov [di].r_ax,ax
- mov [di].r_bx,bx
- mov [di].r_cx,cx
- mov [di].r_dx,dx
- mov [di].r_si,si
- pop [di].r_di ; restore di
- jc carry
-
- xor si,si
- jmp short toend
-
- carry: mov si,1
-
- toend: mov [di].r_flags,si ; set carry/no carry flag
- pop ds
- }
- return pRegs->r_ax;
- }
-
- // intr.c
-
-