 const
          pb   = $91;
          pa   = $93;
          cb   = $90;
          ca   = $92;

var       linefeed,
          cbm  : char;
          name : string [ 122 ];
          ptr  : text;

procedure portini;

begin

   port [ ca ] := $4f;
   port [ cb ] := $cf;
   port [ cb ] := $2; { pb0 > busy / pb1 > strobe }
   port [ pb ] := 1;
   writeln ( port [pa] , '  ' , port [pb] );
end;


function parein : char;

begin

   port [ pb ] := 0;
   repeat {writeln (port[pb])}
             until ( port [ pb ] = 2 ) or  keypressed ;
   port [ pb ] := 1;
   parein := chr ( port [ pa ] );

end;


begin

   portini;                    linefeed := chr(10);
   write( 'Filename : ' );
   readln( name );
   assign( ptr , name );
   rewrite ( ptr );
   repeat
   begin
      cbm := parein;
      if cbm = chr ( 13 )
       then begin
            writeln ( cbm );
            write ( ptr , cbm );
            write ( ptr , linefeed );
            end
       else begin
            write ( cbm ); write( ptr , cbm ); end;

   end
   until keypressed;
   close ( ptr );
end.