home *** CD-ROM | disk | FTP | other *** search
- ;INTCALL.EXE source file by Bob Montgomery, 5-1-87
- Name Intcall ;Allows QBasic to do any BIOS or DOS interrupt
- public INTCALL ;Only this label will be accessable in lib
-
- Intcall: org 0 ;Since will link later
- jmp short Begin
-
- Parameters: ;Parameters passed from QBasic go here
- Out_array dw ? ;Location of returned reg value array
- In_array dw ? ;Loaction of passed reg value array
- Int_no dw ? ;Location of passed interrupt number
-
- Inreg: ;Put register values passed from QBasic here
- Inax dw ?
- Inbx dw ?
- Incx dw ?
- Indx dw ?
- Insi dw ?
- Indi dw ?
- Inds dw ?
- Ines dw ?
-
- Outreg: ;Put register value to return to QBasic here
- Outax dw ?
- Outbx dw ?
- Outcx dw ?
- Outdx dw ?
- Outsi dw ?
- Outdi dw ?
- Outds dw ?
- Outes dw ?
-
- Begin: push bp ;Save bp
- mov bp,sp ;Save sp on entry
- cld ;Set to inc si & di
- push ds ;Preserve Basics ds
- push cs ;es=cs
- pop es
- add bp,6 ;Point to 3rd parameter passed
- mov di,Parameters ;Point es:di to param storage area
- mov cx,3 ;3 parameters being passed from Basic
- A1: mov bx,[bp] ;Get address of parameter from stack
- mov ax,[bx] ;Get parameter from Basic ds
- stosw ;Save it
- add bp,2 ;Point to next address on stack
- loop A1 ;Get all 3 parameters
-
- ;Get the register values from the In_array. es:di points to Inax, ds:si
- ;points to the array in Basics ds.
- mov si,cs:In_array ;Point ds:si to Basics In array
- mov cx,8 ;8 registers to get
- rep movsw ;Get the 8 register values
- mov ax,cs:Int_no ;Get the interrupt number
- mov bx,Doint ;Point to interrupt subroutine
- mov cs:[bx+1],al ;Set interrupt number in subroutine
- push ds ;Save Basics ds
-
- ;Setup registers and do the interrupt.
- push cs ;ds=cs
- pop ds
- mov ax,Inax ;Setup registers for the interrupt
- mov bx,Inbx
- mov cx,Incx
- mov dx,Indx
- mov si,Insi
- mov di,Indi
- mov es,Ines
- mov ds,Inds
- call Doint ;Do the interrupt
-
- ;Save returned register contents
- mov cs:Outds,ds ;Get returned values
- mov cs:Outes,es
- push cs ;ds=cs
- pop ds
- mov Outax,ax
- mov Outbx,bx
- mov Outcx,cx
- mov Outdx,dx
- mov Outsi,si
- mov Outdi,di
-
- ;Save register contents in Basics Out_array
- pop es ;es=Basics ds
- mov di,Out_array ;Point es:di to Basics Out array location
- mov si,Outreg ;Point ds:si to returned register values in cs
- mov cx,8 ;8 registers to return
- rep movsw ;in Basics Out array
- pop ds ;Restore registers
- pop bp
- retf 6 ;and return to Basic
-
- Doint: ;Come here to do the interrupt
- int 0 ;Replace 0 with int # desired, and do int
- ret
-