home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / basic / library / qb_pds / dos / intcall / intcall.8 next >
Encoding:
Text File  |  1987-05-10  |  3.3 KB  |  96 lines

  1. ;INTCALL.EXE source file by Bob Montgomery, 5-1-87
  2. Name      Intcall        ;Allows QBasic to do any BIOS or DOS interrupt
  3. public    INTCALL        ;Only this label will be accessable in lib
  4.  
  5. Intcall:  org  0         ;Since will link later
  6.           jmp  short Begin
  7.  
  8. Parameters:              ;Parameters passed from QBasic go here
  9. Out_array dw   ?         ;Location of returned reg value array
  10. In_array  dw   ?         ;Loaction of passed reg value array
  11. Int_no    dw   ?         ;Location of passed interrupt number
  12.  
  13. Inreg:                   ;Put register values passed from QBasic here
  14. Inax      dw   ?
  15. Inbx      dw   ?
  16. Incx      dw   ?
  17. Indx      dw   ?
  18. Insi      dw   ?
  19. Indi      dw   ?
  20. Inds      dw   ?
  21. Ines      dw   ?
  22.  
  23. Outreg:                  ;Put register value to return to QBasic here
  24. Outax     dw   ?
  25. Outbx     dw   ?
  26. Outcx     dw   ?
  27. Outdx     dw   ?
  28. Outsi     dw   ?
  29. Outdi     dw   ?
  30. Outds     dw   ?
  31. Outes     dw   ?
  32.  
  33. Begin:    push bp        ;Save bp
  34.           mov  bp,sp     ;Save sp on entry
  35.           cld            ;Set to inc si & di
  36.           push ds        ;Preserve Basics ds
  37.           push cs        ;es=cs
  38.           pop  es
  39.           add  bp,6      ;Point to 3rd parameter passed
  40.           mov  di,Parameters ;Point es:di to param storage area
  41.           mov  cx,3      ;3 parameters being passed from Basic
  42. A1:       mov  bx,[bp]   ;Get address of parameter from stack
  43.           mov  ax,[bx]   ;Get parameter from Basic ds
  44.           stosw          ;Save it
  45.           add  bp,2      ;Point to next address on stack
  46.           loop A1        ;Get all 3 parameters
  47.  
  48. ;Get the register values from the In_array. es:di points to Inax, ds:si
  49. ;points to the array in Basics ds.
  50.           mov  si,cs:In_array ;Point ds:si to Basics In array
  51.           mov  cx,8      ;8 registers to get
  52.           rep  movsw     ;Get the 8 register values
  53.           mov  ax,cs:Int_no ;Get the interrupt number
  54.           mov  bx,Doint ;Point to interrupt subroutine
  55.           mov  cs:[bx+1],al ;Set interrupt number in subroutine
  56.           push ds        ;Save Basics ds
  57.  
  58. ;Setup registers and do the interrupt.
  59.           push cs        ;ds=cs
  60.           pop  ds
  61.           mov  ax,Inax   ;Setup registers for the interrupt
  62.           mov  bx,Inbx
  63.           mov  cx,Incx
  64.           mov  dx,Indx
  65.           mov  si,Insi
  66.           mov  di,Indi
  67.           mov  es,Ines
  68.           mov  ds,Inds
  69.           call Doint     ;Do the interrupt
  70.  
  71. ;Save returned register contents
  72.           mov  cs:Outds,ds ;Get returned values
  73.           mov  cs:Outes,es
  74.           push cs        ;ds=cs
  75.           pop  ds
  76.           mov  Outax,ax
  77.           mov  Outbx,bx
  78.           mov  Outcx,cx
  79.           mov  Outdx,dx
  80.           mov  Outsi,si
  81.           mov  Outdi,di
  82.  
  83. ;Save register contents in Basics Out_array
  84.           pop  es        ;es=Basics ds
  85.           mov  di,Out_array ;Point es:di to Basics Out array location
  86.           mov  si,Outreg ;Point ds:si to returned register values in cs
  87.           mov  cx,8      ;8 registers to return
  88.           rep  movsw     ;in Basics Out array
  89.           pop  ds        ;Restore registers
  90.           pop  bp
  91.           retf 6         ;and return to Basic
  92.  
  93. Doint:                   ;Come here to do the interrupt
  94.           int  0         ;Replace 0 with int # desired, and do int
  95.           ret
  96.