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

  1.     page    66,132
  2. ;******************************** ERROR2.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.  
  12.     extrn    err_asciiz:byte
  13.     extrn    err_tbl_off:word
  14.     extrn    err_tbl_seg:word
  15.     extrn    error_number:byte
  16.     extrn    error_flags:byte
  17.     extrn    entry_seg:word
  18.     extrn    entry_bp:word    
  19.     extrn    err_tbl_off:word
  20.     extrn    err_tbl_seg:word
  21.     
  22.     extrn    error_handler1:far
  23.     extrn    one_beep:far
  24.     extrn    library_terminate:far
  25.     extrn    message:far
  26.     extrn    bar_hotkey_color:byte
  27. ;----------------------
  28. .list
  29. ;----------------------------------------------------------------------------
  30.  
  31. comment 
  32. ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -(  ERROR  )
  33. error_prime - setup error handler with additional error information
  34. ;
  35. ; inputs:  ds:bp = table of additional errors used by ERROR_TABLE_HANDLER
  36. ;          ds:di = ptr to file name for use by ERROR_FILE_HANDLER
  37. ;
  38. ; output:  none
  39. ;
  40. ; note:  If either ERROR_TABLE_HANDLER1 or ERROR_FILE_HANDLER1 are used
  41. ;        they must first be primed with the error information.  Error
  42. ;        files can be built with EDREC and the first record will be
  43. ;        error #1.  Similiarly a table can be built in memory which
  44. ;        consists of a list of pointers to text strings.         
  45. ;* * * * * * * * * * * * * *
  46. 
  47.     PUBLIC    error_prime1
  48. error_prime1    proc    far
  49.     apush    cx,si,di,es
  50.     mov    cs:err_tbl_seg,ds
  51.     mov    cs:err_tbl_off,bp
  52.     mov    cx,13
  53.     cld
  54.     mov    si,di
  55.     mov    di,offset err_asciiz
  56.     push    cs
  57.     pop    es
  58.     rep    movsb
  59.     apop    es,di,si,cx
  60.     retf
  61. error_prime1    endp    
  62. ;    
  63. comment 
  64. ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -(  ERROR  )
  65. ERROR_TABLE_HANDLER1 - handle errors described in table provided by programmer
  66. ;
  67. ; inputs:      al = error number
  68. ;           ah - flags 80h = fatal_error, abort after display
  69. ;                         40h = non_fatal1, return to retry
  70. ;                         20h = non_fatal2, return after any key press
  71. ;                         10h = fatal_return, fatal error but return after key
  72. ;                         08h = spare
  73. ;              04h = spare
  74. ;              02h = spare
  75. ;              01h = spare
  76. ;
  77. ; output:  none
  78. ;
  79. ; Note: ERROR_PRIME must be caller before this routine is accessed
  80. ;* * * * * * * * * * * * * *
  81. 
  82.     public    error_table_HANDLER1
  83. error_table_HANDLER1    proc    far
  84.     apush    ax,bx,si,ds
  85.     sub    bx,bx
  86.     mov    bl,al
  87.     shl    bx,1
  88.     sub    bx,2            ;adjust for errors starting with 1
  89.     add    bx,cs:err_tbl_off        ;index into error
  90.     mov    ds,cs:err_tbl_seg
  91.     mov    si,word ptr [bx]     ;get ptr to error msg
  92.     call    error_HANDLER1
  93.     apop    ds,si,bx,ax
  94.     retf    
  95. error_table_HANDLER1    endp
  96. comment 
  97. ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -(  ERROR  )
  98. ERROR_FILE_HANDLER1 - handle errors described in file provided by programmer
  99. ; inputs:      al = error number (1+)
  100. ;           ah - flags 80h = fatal_error, abort after display
  101. ;                         40h = non_fatal1, return to retry
  102. ;                         20h = non_fatal2, return after any key press
  103. ;                         10h = fatal_return, fatal error but return after key
  104. ;                         08h = spare
  105. ;              04h = spare
  106. ;              02h = (future) error_text, ds:bp has message
  107. ;              01h = (future) error_value, bp has error number
  108. ;
  109. ; output:  none
  110. ;
  111. ; Note: ERROR_PRIME must be called before this routine is accessed
  112. ;* * * * * * * * * * * * * *
  113. 
  114.     public    error_file_HANDLER1
  115. error_file_HANDLER1    proc    far
  116.     apush    ax,bx,cx,dx,si,di,ds,es
  117.     mov    cs:entry_seg,ds
  118.     mov    bx,cs
  119.     mov    ds,bx
  120.     mov    es,bx
  121.  
  122.     mov    entry_bp,bp
  123.     mov    error_number,al
  124.     mov    error_flags,ah
  125.     call    one_beep
  126.  
  127.     mov    ah,bar_hotkey_color
  128.     mov    al,0            ;separator
  129.     mov    dx,0101h
  130.     mov    bx,0630h
  131.     mov    si,offset err_asciiz    ;get file name
  132.     mov    bp,msg_save_win+msg_restore_win+msg_anykey+msg_close+msg_open+msg_disp
  133.     call    message
  134.     apop    es,ds,di,si,dx,cx,bx,ax
  135.     test    cs:error_flags,fatal_error
  136.     jnz    ferror_abort        ;jmp if no return from error
  137.     retf
  138.  
  139. ferror_abort:
  140.     mov    ax,0
  141.     call    library_terminate
  142.     mov    ah,4ch
  143.     int    21h
  144. error_file_HANDLER1    endp
  145.  
  146. LIBSEG    ENDS
  147.     end
  148.