home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / dos_ency / 6 / ch1a.asm < prev    next >
Encoding:
Assembly Source File  |  1988-08-11  |  2.4 KB  |  80 lines

  1.         TITLE   CH1A.ASM
  2.  
  3. ; CH1A.ASM -- support file for CTERM.C terminal emulator
  4. ;       this set of routines replaces Ctrl-C/Ctrl-BREAK
  5. ;       usage: void set_int(), rst_int();
  6. ;               int broke();    /* boolean if BREAK     */
  7. ;       for use with Microsoft C and SMALL model only...
  8.  
  9. _TEXT   segment byte public 'CODE'
  10. _TEXT   ends
  11. _DATA   segment byte public 'DATA'
  12. _DATA   ends
  13. CONST   segment byte public 'CONST'
  14. CONST   ends
  15. _BSS    segment byte public 'BSS'
  16. _BSS    ends
  17.  
  18. DGROUP  GROUP   CONST, _BSS, _DATA
  19.         ASSUME  CS:_TEXT, DS:DGROUP, ES:DGROUP, SS:DGROUP
  20.  
  21. _DATA   SEGMENT BYTE PUBLIC 'DATA'
  22.  
  23. OLDINT1B DD     0               ; storage for original INT 1BH vector
  24.  
  25. _DATA   ENDS
  26.  
  27. _TEXT   SEGMENT
  28.  
  29.         PUBLIC  _set_int,_rst_int,_broke
  30.  
  31. myint1b:
  32.         mov     word ptr cs:brkflg,1Bh          ; make it nonzero
  33.         iret
  34.  
  35. myint23:
  36.         mov     word ptr cs:brkflg,23h          ; make it nonzero
  37.         iret
  38.  
  39. brkflg  dw      0               ; flag that BREAK occurred
  40.  
  41. _broke  proc    near            ; returns 0 if no break
  42.         xor     ax,ax           ; prepare to reset flag
  43.         xchg    ax,cs:brkflg    ; return current flag value
  44.         ret
  45. _broke  endp
  46.  
  47. _set_int proc near
  48.         mov     ax,351bh        ; get interrupt vector for 1BH
  49.         int     21h             ; (don't need to save for 23H)
  50.         mov     word ptr oldint1b,bx     ; save offset in first word
  51.         mov     word ptr oldint1b+2,es   ; save segment in second word
  52.  
  53.         push    ds              ; save our data segment
  54.         mov     ax,cs           ; set DS to CS for now
  55.         mov     ds,ax
  56.         lea     dx,myint1b      ; DS:DX points to new routine
  57.         mov     ax,251bh        ; set interrupt vector
  58.         int     21h
  59.         mov     ax,cs           ; set DS to CS for now
  60.         mov     ds,ax
  61.         lea     dx,myint23      ; DS:DX points to new routine
  62.         mov     ax,2523h        ; set interrupt vector
  63.         int     21h
  64.         pop     ds              ; restore data segment
  65.         ret
  66. _set_int endp
  67.  
  68. _rst_int proc near
  69.         push    ds              ; save our data segment
  70.         lds     dx,oldint1b     ; DS:DX points to original
  71.         mov     ax,251bh        ; set interrupt vector
  72.         int     21h
  73.         pop     ds              ; restore data segment
  74.         ret
  75. _rst_int endp
  76.  
  77. _TEXT   ends
  78.  
  79.         END
  80.