      SUBROUTINE MAIN
      INTEGER N, I, FLAG, TYPE, X, JUNK
      INTEGER READF, WRITEF, TBLOOK
      LOGICAL*1 BUF(5000), NAME(20), Y, DEFN(10)
      EQUIVALENCE (X,Y)
      CALL QUERY(54Husage:  objfix <input.obj >output.obj [psect_file] .
     *..)
      CALL INIT
      N=READF(BUF, 5000, 1)
23000 IF (.NOT.(N .GE. 0))GOTO 23002
      IF (.NOT.(N .GT. 0))GOTO 23003
      IF (.NOT.(BUF(1) .EQ. 1))GOTO 23005
      I=3
23007 IF (.NOT.(I .LT. N))GOTO 23009
      FLAG = I + 4
      TYPE = I + 5
      IF (.NOT.(BUF(TYPE) .EQ. 5))GOTO 23010
      CALL FMT(BUF(I), NAME)
      IF (.NOT.(TBLOOK(NAME, DEFN) .EQ. 1))GOTO 23012
      X = 0
      Y = BUF(FLAG)
      X = IOR(X, 16)
      BUF(FLAG) = Y
23012 CONTINUE
      CALL PUTLIN(NAME, 3)
      CALL PUTCH(32, 3)
      CALL PCHAR(BUF(FLAG), 3)
      CALL PUTCH(10, 3)
23010 CONTINUE
23008 I=I+8
      GOTO 23007
23009 CONTINUE
23005 CONTINUE
23003 CONTINUE
      JUNK = WRITEF(BUF, N, 2)
23001 N=READF(BUF, 5000, 1)
      GOTO 23000
23002 CONTINUE
      RETURN
      END
      SUBROUTINE DOIT(I, ZERO, ONE, INT)
      INTEGER I, INT
      LOGICAL*1 ZERO(100), ONE(100)
      IF (.NOT.(MOD(I,2) .EQ. 0))GOTO 23014
      CALL PUTLIN(ZERO, INT)
      GOTO 23015
23014 CONTINUE
      CALL PUTLIN(ONE, INT)
23015 CONTINUE
      I = I / 2
      RETURN
      END
      SUBROUTINE FMT(BUF, STR)
      LOGICAL*1 STR(100), BUF(100)
      CALL R50ASC(6, BUF, STR)
      STR(7) = 0
      CALL FOLD(STR)
      RETURN
      END
      SUBROUTINE PCHAR(N, INT)
      LOGICAL*1 N, X
      INTEGER I
      EQUIVALENCE (X, I)
      I = 0
      X = N
      I = I / 4
      CALL DOIT(I, 4HCON , 4HOVR , INT)
      I = I / 2
      CALL DOIT(I, 3HRW , 3HRO , INT)
      CALL DOIT(I, 4HABS , 4HREL , INT)
      CALL DOIT(I, 4HLCL , 4HGBL , INT)
      CALL DOIT(I, 1HI, 1HD, INT)
      RETURN
      END
      SUBROUTINE INIT
      LOGICAL*1 BUF(512)
      INTEGER I, N
      INTEGER GETARG, GETLIN, LENGTH
      INTEGER FD
      INTEGER OPEN
      INTEGER MEM(1000)
      LOGICAL*1 CMEM(2000)
      EQUIVALENCE (CMEM(1),MEM(1))
      COMMON/CDSMEM/MEM
      LOGICAL*1 NULL(1)
      DATA NULL(1)/0/
      CALL TBINIT(1000)
      I=1
23016 IF (.NOT.(GETARG(I, BUF, 40) .NE. -1))GOTO 23018
      FD = OPEN(BUF, 1)
      IF (.NOT.(FD .EQ. -3))GOTO 23019
      CALL CANT(BUF)
23019 CONTINUE
23021 IF (.NOT.(GETLIN(BUF, FD) .NE. -1))GOTO 23022
      N=LENGTH(BUF)
23023 IF (.NOT.(N .LE. 6))GOTO 23025
      BUF(N) = 32
23024 N=N+1
      GOTO 23023
23025 CONTINUE
      BUF(N) = 0
      CALL FOLD(BUF)
      CALL TBINST(BUF, NULL)
      GOTO 23021
23022 CONTINUE
      CALL CLOSE(FD)
23017 I=I+1
      GOTO 23016
23018 CONTINUE
      RETURN
      END
