home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / xbase / library / clipper / progr_ba / ints.asm < prev    next >
Assembly Source File  |  1992-02-27  |  6KB  |  181 lines

  1. ;-----------------------------------------------------------------------------
  2. ;
  3. ;  STATUS version 1.01
  4. ;  (c) 1992 John T. Opincar, Jr.
  5. ;  CID: 71631,541
  6. ;  02/27/92 
  7. ;
  8. ;  PLEASE READ THIS!
  9. ;                                      
  10. ;  You are free to distribute STATUS in any manner you choose and use STATUS
  11. ;  in any setting, including commercial without any obligation to me.  The
  12. ;  only thing that I ask is that you do not distribute modified versions of
  13. ;  STATUS without including the original code and documentation in its
  14. ;  entirety.  If you feel inclined to distribute STATUS with your own 
  15. ;  modifications (which I would discourage), ***PLEASE*** keep your changes
  16. ;  in seperate files, and make the seperation and changes obvious to anyone
  17. ;  who might subsequently encounter the ZIP.
  18. ;
  19. ;  I have been informally supporting STATUS on CIS, and do not want a zillion
  20. ;  messages about problems introduced by others.  In lieu of making your own
  21. ;  changes, I would prefer that you send me mail describing the additional
  22. ;  features you would like to see in STATUS.  The exceptional performance
  23. ;  gains yielded by STATUS are the result of several key assumptions about 
  24. ;  how it will be used.  Before making a suggestion, please read the section
  25. ;  in the documentation entitled, "What Makes STATUS Tick." The main 
  26. ;  motivation behind this version of STATUS was input I received from users.
  27. ;
  28. ;-----------------------------------------------------------------------------
  29.  
  30. DOSSEG
  31. .MODEL      LARGE
  32.  
  33. PUBLIC      SETINT
  34.  
  35. .DATA
  36. intcount    dw      0           ;number of ints installed
  37. ints        dw      30 dup(?)   ;array of old interrupt vectors and their #s
  38. old21h      dw      2 dup(0)    ;old int 21h vector
  39.  
  40. .CODE
  41.  
  42. ;-----------------------------------SETINT--------------------------------------
  43.  
  44. ;PURPOSE: Saves old interrupt vector and number specified by intnum.  Installs
  45. ;         routine pointed to by newintseg:newintofs
  46.  
  47. SETINT      proc    far
  48.             push    bp
  49.             mov     bp,sp
  50. intnum      equ     <[bp + 6]>
  51. newintofs   equ     <[bp + 8]>
  52. newintseg   equ     <[bp + 10]>
  53.             push    es
  54.  
  55.             mov     ax,old21h[0]            ;see if exitctrl already installed
  56.             mov     dx,old21h[2]
  57.             or      ax,dx
  58.             jnz     exitinst
  59.  
  60.             mov     ax,3521h                ;save old exit handler
  61.             int     21h
  62.             mov     old21h,bx
  63.             mov     old21h[2],es
  64.  
  65.             push    ds                      ;set new exit handler
  66.             mov     dx,OFFSET exitctrl
  67.             mov     ax,SEG exitctrl
  68.             mov     ds,ax
  69.             mov     ax,2521h
  70.             int     21h
  71.             pop     ds
  72.  
  73. exitinst:   mov     ax,intnum               ;get old int pointer
  74.             mov     ah,35h
  75.             int     21h
  76.             push    bx
  77.             push    es
  78.  
  79.             push    ds
  80.             mov     ax,intnum               ;set new int pointer
  81.             mov     ah,25h
  82.             mov     dx,newintofs
  83.             mov     bx,newintseg
  84.             mov     ds,bx
  85.             int     21h
  86.             pop     ds
  87.  
  88.             mov     bx,intcount             ;record old int pointer and num
  89.             mov     ax,bx
  90.             shl     ax,1
  91.             add     bx,ax
  92.             shl     bx,1
  93.             add     bx,OFFSET ints
  94.             mov     ax,intnum
  95.             mov     [bx],ax
  96.             pop     dx
  97.             pop     ax
  98.             mov     [bx + 2],ax
  99.             mov     [bx + 4],dx
  100.             inc     intcount
  101.  
  102.             pop     es
  103.             mov     sp,bp
  104.             pop     bp
  105.             ret
  106. SETINT      ENDP
  107.  
  108. ;----------------------------------EXITCTRL-------------------------------------
  109.  
  110. EXITCTRL    proc    far
  111.             jmp     overdata
  112.  
  113. exit_int    label   dword
  114. old21h_c    dw      2 dup(?)
  115.  
  116. overdata:   pushf
  117.             cmp     ah,4ch          ;only interested in function 4ch
  118.             jne     calloldexit
  119.  
  120.             push    ax
  121.             push    bx
  122.             push    cx
  123.             push    dx
  124.             push    ds
  125.             push    es
  126.             push    di
  127.  
  128.             mov     ax,@DATA
  129.             mov     ds,ax
  130.             assume  ds:DGROUP
  131.  
  132. intloop:    cmp     intcount,0      ;restore all modified interrupt vectors
  133.             je      loopdone
  134.             dec     intcount
  135.             mov     bx,intcount
  136.             mov     ax,bx
  137.             shl     ax,1
  138.             add     bx,ax
  139.             shl     bx,1
  140.             add     bx,OFFSET ints
  141.             push    ds
  142.             mov     ah,25h
  143.             mov     al,[bx]
  144.             mov     dx,[bx + 2]
  145.             mov     cx,[bx + 4]
  146.             mov     ds,cx
  147.             int     21h
  148.             pop     ds
  149.             jmp     intloop
  150.  
  151. loopdone:   mov     ax,2521h        ;restore old int 21h vector
  152.             mov     dx,old21h
  153.             mov     cx,old21h[2]
  154.             mov     ds,cx
  155.             int     21h
  156.             pop     di
  157.             pop     es
  158.             pop     ds
  159.             pop     dx
  160.             pop     cx
  161.             pop     bx
  162.             pop     ax
  163.  
  164. calloldexit:push    ax              ;jump to old int 21h routine
  165.             push    ds
  166.             mov     ax,@DATA
  167.             mov     ds,ax
  168.             assume  ds:DGROUP
  169.             mov     ax,old21h
  170.             mov     cs:old21h_c,ax
  171.             mov     ax,old21h[2]
  172.             mov     cs:old21h_c[2],ax
  173.             pop     ds
  174.             pop     ax
  175.             popf
  176.             assume  ds:nothing,es:nothing
  177.             jmp     exit_int
  178. EXITCTRL    ENDP
  179.  
  180. END
  181.