home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / forth / compiler / fpc / source / hcritica.seq < prev    next >
Text File  |  1990-05-25  |  5KB  |  120 lines

  1. \ HCRITICA.SEQ  this file provides a special critical error handler
  2. \ written by mike christopher  12/31/89 16:05:00.53
  3. \ modified by Tom Zimmer       03/15/90 11:21:55.26
  4. \ Added to FPC KERNEL.COM      05/25/90 16:08:09.42
  5.  
  6. FILES DEFINITIONS
  7.  
  8. VARIABLE HCRITICA.SEQ
  9.  
  10. FORTH DEFINITIONS
  11.  
  12. comment:
  13.   Tom, if you desire to use this, you may do so without any restrictions.
  14.   These words are in the public domain and may be used for any
  15.   purpose comercial or otherwise
  16.  
  17.   Mike Christopher  28 Feb 1990
  18.  
  19.  
  20.   These routines support DOS critical errors. If a critical error
  21.   occurs, DOS gives the dreaded ---  Abort, Retry, Ignore ?  ( on xt's)
  22.                                 ---  Abort, Retry, Fail ?    (on AT's)
  23.  
  24.   To handle this more gracefully, you can use your own routine to decide
  25.   what to do in response to a critical error (like the drive door being open)
  26.   This particular incarnation simply instructs DOS that we wish to fail
  27.   in the optimistic expectation that user software will catch the errors.
  28.   In practice this is reasonable and it sure beats having vectors installed
  29.   (memory allocations too!) when some operator decides to reply ABORT
  30.   to DOS's default handler.
  31.  
  32.   The critical error interrupt differs from the Control C/Break interrupt
  33.   because you can NOT just abort to forth!!! DOS expects to get control
  34.   back and will NOT BE STABLE if you don't give control back!!
  35.  
  36.   This works well with F-PC because drive door problems result in a
  37.   "unable to open" type of error. I humbly contend that since some
  38.   vectors are snatched by F-PC, it should handle this itself.
  39.  
  40.   For More info, see Advanced MSDOS programming by Ray Duncan. (MS Press)
  41.   (he's a fellow Forther too!)
  42.  
  43. Modifications by Tom Zimmer      03/15/90 11:22:10.25
  44.  
  45.   Re-ordered the save and restore vector functions, since DOS already
  46.   restores the critical error handler when our program terminates, we
  47.   need not do that. Note that whenever we shell out to DOS from Forth,
  48.   the critical error handler gets reset to the DOS default, so we must
  49.   re-install the handler when returning from a DOS shell (like DIR for
  50.   example).
  51.  
  52. comment;
  53.  
  54. \ you may use hadcritical to see if the last thing you did caused a
  55. \ critical error. If you are going to use it (its optional)
  56. \  YOU must clear the flag after you've seen it.
  57.  
  58. VARIABLE HADCRITICAL        \ non-zero if critcal error has happened
  59.  
  60.  
  61. LABEL CRITINT                           \ handle a critical error interrupt
  62.                 STI                     \ re-enable interrupts
  63.                 INC HADCRITICAL WORD    \ set when critical error occurs
  64.                 MOV AL, # 0             \ tell DOS to ignore the error
  65.                 IRET                    \ return from interrupt
  66.                 END-CODE
  67.  
  68. CODE SETCRITICAL
  69.                 PUSH DS
  70.                 MOV DX, # CRITINT       \ get new hndlr addr
  71.                 MOV AX, # $2524         \ set critical err int
  72.                 INT $21
  73.                 POP DS
  74.                 NEXT    END-CODE
  75.  
  76.  
  77. comment:
  78.  
  79. \ ***************************************************************************
  80. \ Using the following routines, we can save and restore the critical error
  81. \ handler, but DOS does this when our program terminates anyway, so why
  82. \ bother.
  83. \ ***************************************************************************
  84.  
  85. create oldcritical  4 allot             \ room for seg:ofs of old routine
  86.        oldcritical  4 erase             \ clear it out
  87.  
  88. code savecritical
  89.                 push ds                 \ save critical regs affected
  90.                 push es
  91.                 mov ax, # $3524         \ get current errhndlr at int $24
  92.                 int $21
  93.                 mov ax, es              \ get segment
  94.                 mov oldcritical ax      \ save seg
  95.                 mov oldcritical 2+ bx   \ save offset
  96.                 pop es                  \ es is safe now
  97.                 pop ds                  \ get old ds
  98.                 next
  99.                 c;
  100.  
  101. code resetcritical                      \ put back original critical hndler
  102.                 push ds                 \ save critical regs affected
  103.                 push es
  104.                                         \ note: this is ORDER dependant.
  105.                                         \ you have to do the offset first
  106.                                         \ because you'll lose access to it
  107.                                         \ as soon as ds changes!! tough bug!
  108.                 mov dx, oldcritical 2+  \ restore offset of old hndlr
  109.                 mov ax, oldcritical     \ restore segment
  110.                 mov ds, ax              \ of old handler
  111.                 mov ax, # $2524         \ set critical err int
  112.                 int $21
  113.                 pop es                  \ restore regs
  114.                 pop ds
  115.                 next
  116.                 c;
  117.  
  118. comment;
  119.  
  120.