home *** CD-ROM | disk | FTP | other *** search
- {FileDump.pas Typed in by Lem Hill from the
- Turbo Pascal Ver. 2.0 Micro/Systems Journal Vol. 1/3
- PC-DOS Version July/Aug 1985 page 19.
- Copyright 1985 by David W. Carroll
- Date: 4/23/85 Modifications by Lem 7/1/85
- Version: 10 called FDump.pas/com
- }
-
- program filedump;
- const
- bell = 07;
- version = '10';
-
- type
- datstr = string[20];
- datafile = file of byte;
-
- var
- infile : datafile;
- infname : string[20];
- asciitext : string[20];
- sec : real;
- sec1 : real;
- col : byte;
- dat : byte;
- msec : byte;
- hsec : byte;
- lsec : byte;
- goodfile : boolean;
- quit : boolean;
-
- procedure trans(indat: byte);
- var
- ch : char;
-
- function xlt(bdat: byte): char;
- begin
- case bdat of
- 0..9 : xlt := chr(bdat + ord('0'));
- 10..15 : xlt := chr(bdat + ord('A') - 10);
- else
- ch := 'X';
- end;
- end;
-
- begin
- ch := xlt(indat div 16);
- write(ch);
- ch := xlt(indat mod 16);
- write(ch);
- end;
-
- procedure Uppercase(var str: datstr);
- var
- indx, len : integer;
-
- begin
- len := length(str);
- for indx := 1 to len do
- str[indx] := UpCase(str[indx])
- end;
-
- begin
- asciitext[0] := chr(16); {set ASCII string length}
- sec := 256; {set initial .COM address}
- quit := false;
- ClrScr;
- writeln;
- write('File HEX and ASCII DUMP program Version ');
- write(version);
- writeln(' | Mods by Lem Hill 7/1/85 and');
- write('Copyright 1985 by David W. Carroll');
- writeln(' | now called FDump.com');
- writeln;
- window(1,5,80,25);
- repeat
- ClrScr;
- write('Input filename --> ');
- readln(infname);
- if length(infname) > 0 then
- begin
- assign(infile,infname);
- {$I-} reset(infile) {$I+};
- goodfile := (IOresult = 0);
- if not goodfile then
- begin
- write(chr(bell));
- writeln('FILE ',infname,' NOT FOUND');
- delay(3000)
- end;
- end
- else
- quit := true;
- until goodfile or quit;
- if not quit then
- begin
-
- {reset start address if not .COM}
- uppercase(infname);
- if (pos('.COM',infname)=0) then sec := 0;
-
- writeln;
- write('Address 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F ');
- writeln(' ASCII TEXT');
- write('------- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- ');
- writeln(' ----------');
- window(1,9,80,25);
- while not eof(infile) do
- begin
- msec := trunc(sec / 65536.0);
- trans(msec);
- write(' ');
- sec1 := sec - (msec * 65536.0);
- hsec := trunc(sec1 / 256);
- lsec := trunc(sec1 - (hsec * 256.0));
- trans(hsec);
- trans(lsec);
- write(' ');
- for col := 1 to 16 do
- begin
- if not eof(infile) then
- begin
- read(infile,dat);
- trans(dat);
- if dat in [32..126] then
- asciitext[col] := chr(dat)
- else
- asciitext[col] := '.';
- end
- else
- begin
- write(' ');
- dat := 0;
- asciitext[col] := ' ';
- end;
- write(' ');
- if col = 8 then write(' ');
- end;
- writeln(' *',asciitext,'*');
- if lsec = 240 then
- begin
- repeat until KeyPressed;
- writeln;
- end;
- sec := sec + 16
- end;
- close(infile);
- end;
- if not quit then
- begin
- writeln;
- writeln(' - eof -');
- end;
- end.
-
-