home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / l / l320 / 2.img / EXAMPLES / CHECK.F < prev    next >
Encoding:
Text File  |  1989-08-31  |  2.1 KB  |  59 lines

  1. c This subroutine can be used to catch NDP EXCEPTIONS.
  2. c To find what procedure an exception has occurred in, see
  3. c the example of USER_DEBUG(a,b,n).  Once the procedure is known,
  4. c add CALL CHECK(identifier) at strategic places.
  5. c Every time CHECK is called, it will check the STATUS WORD.
  6. c If a problem has occurred since the last invocation to CHECK,
  7. c the error will be printed with the identifier.
  8.  
  9.     subroutine check(i)
  10.     character*10 temp
  11.     data temp / 10H(' ',i1,$) /
  12.     integer j, stndpsw, k
  13. 1    Format (' ',a,$)
  14.     j = stndpsw()
  15.     if (0.lt.(j.and.127)) then
  16.       k=0
  17. 10      k=k+1
  18.       if (i.ge.10**k) goto 10
  19.       temp(7:7) = char(48+k)
  20.       Print 1, 'Before Check #'
  21.       Print temp, i
  22.       If (0.lt.(J.AND. 1)) Print 1,', Invalid Operation'
  23.       If (0.lt.(J.AND. 2)) Print 1,', Denormal'
  24.       If (0.lt.(J.AND. 4)) Print 1,', Zero Divide'
  25.       If (0.lt.(J.AND. 8)) Print 1,', Overflow'
  26.       If (0.lt.(J.AND.16)) Print 1,', Underflow'
  27.       If (0.lt.(J.AND.32)) Print 1,', Precision'
  28.       If (0.lt.(J.AND.64)) Print 1,', Stack Fault'
  29.       Print *,'.'
  30.       call clrndpex
  31.     end if
  32.     end
  33.  
  34. c This subroutine can be used to catch MEMORY PROTECTION FAULTS.
  35. c To find what procedure the problem is happening in, write down
  36. c the address given in CS:EIP.  From the DOS prompt, type this line:
  37. c TYPE {filename}.MAP | FIND "codeseg" | SORT /+15 > p2.map
  38. c This line will sort the map file into a new file called p2.map.
  39. c p2.map will have all procedures listed in increasing order of
  40. c memory address.  Find what 2 memory addresses the CS:EIP number is
  41. c between; the MEMORY PROTECTION FAULT is in the first procedure.
  42. c In that procedure, add CALL DUM(identifier 1-26) at strategic places.
  43. c Every time the program passes this point, it will print a letter
  44. c (A-Z corresponding to the identifier), followed by the number
  45. c of times the program has passed this point.
  46.  
  47.     subroutine dum(k)
  48.     character*11 temp
  49.     integer i(26)
  50.     data i,temp / 26*0,11H(' A',I1,$) /
  51.     i(k) = i(k) + 1
  52.     j = 0
  53. 10    j = j + 1
  54.     if (i(k).ge.10**j) goto 10
  55.     temp(4:4) = char(64+k)
  56.     temp(8:8) = char(48+j)
  57.     print temp, i(k)
  58.     end
  59.