(* PACK OBJECT CODE TO PDP-11 *)

VAR
 INP,UT: FILE OF INTEGER;
 I,W,LEN,BYTENO: INTEGER;
 FILNAM: PACKED ARRAY [0..8] OF CHAR;

 PROCEDURE PUTUT(N: INTEGER);
  BEGIN
   CASE BYTENO OF
    0: W := 65536*4*N;
    1: W := W + 1024*65536*N;
    2: W := W + N;
    3: BEGIN   UT^ := W + 256*N; PUT(UT); BYTENO := -1
       END
   END;
   BYTENO := BYTENO + 1;
  END;

 PROCEDURE TRANSFER;
  BEGIN   PUTUT(INP^);  GET(INP)
  END;

 PROCEDURE INIT;
  VAR   CH: CHAR;
  BEGIN     FILNAM := '      OBJ';
   I:=0;   WHILE (I<6) AND NOT EOLN(TTY) DO
    BEGIN   READ( TTY, CH );
     FILNAM[I] := CH
    END;
   RESET(INP,FILNAM,0,0,'DSKD  ');
   FILNAM[8] := 'P';
   REWRITE(UT,FILNAM,0,0,'DSKD  ');
   BYTENO := 0
  END;

BEGIN
 INIT;
 WHILE INP^ = 0 DO GET(INP);
 REPEAT
  TRANSFER; TRANSFER;  LEN := INP^;  TRANSFER; TRANSFER;
  FOR I := 1 TO LEN - 4 DO   TRANSFER;
  IF INP^ < 0 THEN INP^ := INP^ + 256;
  TRANSFER;   TRANSFER;
  WHILE INP^ = 0 DO GET(INP);
 UNTIL EOF(INP);
 FOR I := 1 TO 3 DO PUTUT(0);
END.
