|
DataMuseum.dkPresents historical artifacts from the history of: CP/M |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about CP/M Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - download
Length: 5888 (0x1700) Types: TextFile Names: »ZDUMP.PAS«
└─⟦dd59903ef⟧ Bits:30005887 Klub diskette for udveksling af software └─ ⟦this⟧ »ZDUMP.PAS«
PROGRAM dump; æ ***************************************************************** * * * Hex-Ascii file dump utility * * * * Written by: Bob Longoria * * 1024 Lawrence Dr. N.E. * * Albuquerque, New Mexico 87123 * * (505)-298-7231 * * * * Description: * * This program is a slightly improved dump utility * * over the standard dump program which comes with CP/M * * distribution. When dumping, the program will dump * * both in hex (as done by dump.com) and in ascii and * * at a standard CP/M sector (128 bytes) at a time. Also * * each sector is numbered beginning with sector 1. * * Output of the dump can be directed to any desired * * file or output device. For example: * * zdump foo.rel - dumps to the console * * zdump foo.rel con: - also dumps to console * * zdump foo.rel lst: - dumps to listing device * * zdump foo.rel dumb.dmp - dumps to a file * * called dump.dmp * * * ***************************************************************** å CONST MAXARGS = 4; æ Maximum command line arguments å TYPE byte = 0..255; buffer = arrayÆ1..8,1..16Å of 0..255; ch2 = packed arrayÆ1..2Å of char; args = arrayÆ1..MAXARGSÅ of string 14; VAR i : integer; æ General purpose index variable å infile : file of buffer; æ The input file to be dumped å outfile : text; æ The output file to receive the dump å inbuf : buffer; æ Buffer which holds a standard sector å reccount : integer; æ The current sector being processed å argc : integer; æ The number of command line arguments å argv : args; æ The command line argument array å FUNCTION tohex(x : byte) : char; æ Description: receives a byte within the hex range (0-15) and returns the hex character equivalent. å BEGIN case x of 0,1,2,3,4,5,6,7,8,9 : tohex := chr(x+ord('0')); æ If it is in this range, must be a letter character of A-F å 10,11,12,13,14,15: tohex := chr(x+ord('A')-10); end end; FUNCTION cnvrthex(operand : byte) : ch2; æ DESCRIPTION: This function takes a byte and converts it into it's two equivalent hex characters. å VAR remain : byte; BEGIN remain := operand-(operand div 16)*16; cnvrthexÆ2Å := tohex(remain); æ First hex character å operand := operand div 16; remain := operand-(operand div 16)*16; cnvrthexÆ1Å := tohex(remain) æ Second hex character å END; PROCEDURE display(recno : integer; inbuf : buffer); æ DESCRIPTION: This routine takes care of displaying in both hex and ascii the input buffer (128 byte record). å VAR i, j : integer; hexchar : ch2; BEGIN æ Begin by labeling the record number å write(outfile,recno:3,': '); æ This buffer is processed into 8 lines of output å for i := 1 to 8 do begin æ Each line has 16 bytes to process å æ Begin by writing out the hexidecimal equivalents of each of the bytes å for j := 1 to 16 do begin hexchar := cnvrthex(inbufÆi,jÅ); write(outfile,hexchar,' ') end; æ Now convert the same 16 bytes into their ascii eqivalents å write(outfile,' '); for j := 1 to 16 do begin æ If the byte is a non-printing character, sub- stitute an ascii "." in its place å if (inbufÆi,jÅ < 32) or (inbufÆi,jÅ > 126) then write(outfile,'.') æ Otherwise print the actual ascii equivalent å else write(outfile,chr(inbufÆi,jÅ)) end; writeln(outfile); write(outfile,' ') end; writeln(outfile) END; PROCEDURE cmdline(var count : integer; var token : args); æ DESCRIPTION This routine performs several functions. It reads the CP/M command tail if any and breaks the command tail into tokens. A token is any string of characters delimited by either the beginning of the command tail, the end of the command tail, or a space. The routine returns the token count and all tokens found. å VAR cmd_line : packed arrayÆ1..80Å of char; i, j : integer; BEGIN æ cmdline å æ Make sure the command line is clean å for i := 1 to 80 do cmd_lineÆiÅ := ' '; count := 0; æ if the following is true there is a command tail, otherwise leave the count set to 0 and do not parse the command line å if not eoln(0) then begin readln(cmd_line); i := 0; repeat i := i+1; if cmd_lineÆiÅ <> ' ' then begin count := count+1; j := 1; tokenÆcount,jÅ := cmd_lineÆiÅ; while cmd_lineÆi+1Å <> ' ' do begin i := i+1; j := j+1; tokenÆcount,jÅ := cmd_lineÆiÅ end æ while å end æ if å until i = 80 end æ if not eoln å END; æ cmdline å BEGIN æ MAIN CODE å writeln; æ Make sure command line arguments are clean å for i := 1 to MAXARGS do argvÆiÅ := ' '; reccount := 1; æ Begin numbering records at 1 å cmdline(argc,argv); æ Get and parse the command line å if argc = 0 then writeln('No INPUT file specified') else if argc > 2 then writeln('Too many command line arguments') else begin æ Default output goes to the console å if argc = 1 then argvÆ2Å := 'CON:'; reset(argvÆ1Å,infile); rewrite(argvÆ2Å,outfile); writeln(outfile,' Hex-Ascii file dump -- Vers. 1.1'); writeln(outfile); æ Process until EOF detected on input file å while not(eof(infile)) do begin read(infile,inbuf); display(reccount,inbuf); reccount := reccount+1 end end END. «eof»