{$T+}
program  merge(input,output,codeFile,blFile,pascalFile);
{
This asks for the filenames of a machine code file, a bl-code
(Pascal object) file and a final file. It merges the first
two files to create the last.
}

const
   nameLen = 10;

type
   byte = 0..255;
   name = packed array[1..nameLen] of char;
   binary = packed file of byte;

var
   codeFile : binary;
   blFile   : binary;
   pascalFile : binary;
   codeName : name;
   blName   : name;
   pascalName : name;
   prompt : boolean;


procedure readName(var fileName : name);
var
   i : 1..nameLen;

begin
   for i:=1 to nameLen do
     fileName[i] := ' ';
   while input^ = ' ' do
     get(input);
   i := 1;
   repeat
     read(fileName[i]);
     i := i+1
   until eoln or (fileName[i-1]=' ');
   if eoln then
     readln
end;

procedure  copy(var sourceFile, destFile : binary);
var
   b : byte;
begin
   while not eof(sourceFile) do
      begin
         read(sourceFile, b);
         write(destFile, b)
      end
end;

begin { Main Program }

   prompt := eoln;

   if prompt then
     write('Name of machine code file: ');
   readName(codeName);

   if prompt then
     write('Name of object file: ');
   readName(blName);

   if prompt then
     write('Name of final object file: ');
   readName(pascalName);

   reset(codeFile, codeName);
   reset(blFile, blName);
   rewrite(pascalFile, pascalName);

   copy(codeFile, pascalFile);
   copy(blFile, pascalFile);

   writeln('Finished')

end.
