home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c220 / 4.ddi / LIB / SRC / CALLINT.ASM < prev    next >
Encoding:
Assembly Source File  |  1990-12-16  |  2.9 KB  |  105 lines

  1.     include model
  2.     cseg    callint_
  3. ; {*********************************************************************
  4. ; (C) Copyright      1986;  Franklin L. DeRemer,   Thomas J. Pennello,
  5. ;               MetaWare Incorporated;  Santa Cruz, CA 95060.
  6. ; This program is the unpublished property and trade secret of the above
  7. ; three.  It is to be utilized solely under license from MetaWare and it
  8. ; is to be maintained on a confidential basis for internal  company  use
  9. ; only.  The  security    and  protection  of  the program is paramount to
  10. ; maintenance of the trade secret status.  It is to  be  protected  from
  11. ; disclosure  to  unauthorized parties, both within the Licensee company
  12. ; and outside, in a manner not less stringent than that utilized for Li-
  13. ; censee's own proprietary  internal  information.   No  copies  of  the
  14. ; Source or Object Code are to leave the premises of Licensee's business
  15. ; except  in  strict accordance with the license agreement signed by Li-
  16. ; censee with MetaWare.
  17. ; *********************************************************************}
  18. ;
  19. ;  MetaWare Pascal Runtime Support: DOS Interface.
  20. ;
  21. _MWDOSREGS    segment dword common 'DATA'
  22. Rax        dd    0
  23. Rbx        dd    0
  24. Rcx        dd    0
  25. Rdx        dd    0
  26. Rsi        dd    0
  27. Rdi        dd    0
  28. Rds        dd    0
  29. Res        dd    0
  30. Flags        dw    0
  31. _MWDOSREGS    ends
  32.  
  33. DGROUP    group    _MWDOSREGS
  34.  
  35. ; This is almost identical to DOS.ASM.
  36.  
  37. CALLINT        proc    far    ; Call an arbitrary interrupt.
  38. ; Callint(n) constructs an "int n" instruction and executes it, after
  39. ; loading the registers from the global register record.
  40. ; THIS WILL NOT WORK on a 286 in virtual mode.
  41. ; We couldn't fake it anyway since in the latter case INT must go
  42. ; through the 286's IDT.
  43. ; This works for the time being on a 386 in protected mode ONLY WHEN
  44. ; CS and DS point to the same area, as they do for Softguard and Phar Lap.
  45. ; What about A.I. Architects OS/386?
  46.         publab    callint
  47.         push    ebp
  48.         mov    ebp,esp
  49.         push    esi
  50.         push    edi
  51.         push    ebx
  52.         parms    <<Int_level,byte>>
  53.         mov    al,Int_level
  54.         mov    esi,offset int_number
  55.         mov    [esi],al
  56. ;           mov    cs:int_number,al
  57.         push    ds
  58.         push    es    ; Save es in case we're in small_data mode.
  59.         ASSUME    ds:DGROUP
  60.         mov    eax,Rax    ; set ax..dx, si, di.
  61.         mov    ebx,Rbx
  62.         mov    ecx,Rcx
  63.         mov    edx,Rdx
  64.         mov    esi,Rsi
  65.         mov    edi,Rdi
  66.         push    Res
  67.         pop    es    ; Set es.
  68.  
  69.         push    ds    ; Save DS before call.
  70.         push    Rds
  71.         pop    ds    ; set ds now.
  72.         clc        ; For int 21.
  73. int_number equ byte ptr $+1
  74.         int    0dh     ; call some interrupt.
  75.                         ; In case the poke fails, 0dh traps in os386.
  76.         
  77. continue:       pop    ebp    ; Old value of DS; BP IS NOW DESTROYED!!
  78.         push    ds    ; save returned DS.
  79.         mov    ds,bp    ; DS is now restored.
  80.         pop    Rds    ; pop ds.
  81.  
  82.         push    es
  83.         pop    Res
  84.         mov    Rax,eax
  85.         mov    Rbx,ebx
  86.         mov    Rcx,ecx
  87.         mov    Rdx,edx
  88.         mov    Rsi,esi
  89.         mov    Rdi,edi
  90.         pushf
  91.         pop    Flags
  92.         ; Now we've moved all results into register table.
  93.         pop    es
  94.         pop    ds
  95.         
  96.         pop    ebx
  97.         pop    edi
  98.         pop    esi
  99.         pop    ebp
  100.         
  101.         return  Word_size
  102. CALLINT     endp
  103.         endcseg callint_
  104.         end
  105.