FTN77
      PROGRAM YLOOP(3),READ AND WRITE LOOPBACK
C
C  RU,YLOOP
C
C  NOTE: XWLPB ONLY WORKS WITH EVEN BYTE COUNT FOR LENGTH.
C        SPECIFYING AN ODD COUNT WILL NOT TAG LAST BYTE WITH EOI,
C        E.G., SUPPLIES SIX BYTES FOR LENGTH = 5.
C
      IMPLICIT INTEGER (A-Z)
      INTEGER*4 ADDR
      DIMENSION COMP (24), BUF (1086), PARAM (5)
C
      DO 10 I=1,24
10    COMP (I) = -1
C
C
      LU = 20
C
C
      WRITE (1,1)
1     FORMAT ("BUS ADDRESS? _")
      READ (1,*) BUS
C
C
16    WRITE (1,17)
17    FORMAT ("LENGTH? _")
      READ (1,*) LENGTH
      IF (LENGTH.LT.0.OR.LENGTH.GT.1024) GO TO 16
      BUF (61) = 0
      BUF (62) = LENGTH
C
C
      CALL XRLPB (LU, BUS, COMP, BUF)
C
      WRITE (1,20) BUS, BUF (60)
20    FORMAT ("READ LOOPBACK ADDRESS ",I1," QSTAT ",I1)
C
      IF (BUF (60).NE.0) GO TO 90
C
C XRLPB RETURNS BYTES STARTING AT BUF (60), BUT XWLPB WANTS BYTES
C   STARTING AT BUF (62), SO WE MUST MOVE THE LOT!
C
      DO 30 I=1024,1,-1
30    BUF (I+62) = BUF (I+60)
C
C
      BUF (61) = 0
      BUF (62) = LENGTH
      CALL XWLPB (LU, BUS, COMP, BUF)
C
      WRITE (1,40) BUS, BUF (60)
40    FORMAT ("WRITE LOOPBACK ADDRESS ",I1," QSTAT ",I1)
C
C
      IF (BUF (60).EQ.0) GO TO 999
C
90    WRITE (1,91)
91    FORMAT ("REQUEST STATUS RETURNS:")
      WRITE (1,92) (BUF (I),I=2,11)
92    FORMAT (9(K6,2X),K6)
C
C
999   CONTINUE
      END
      END$
