*  Subroutine RESDCE - Reserve Directory Cache Entry
*
*  This routine goes through the directory name cache
*  and looks for any unused entries.  If it finds one,
*  it returns a pointer to that entry in the caller's
*  R4.  If there are no unused entries, it will reuse
*  the least recently used entry.
*

RESDCE DATA FDDRWS
       DATA RESD1

RESD1  SETO R3           R3 will store oldest age
       LI   R4,DNCASH
RESD2  MOV  @4(R4),R5    See if this entry is unused
       JEQ  RESD4

       C    R3,@46(R4)   Check this entry's age
       JL   RESD3
       MOV  @46(R4),R3   Save new age
       MOV  R4,R5        R5 points to oldest entry

RESD3  AI   R4,48
       CI   R4,>5FFE-48
       JL   RESD2

       MOV  R5,R4
RESD4  INC  @>5FFE
       MOV  @>5FFE,@46(R4)
       MOV  R4,@8(R13)
       CLR  *R4+
       CLR  *R4+
       LI   R5,'  '
       LI   R3,40
RESD5  MOV  R5,*R4+
       DECT R3
       JNE  RESD5
       RTWP
