program undump; { undump is a program to take the output from dump and put it into binary format. } {$I 'binary.pas'} {$I 'ihex.pas'} type FilePath = String[12]; Procedure DumpIHex(iname, oname : FilePath); var inf : Text; outf : Text; line : LnStr; rec : IRec; begin if iname <> '' then begin Assign(inf, iname); Reset(inf); end else inf := Input; if oname <> '' then begin Assign(outf, oname); Rewrite(outf); end else outf := Output; while not EOF(inf) do begin ReadLn(inf, line); if (Line <> '') then begin rec := RdDumpLn(line); WrRec(rec, outf); end; end; Close(inf); Writeln(outf, IRecEOF); Flush(outf); Close(outf); end; procedure PrnHelp; begin WriteLn('UNDUMP V1.0'); WriteLn('Converts DUMP.COM output to Intel Hex format'); WriteLn(''); WriteLn('Usage:'); WriteLn(' UNDUMP.COM INFILE OUTFILE'); Halt; end; var i, argc : Integer; rec : irec; opts : record ShoVer : Boolean; InFile : FilePath; OutFile : FilePath; end; param : String[255]; begin opts.ShoVer := False; opts.InFile := ''; opts.OutFile := ''; argc := ParamCount; for i := 1 to ParamCount do begin if ParamStr(i) = '-h' or ParamStr(i) = 'H' then begin opts.ShoVer := True; argc := argc - 1; end; end; if opts.ShoVer then PrnHelp(); i := ParamCount - argc + 1; if i = 1 then opts.OutFile := ParamStr(ParamCount); if i > 1 then begin InFile := ParamStr(i); OutFile := ParamStr(i+1); end; DumpIHex(InFile, OutFile); end.