home *** CD-ROM | disk | FTP | other *** search
/ Power Programming / powerprogramming1994.iso / progtool / modem / byepc300.arc / BYEXMDM.ARC / CTRLBRK.ASM < prev    next >
Assembly Source File  |  1987-03-07  |  4KB  |  123 lines

  1.           page 60,132
  2.           title ASM Routines for MSC 3.00 Small Memory Model
  3. ;
  4. ;---------------------------------------------------------------------------
  5. ;             General Equates
  6. ;---------------------------------------------------------------------------
  7. ;
  8. YES    equ    1
  9. NO    equ    0
  10. ;
  11. ;---------------------------------------------------------------------------
  12. ;  Memory Model selector for Microsoft C v3.0, ASM files.
  13. ;---------------------------------------------------------------------------
  14. ;  -- model --              -- equates --
  15. ; {small}            _LDATA = NO    _LCODE = NO
  16. ; {medium}            _LDATA = NO    _LCODE = YES
  17. ; {compact}            _LDATA = YES   _LCODE = NO
  18. ; {large}            _LDATA = YES   _LCODE = YES
  19. ;---------------------------------------------------------------------------
  20. ;
  21. ;    -- Small Memory Model --
  22. ;
  23. _LDATA    equ   NO          ; data area size
  24. _LCODE    equ   NO          ; code pointers far.
  25. ;
  26. include  MODEL.H          ; get memory model header
  27. ;
  28. ;---------------------------------------------------------------------------
  29. ; Set up the program segment according to memory model.
  30. ;---------------------------------------------------------------------------
  31. ;
  32. if _LCODE             ; setup program segment
  33.     pseg cbrk
  34. else
  35.     pseg
  36. endif
  37. ;
  38. ;---------------------------------------------------------------------------
  39. ;
  40. ;  void ctrl_break(state)
  41. ;
  42. ;     int state; 0 = Disable Ctrl-Break
  43. ;         1 = Enable Control Break;
  44. ;
  45. ;  This routine will disable the control break from the keyboard from
  46. ;  'C' programs and prevent the '^C' from appearing after the break
  47. ;  key was pressed. Once the break has been disabled IT MUST BE RE-
  48. ;  STORED BEFORE EXITING or a SYSTEM CRASH will occur after exiting
  49. ;  the program.
  50. ;---------------------------------------------------------------------------
  51. ;
  52.           public _ctrl_break
  53. ;
  54. if          _LCODE
  55. _ctrl_break   proc far
  56. else
  57. _ctrl_break   proc near
  58. endif
  59.           push bp                ;standard 'C' function entry
  60.           mov  bp,sp
  61.           push di
  62.           push si
  63.           push ds
  64.           push es
  65.  
  66.           mov  ax,@ab[bp]            ;get the break state flag
  67.           or   ax,ax            ;if zero, cut if off
  68.           jz   short brk_off
  69.  
  70.           mov  dx,cs:int23_off        ;get old vector location
  71.           mov  ax,cs:int23_seg
  72.           mov  ds,ax            ;DS:DX = old vector
  73.           mov  ax,251Bh
  74.           int  21h                ;now restore old vector
  75.           jmp  short brk_end        ; and exit
  76.  
  77. brk_off:      mov  ax,351Bh            ;get Ctrl_Break vector
  78.           int  21h
  79.           mov  cs:int23_off,bx        ;store old vector location
  80.           mov  cs:int23_seg,es
  81.  
  82.           mov  dx, offset cs:dummy        ;set new Ctrl-Break vector
  83.           mov  ax,cs            ;DS:DX = new vector
  84.           mov  ds,ax
  85.           mov  ax,251Bh
  86.           int  21h
  87.  
  88. brk_end:      pop  es
  89.           pop  ds
  90.           pop  si                ;standard  'C' function exit
  91.           pop  di
  92.           mov  sp,bp
  93.           pop  bp
  94.           ret
  95.  
  96. int23_seg     dw   ?                ;old break vector storage
  97. int23_off     dw   ?
  98.  
  99. _ctrl_break   endp
  100. ;
  101. ;
  102. ;---------------------------------------------------------------------------
  103. ; This is the dummy function called when Ctrl-Break is pressed.
  104. ;---------------------------------------------------------------------------
  105. ;
  106. dummy          proc far
  107.  
  108.           iret                ;do nothing and return
  109.  
  110. dummy          endp
  111. ;
  112. ;---------------------------------------------------------------------------
  113. ;   End of program code
  114. ;---------------------------------------------------------------------------
  115. ;
  116. if          _LCODE
  117.           endps cbrk
  118. else
  119.           endps
  120. endif
  121.           end
  122.  
  123.