home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c082_122 / 1.ddi / CLIBSRC1.ZIP / STACK.ASM < prev    next >
Encoding:
Assembly Source File  |  1992-06-10  |  1.5 KB  |  50 lines

  1. ;[]-----------------------------------------------------------------[]
  2. ;|      STACK.ASM -- stack overflow handler                          |
  3. ;[]-----------------------------------------------------------------[]
  4.  
  5. ;
  6. ;       C/C++ Run Time Library - Version 5.0
  7. ;       Copyright (c) 1987, 1992 by Borland International
  8. ;       All Rights Reserved.
  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.         mov     bx,ds                   ; save DS
  29.         mov     ax,cs
  30.         mov     ds,ax                   ; Print the message.
  31.         mov     dx,offset message
  32.         mov     ah,9
  33.         int     21h
  34.         mov     ds,bx                   ; restore DS
  35. ;
  36. ; We can't just terminate the program here because it might die owning
  37. ; interrupt vectors that startup took for the signals and divide by zero.
  38. ; The clean way out is through _exit() who puts all that stuff back.
  39. ;
  40. ; Hopefully the program hasn't gone so berserk so that _exit() restores
  41. ; invalid stuff.  We have a real "lose-lose" situation here....
  42. ; In the case of a 'nice' stack overrun we're doing the right thing though.
  43. ;
  44.         jmp    __exit                   ; This is a one-way trip!
  45. _TEXT   ENDS
  46.         END
  47.  
  48.