%begin {Generate LIB.A}

   %routine Read Word(%string(255)%name S)
      %integer C
      S = ""
      %cycle
         Readsymbol(C)
         %return %if C = NL %and S # ""
         C = C+32 %if 'A' <= C <= 'Z'
         S = S.Tostring(C) %unless C <= ' '
      %repeat
   %end

   %routine String(%string(255) S)
      %integer J
      Printsymbol(Length(S))
      Printsymbol(Charno(S, J)) %for J = 1, 1, Length(S)
   %end

   %routine Copy(%string(255) Id)
      %string(255) In = "[ARM.RTL.LIBRARY]".Id.".o", Out
      %on 9 %start
         Select Output(0)
         Printstring("cannot access ".In);  Newline
         %return
      %finish
      Open Input(2, In);  Select Input(2)
      Select Output(1)
      Out = Id
      Printsymbol(254);  String(Out)
      %begin
         %integer J, C
         %string(127) Line
         %on 9 %start
            String(Line) %unless Line = ""
            %return
         %finish
         %cycle
            Line = ""
            %for J = 1, 1, 127 %cycle
               Readsymbol(C)
               Line = Line.Tostring(C)
            %repeat
            String(Line)
         %repeat
      %end
      Printsymbol(255)
      Close Input
   %end

   %begin
      Open Input(1, "LIBLIST.DAT")
      Open Binary Output(1, "[ARM.NATIVE.OBJECT]LIB.A")
      %begin
         %string(255) Id
         %on 9 %start
            %return
         %finish
         %cycle
            Select Input(1)
            Read Word(Id)
            Copy(Id)
         %repeat
      %end
   %end

   %begin
      %string(255) Id
      %on 9 %start
         %return
      %finish
      Select Input(1)
      Reset Input
      Open Output(2, "[arm.native.object]liblist.dat")
      Select Output(2)
      %cycle
         Read Word(Id)
         %continue %if Id = "mindiag" %or Id = "startimp" %or Id = "startpas"
         Id = "lib".Tostring(Charno(Id, 1)).".".Id
         Printstring(Id);  Newline
      %repeat
   %end
%end
