home *** CD-ROM | disk | FTP | other *** search
/ Computer Select (Limited Edition) / Computer Select.iso / dobbs / v17n02 / inhook.exe / INT61.ASM < prev    next >
Encoding:
Assembly Source File  |  1991-05-03  |  1.7 KB  |  57 lines

  1. ;-----------------------------------------------------------------------------;
  2. ;                                          ;
  3. ;    INT61.ASM -- Forwarder program for the INTHOOK example application       ;
  4. ;                                          ;
  5. ;    Written by Walter Oney                              ;
  6. ;                                          ;
  7. ;-----------------------------------------------------------------------------;
  8.  
  9.      name  int61
  10.      .286p
  11. int61     segment byte public 'code'
  12.      assume cs:int61, ds:int61
  13.      org   100h          ; required for .COM file usage
  14. begin:     jmp   doit          ; jump around fixed data area
  15.  
  16. vect60     dw    0, 0          ; for inspection by signaller
  17.  
  18. doit:     mov   ax, 2561h      ; hook INT 61h so INT60 can find us
  19.      lea   dx, callback      ;   from another virtual machine
  20.      int   21h          ;   ..
  21.  
  22.      lea   dx, endprog+15      ; point past all code in this module
  23.      shr   dx, 4          ; compute # paragraphs to keep
  24.      mov   ax, 3100h      ; terminate and stay resident
  25.      int   21h          ; (does not return)
  26.  
  27. ;    CALLBACK is reached circuitously when INT60 does a 2F/1685 to schedule
  28. ;    it to run in the system virtual machine.
  29.  
  30. callback:
  31.      push  es          ; save working registers
  32.      push  ds          ;   ..
  33.      pusha              ;   ..
  34.      mov   ax, cs          ; set DS == CS
  35.      mov   ds, ax          ;   ..
  36.  
  37.      mov   ax, 3560h      ; get current INT 60 vector address
  38.      int   21h          ;   ..
  39.      mov   vect60, bx      ; save for debugging inspection
  40.      mov   vect60+2, es      ;   ..
  41.  
  42.      mov   ax, es          ; is there a handler?
  43.      or    ax, bx          ;   ..
  44.      jz    done60          ; if not, don't signal it!
  45.  
  46.      int   60h          ; issue INT 60 to wakeup WinApp
  47.  
  48. done60:  popa              ; restore registers
  49.      pop   ds
  50.      pop   es          ;   ..
  51.      iret              ; return from callback to Windows
  52.  
  53. endprog:              ; for 21/31 paragraph computation
  54.  
  55. int61     ends
  56.      end   begin
  57.