C DOHLIB.FOR							9-AUG-85
C
C	Sample subroutines for diagnostic overlay handler.
C
C*****************************************************************************

	SUBROUTINE OHANDI

	INCLUDE 'DOHLIB.INC'

D	BYTE REPLY

	nlevel = 0
D	WRITE (5,*) 'DOH: initializing'

D	WRITE (5,*) 'DOH: Do you want detailed diagnostics?'
D	READ  (5,'(A1)') REPLY
D	diagnostics = REPLY .EQ. 'Y'  .OR.  REPLY .EQ. 'y'

	END

C*****************************************************************************

	SUBROUTINE OHANDC ( iseg, iaddr )

	INCLUDE 'DOHLIB.INC'

D	IF ( diagnostics ) THEN
D	   WRITE (5,10) iseg, iaddr+2
D10	   FORMAT ( ' DOH: call subroutine : segment 'O3,
D    1	            ' at ', O6 )
D	ENDIF

	IF ( nlevel .LT. nbranch ) THEN
	   nlevel = nlevel + 1
	   nseg  (nlevel) = iseg
	   naddr (nlevel) = iaddr
	ELSE
	   STOP 'DOH: too many branches'
	ENDIF

	END

C*****************************************************************************

	SUBROUTINE OHANDE

	INCLUDE 'DOHLIB.INC'

D	IF ( diagnostics ) THEN
D	   WRITE (5,*) 'DOH: return from overlay subroutine'
D	ENDIF

	nlevel = nlevel - 1

	END

C*****************************************************************************

	SUBROUTINE OHANDR ( iseg, len, istart )

	INCLUDE 'DOHLIB.INC'

	IF ( nlevel .NE. 0 ) THEN
	   DO 10 I=1,nlevel
	      IF ( istart .EQ. naddr(I) ) THEN
	         WRITE (5,99) iseg, istart+2
99	         FORMAT ( ' DOH: Illegal call of segment 'O3' at 'O6 )
D	         WRITE (5,*) 'DOH: calling chain:'
D	         WRITE (5,*) 'DOH: segment  address'
	         DO 97 J = 1,NLEVEL
	            WRITE (5,98) nseg(J), naddr(J) + 2
98	            FORMAT ( ' DOH: 'O4,O11 )
97	         CONTINUE

	         STOP 'DOH'
	      ENDIF
10	   CONTINUE
	ENDIF

D	IF ( diagnostics ) THEN
D	   WRITE (5,100) len-1, iseg, istart
D100	   FORMAT ( ' DOH: load 'I5' bytes: segment 'O3' at 'O6 )
D	ENDIF

	END
����������������������������������������������������������������������������������������