home *** CD-ROM | disk | FTP | other *** search
/ C!T ROM 5 / ctrom5b.zip / ctrom5b / PROGRAM / ASM / ALIB30B / ERROR3.ASM < prev    next >
Assembly Source File  |  1994-11-15  |  5KB  |  146 lines

  1.     page    66,132
  2. ;******************************** ERROR3.ASM *********************************
  3.  
  4. LIBSEG           segment byte public "LIB"
  5.         assume cs:LIBSEG , ds:nothing
  6.  
  7. ;----------------------------------------------------------------------------
  8. .xlist
  9.     include  mac.inc
  10.     include  common.inc
  11. .list
  12. ;----------------------------------------------------------------------------
  13.     extrn    one_beep:far
  14.     extrn    library_terminate:far
  15.     extrn    key_read:far
  16.     extrn    stdout_crlf:far
  17.         
  18.     extrn    stdout_string:far
  19.     extrn    entry_seg:word
  20.     extrn    entry_bp:word
  21.     extrn    error_number:byte
  22.     extrn    error_flags:byte
  23.     extrn    error_index:word
  24. ;-----------------------------------------------------------------------------
  25. comment 
  26. ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -(  ERROR  )
  27. LIB_ERROR_HANDLER2 - handle pre defined library errors
  28. ;
  29. ; inputs:     al = error number (see error_index)
  30. ;          ah = flags 80h = fatal_error, abort after display
  31. ;                        40h = non_fatal1, return to retry
  32. ;                        20h = non_fatal2, return after any key press
  33. ;                        10h = fatal_return, fatal error but return after key
  34. ;                        08h = spare
  35. ;                        04h = spare
  36. ;             02h = spare
  37. ;             01h = spare
  38. ;
  39. ; output:  displayed error message as follows:
  40. ;          1 - Incompatable display mode
  41. ;          2 - Code error, Contact program author for possible
  42. ;              problem resolution
  43. ;          3 - Disk read error, Press any key to contine
  44. ;          4 - Fatal disk error, Press any key
  45. ;          5 - Out of memory, Press any key to abort current operation
  46. ;          6 - Path change failed, Press any key
  47. ;          7 - insufficient DOS memory to run program,
  48. ;              Press any key to abort.
  49. ;          8 - Error in finding/reading quote file QUOTE.DAT
  50. ;          9 - Memory manager transfer error.  This is usually
  51. ;              a programming error.  Contact the author for assistance.
  52. ;         10 - Open of above file failed, possibly the file does not
  53. ;              exist or is not in correct directory.
  54. ;         11 - The program configuration (.CFG) file is missing an <end>
  55. ;              statement.   press any key to continue
  56. ;
  57. ; note:  LIB_ERROR_HANDLER2 is intended for library use only, but can be
  58. ;        called from application.               
  59. ;* * * * * * * * * * * * * *
  60. 
  61.     public    LIB_ERROR_HANDLER2
  62. LIB_ERROR_HANDLER2    proc    far
  63.     apush    ax,bx,si,ds
  64.     sub    bx,bx
  65.     mov    bl,al
  66.     shl    bx,1
  67.     add    bx,offset error_index-2  ;index into table
  68.     mov    si,word ptr cs:[bx]     ;get ptr to error msg
  69.     push    cs
  70.     pop    ds
  71.     call    one_beep
  72.     call    stdout_crlf
  73.     call    stdout_string
  74.     call    key_read
  75.     apop    ds,si,bx,ax
  76.     retf    
  77. LIB_ERROR_HANDLER2    endp
  78. comment 
  79. ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -(  ERROR  )
  80. ERROR_HANDLER2 - handle fatal errors
  81. ;
  82. ; inputs:     ds:si = error text terminated with null character (00).
  83. ;                ah = flags 80h - fatal_error, abort after display
  84. ;                           40h - non_fatal1, return to retry
  85. ;                           20h - non_fatal2, return after any key press
  86. ;                           10h - fatal_return, fatal error but return after key
  87. ;                           08h - spare
  88. ;                04h - spare
  89. ;                02h - spare
  90. ;                01h - spare
  91. ;
  92. ; output:    ax = last keypress if a return was requested.
  93. ;
  94. ; notes:  If the abort option is requested, the library will be closed and
  95. ;         the DOS return call executed.
  96. ;* * * * * * * * * * * * * *
  97. 
  98.  
  99. err_key_sav    dw    0    ;user key press used to confirm box is viewed.
  100.  
  101.     public    ERROR_HANDLER2
  102. ERROR_HANDLER2    proc    far
  103.     apush    bx,cx,dx,si,di,ds,es
  104.     mov    cs:entry_seg,ds
  105.  
  106.     mov    entry_bp,si
  107.     mov    error_number,al
  108.     mov    error_flags,ah
  109.     call    one_beep
  110. ;
  111. ; display the error text
  112. ;
  113. eh1_cont2:
  114.     push    ds
  115.     mov    ds,cs:entry_seg
  116.     mov    si,cs:entry_bp
  117.     call    stdout_crlf
  118.     call    stdout_string
  119.     pop    ds
  120. ;
  121. ; check type of exit processing, and wait for key if necessary, then exit
  122. ;
  123. error_key1:
  124.     call    KEY_READ            ;get key press
  125.     mov    cs:err_key_sav,ax        ;save keypress
  126. ;
  127. ; determine what type of exit is needed
  128. ;
  129.     apop    es,ds,di,si,dx,cx,bx
  130.     test    cs:error_flags,fatal_error
  131.     jnz    error_abort1        ;jmp if no return from error
  132.     mov    ax,cs:err_key_sav    ;restore key press
  133.     retf
  134.  
  135. error_abort1:
  136.     mov    ax,0
  137.     call    library_terminate
  138.     mov    ah,4ch
  139.     int    21h
  140.     
  141. ERROR_HANDLER2    endp
  142. ;---------------------------------------------------------------------------
  143.  
  144. LIBSEG    ENDS
  145.     end
  146.