home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c065 / 2.ddi / CLIB2.ZIP / STACK.ASM < prev    next >
Encoding:
Assembly Source File  |  1990-06-07  |  1.6 KB  |  46 lines

  1. ;[]-----------------------------------------------------------------[]
  2. ;|      STACK.ASM -- stack overflow handler                          |
  3. ;|                                                                   |
  4. ;|      Turbo-C Run Time Library        Version 3.0                  |
  5. ;|                                                                   |
  6. ;|      Copyright (c) 1987,1988,1990 by Borland International Inc.   |
  7. ;|      All Rights Reserved.                                         |
  8. ;[]-----------------------------------------------------------------[]
  9.  
  10. ; calls to this routine are generated by the compiler when
  11. ; stack overflow is detected.
  12.  
  13.         INCLUDE RULES.ASI
  14.  
  15. _TEXT   SEGMENT BYTE PUBLIC 'CODE'
  16.         ASSUME  CS:_TEXT
  17.  
  18. extrn    __exit:near
  19.  
  20.         public  F_OVERFLOW@
  21.         public  N_OVERFLOW@
  22.         public  OVERFLOW@
  23.  
  24. message db      'Stack overflow!',13,10,'$'
  25. N_OVERFLOW@:
  26. F_OVERFLOW@:
  27. OVERFLOW@:
  28.         push    cs
  29.         pop     ds                      ; Print the message.
  30.     mov     dx,offset message
  31.     mov     ah,9
  32.     int     21h
  33. ;
  34. ; We can't just terminate the program here because it might die owning
  35. ; interrupt vectors that startup took for the signals and divide by zero.
  36. ; The clean way out is through _exit() who puts all that stuff back.
  37. ;
  38. ; Hopefully the program hasn't gone so berserk so that _exit() restores
  39. ; invalid stuff.  We have a real "lose-lose" situation here....
  40. ; In the case of a 'nice' stack overrun we're doing the right thing though.
  41. ;
  42.     jmp    __exit            ; This is a one-way trip!
  43. _TEXT   ENDS
  44.         END
  45.  
  46.